I am trying to read a binary file. This file records seismic data. Basically its first 3600 bytes are for the general file information, following are for seismic traces, each begins with 240 bytes for information about this trace.
For the file I am reading, it has 3617 traces, each trace has 6240 bytes, with the first 240 bytes for trace headers. Following the trace headers are some velocity values for underground formation, it has 1500 data points. I can view this data using some commercial software... the values should be around 4999.99 feet/s(velocity of sea water) to 14800 feet/s. But what I read range from 590.125 to 743.25, which is obviously not correct.
Later I found out that the binary file I am trying to read stores IBM-format floating point values.
If I read it as an IEEE binary file, for integer data, it is all right, but for floating point data, what I read is totally wrong.
The trace head I read is about the geographic location of the traces, and it is correctly read by Mathematica, giving {0, 20, 40, 60, ..., 72320} feet. I don't need to read all the trace headers.
What I care about most is reading the correct velocity values.
Here's the code I have so far (the input files are from timodel_vp.segy.gz (22 MB) from here: http://software.seg.org/datasets/2D/Hess_VTI/)
nByteFile =
FileByteCount[
"timodel_c11.segy"];
nByteTrace = (nByteFile - 3600)/3617;
nTraceSample = (nByteTrace - 240)/4;
str = OpenRead[
"timodel_vp.segy",
BinaryFormat -> True];
pos = Range[3600, nByteFile - 1, nByteTrace];
traces = {SetStreamPosition[str, # + 76];
BinaryRead[str, "Integer32", ByteOrdering -> +1],
SetStreamPosition[str, # + 240];
Table[BinaryRead[str, "Real32",
ByteOrdering -> +1], {nTraceSample}]} & /@ pos;