Giter Club home page Giter Club logo

readpl4's Introduction

readPL4

Describe and read ATP's (Alternative Transients Program) PL4 binary data file format by means of reverse engineering.

The documentation of this project can be found on the wiki pages.

Note: This a very new project, therefore things here may seem messy. However, don't let it scare you. Come closer, take a seat and help us out! =)

readpl4's People

Contributors

ldemattos avatar pdb5627 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

readpl4's Issues

Port to Matlab

Here's an alternate version of the code ported to Matlab.
P.s. I am smart enough to translate Python to Matlab, but too dumb to figure how to properly make a pull request.

function [data,varnames,miscData] = readPL4(pl4file)

miscData = struct('deltat',0.0,'nvar',0,'pl4size',0,'steps',0,'tmax',0.0);

% open binary file for reading
fid = fopen(pl4file,'r');

% read DELTAT
fseek(fid,40,'bof');
miscData.deltat = fread(fid,1,'float32');

% read number of vars
fseek(fid,48,'bof');
miscData.nvar = floor(fread(fid,1,'uint32')/2);

% read PL4 disk size
fseek(fid,56,'bof');
miscData.pl4size = fread(fid,1,'uint32')-1;

%read variable names
varnames{1,1}='t';
for i = 0:miscData.nvar-1
pos = 516 + i16;
fseek(fid,pos,'bof');
h = fread(fid,[1 16],'*char');
vartype=str2num(h(4));
switch vartype
case 4 %'V-node'
h(1:4)='Vno_';
case 7 %'E-bran'
h(1:4)='Ebr_';
case 8 % 'V-bran'
h(1:4)='Vbr_';
case 9 % 'I-bran'
h(1:4)='Ibr_';
end
varnames{1,i+2}=h;
end

% compute the number of simulation miscData.steps from the PL4's file size
miscData.steps = (miscData.pl4size - 516 - miscData.nvar16) / ...
((miscData.nvar+1)*4)
miscData.tmax = (miscData.steps-1)*miscData.deltat

% Check for unexpected rows of zeros
expsize = (5 + miscData.nvar)16 + miscData.steps(miscData.nvar+1)*4;
nullbytes = 0;
if miscData.pl4size > expsize
nullbytes = miscData.pl4size-expsize;
end

% close the file
fclose(fid);

% read and store actual data as a matrix
m = memmapfile(pl4file,'Format','single','Writable',false,...
'Offset',(5 + miscData.nvar)16 + nullbytes,...
'Repeat',miscData.steps
(miscData.nvar+1));
% create a Matlab matrix from the memory map data
data = reshape(m.Data,[miscData.nvar+1,miscData.steps])';

end

Check for PL4 version

Would be great to check the PL4 file format and, if it is the old PISA's format, return an error to the user and end the program.

Python 3 version

readPL4 must have one python3 version since python2 is officially decommissioned.

PL4 and frequency scan simulations

I've made some experiments with frequency scan simulations using ATP and ATPDraw 6.2.
The experiments were not exhaustive but I've noticed some modifications in pl4 file:

The field TMAX now is the FMAX (maximum frequency of the scan). In a similar manner, delta_t becomes delta_f.

The line 0x04 is no longer full of zeros. It will show different content based on the type of simulation output:

  • Abs output: the line 0x04 is 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00

  • Abs/ang output: the line 0x04 is 01 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 and the number of channels doubled.

  • Re/img output: the line 0x04 is 02 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 with also twice the number of channels.

  • All output: the line 0x04 is 03 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 with four times the number of outputs.

It seems that bytes 0 to 3 represent the type of output and bytes 4 to 7 the number of channels per measured variable.

There are changes in bytes 12 to 15 in line 0x02. They seems to change as the simulation and type of output changes.

There are no changes in the ASCII lines of measurement names, but they are doubled or quadrupled accordingly with the simulation type and output. VT parameter also didn't changed.

I didn’t check the parameter NPD (Number of frequencies per decades in logarithmic scan) yet.

time data

The time data values are in the last column of the data memmap, not in the first as the example sugests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.