Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'How to read IMB 32-bit floating point binary fi...' topicStudent Support Forum > General > Archives > "How to read IMB 32-bit floating point binary fi..."

Next Comment >Help | Reply To Topic
Author Comment/Response
Fuyong Yan
06/24/13 11:34am

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 begin 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 is IBM binary file. If I read it as 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 trace, and it is correctly read by mathematica, which is {0, 20, 40, 60, ..., 72320} feet. I don't need to read all the trace headers. What I care most is to read the correct velocity values.

Could someone help me? Thanks a lot!

(* The following code do not work right away, you need to download and unzip the file first and replace the file string path, the file name is timodel_vp.segy.gz, it is about 22 Megabytes after unzip and absolutely free to download. The address is:

Sorry for the inconvenience! *)

nByteFile =

nByteTrace = (nByteFile - 3600)/3617;

nTraceSample = (nByteTrace - 240)/4;

str = OpenRead[
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;

Attachment: readIBMbinaryfile.nb, URL: ,

Subject (listing for 'How to read IMB 32-bit floating point binary fi...')
Author Date Posted
How to read IMB 32-bit floating point binary fi... Fuyong Yan 06/24/13 11:34am
Re: How to read IMB 32-bit floating point binar... Bill Simpson 06/29/13 10:39pm
Next Comment >Help | Reply To Topic