How to load a complicated binary file into igor
Lucas
Now i want to load a binary data into Igor, the raw binary data consists of 100 Rows, 4 Columns, the data format is just like this:
Column Bytes Type Object_name
Column_1 6 bytes, string, "Time";
Column_2 2 bytes, string, "Data_Quality";
Column_3 4 bytes, real, "Data"
The Column_3 "Data" is what i want, the problem is how to extract it from such a binary file with Igor?
Thanks!
Lucas
Set the dialog up as shown in the attachment. This creates a command like this:
GBLoadWave/B/V/T={2,2}/W=3
This treats the file as containing 3 interleaved waves where the data for each wave is a single-precision floating point value.
This will create three waves. The first two will be garbage and you should kill them. The third should contain the data of interest.
There is a possibility that you will need to use "high byte first" (/B=0) instead of "low byte first" (/B or /B=1).
December 22, 2014 at 11:26 am - Permalink
That's a good idea, maybe i can try that when i need to deal with data which have 3(or more) columns && all the columns have the same Bytes .
In my case, there are 4 columns, and each column has different formats and bytes, so if i load all the data as single-precision floating (32 bit), the data will be disordered.
I have thought up a way, though maybe a little violent, it works.
(6_bytes, string) (3_bytes, string) (4_bytes, single float) (1_byte, integer)
(6_bytes, string) (3_bytes, string) (4_bytes, single float) (1_byte, integer)
.......
(300 rows, 4 columns, each column has 14 bytes)
The third column is what i want to extract. The start byte is 10, so we can skip 9 bytes when i want to extract the first data point, and load all the binary data left as single_float into wave0, the first point in this wave is what i want.
And we can skip (9+14) bytes to extract the second data point into wave1. And so on... We will produce 300 waves, and the first point of each wave is what i want, so i just need to obtain the first point value of each wave to make up a new wave.
By setting the parameter /S=(skip) , i can control the start byte. I haven't found a way to control the end byte, so i have to load all the data 300 times, it's really a wast of memory.
skip = 9 + 14*i
GBLoadWave/Q/B=1/V/A=S006_SD/T={2,2}/S=(skip)/W=1 "G:SWIR_SD"
endfor
December 23, 2014 at 05:41 am - Permalink
FBinRead
function? This is probably more appropriate for the complicated form of your data file.To simplify this further, you can define a structure with the same format as a row of values in the file and load an entire row at once.
Sorry for the vague offering here, but your response to Howard indicates that you should be able to take it from here.
December 23, 2014 at 06:49 am - Permalink