[ncl-talk] Help reading binary file

David Brown dbrown at ucar.edu
Fri Dec 5 17:02:07 MST 2014


It's pretty hard to tell what's going on with this file without
additional information. But there are a few observations I could make
after experimenting with this file a bit.
1) The size in bytes of the file is exactly 4 * 5 * 720 * 1440
(20,736,000 bytes). If you look at the section "Hints on determining
the exact format of a binary file" on this page:
http://www.ncl.ucar.edu/Applications/r-binary.shtml, you will see that
most likely means that the file is a flat binary file -- in other
words there are no record indicators, meaning that you should use
fbindirread or cbinread.
2) Also since the variable gives a very small numbers for both min and
max when read as is (on my little endian machine), it is likely
written in
big endian byte order. That means you should do
setfileoption("bin","ReadByteOrder", "BigEndian") prior to reading the
file.

3) You have the ordering of the dimensions as (/1440, 720, 5/) , or
(lat, lon, time). Are you sure this is the right order? This seems to
be Fortran type specification for the order, and I suspect that the
correct NCL specification is reversed: (/ 5, 720, 1440 /)

4) Are you sure the type of the data is really float? Could it really
be an integer type that is supposed to have a scale and offset
supplied. Also are any of the values supposed to be fill values? You
really need to find out a bit more about this data in order to plot it
correctly.

Anyway, with the above thoughts in mind, I am attaching a modified
version of your script that plots the five time steps. The first one,
at least seems somewhat plausible for a plot of "dust". Maybe this
will help get you where you want to go.

 -dave


On Fri, Dec 5, 2014 at 2:18 PM, Debasish Hazra
<debasish.hazra5 at gmail.com> wrote:
> Hi,
>
>  I am trying to read binary ".dat" file with ncl with limited success. Data
> dimension is (1440,720,5) and attached the attempted script. Uploaded the
> file in NCL ftp (viirs_dbdi_gridded_statis2013182.dat). Any help is
> appreciated.
>
>  Thanks.
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: viirs_13-mod.ncl
Type: application/octet-stream
Size: 3437 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141205/67c62714/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Daily_dust.000001.png
Type: image/png
Size: 162361 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141205/67c62714/attachment.png 


More information about the ncl-talk mailing list