comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » reading binary file with READ_BINARY
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: reading binary file with READ_BINARY [message #89891 is a reply to message #86190] Wed, 17 December 2014 14:32 Go to previous message
zzhaoch is currently offline  zzhaoch
Messages: 1
Registered: December 2014
Junior Member
Hi,

You can read in the follow way,

Data = read_binary('smoothmap.fix.2.bin',DATA_TYPE=4,ENDIAN='big');
Data = Data[1:64800]
Data = reform(Data,[360,180])

Best,
Zhao


On Thursday, October 17, 2013 8:00:10 AM UTC-4, mish...@gmail.com wrote:
> Folks,
>
> I am trying to read a binary file in IDL containing a simple 2D array of 360x180 values. For reference, the binary file can be found here:
>
> http://transcom.project.asu.edu/download/transcom03/smoothma p.fix.2.bin
>
> Here is what the readme for this .bin says:
>
> The file 'smoothmap.fix.2.bin' contains a single real, binary
> array dimensioned 360 x 180. The array contains the numbers 1
> through 22, denoting each of the 22 basis functions in the
> TransCom 3 experiment. This file was written on an SGI Origin
> 2000 hosting UNIX.
>
> And my code:
>
> GET_LUN, fstart
> OPENR, fstart, FFilename
>
> mask_data = READ_BINARY(fstart, DATA_DIMS=[360,180], DATA_TYPE=4) ; float data
>
>
> Now mask_data contains only junk values:
> print, mask_data[0:100] gives
> -2.24089e-038 0.000000 0.000000 0.000000 ....
>
> Why would that be?
>
> Also, I've noticed the .bin file size is 259208 bytes, aka 8 bytes more than the space required to store a 360x180 float array. I've been looking at this for an hour now and I'm stumped. Played around with endian-ness settings but that did not help.
>
> How can I read in this file correctly?
>
> Thank you!
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Synchronizing xrange of cgZPlot with another plot
Next Topic: quirk End of file encountered before end of program

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 06:57:20 PDT 2025

Total time taken to generate the page: 0.24457 seconds