[SciPy-User] dtype of LabView binary files
Tue Nov 9 16:51:14 CST 2010
Xunchen Liu wrote:
> It seems there is only one web page here talking about the dtype of the
> binary file saved from Labview:
> I followed Travis' suggestion on that page to convert one of my Labview
> binary file using
> but this gives a array doubled the shape of my recorded data
hmm -- "d" is already double (64 bit float) -- could the labview data be
128bit? seems unlikely.
> and also
> the value of the data are not right.
> For example, the attached is the text file and binary file saved by Labview.
> the text file reads:
> array([-2332., -2420., -2460., ..., 1660., 1788., 1804.])
> while the binary file reads (with dtype='>d')
> array([-3.30078125, 0. , -3.30297852, ..., 0. ,
> -2.6953125 , 0. ])
> Anyone knows what dtype I should use, or how should I build the correct
> dtype for it?
I see from that web page:
"One final note about arrays: arrays are represented by a 32-bit
dimension, followed by the data."
so you may need to skip (or read) 32 bits (4 bytes) before you read the
header = numpy.fromfile(infile, dtype='>i',count=1)
data = numpy.fromfile(infile, dtype='>d')
that's guessing that the header is big-endian 32bit integer.
You also might try both ">" and "<" -- maybe it's not big endian?
It's going to take some experimentation.
The good news that if you read binary data wrong, the result is usually
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
More information about the SciPy-User