Re: About reading .bin files in NCL

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Dec 27 2012 - 09:23:00 MST

Hi Waqar,

I'm not an expert on binary files, but the error is simply telling you that you are trying to read more data off your file than what the size of the file is. Also, you are giving it "record 5", which means it expects there to be four other records on the file before you get to the data you want.

For example, if you want to read a 10 x 20 float array, then binary file needs to be at least 10 * 20 * 4 (size of float) in size (800 bytes). If you tell it to read record #5, then I believe you need to have four other records on the file of size 800 bytes, so now your file needs to be at least 800*5 bytes in size. (4000). Since there has to be a record identifier on the file, the file may be 4 or 8 bytes size larger for each record, to hold the record identifier.

You should do an "ls -l" on your file to see what the size is.

You are specifying a size of 144 x 73 x 9 x 420 x 46 with a float type, so this means a size of 144*73*9*420*46*4 = 7311306240 bytes, with four more records this size.

Is your file indeed at least this big (36556531200 bytes)?

Are you sure the file was written with direct access write? If it was written with unformatted sequential access, then you may need to use fbinrecread instead.

Please see the nice section "Hints on determining the exact format of a binary file" by Dave Allured on reading binary files:

http://www.ncl.ucar.edu/Applications/r-binary.shtml

This URL also shows you how to convert a binary file to NetCDF after you've attached coordinate arrays.

For writing efficient (and faster) NetCDF files, you should see our NetCDF output page:

http://www.ncl.ucar.edu/Applications/method_2.shtml

If you still have problems, it will help if you can provide some information about the how the file was written, how big it is, etc.

--Mary

On Dec 27, 2012, at 2:13 AM, Waqar Younas wrote:

> Hi
> I am using NCL version 6.1.0 beta version. I am wondering what is correct way of reading .bin files in NCL. I am trying to read ENSEMBLES project stream 2, uwind data at 850mb.
> The data dimensions are
> 144,73,9,420,46 where these numbers are representing lon, lat, ensemble member, lead time and number of years respectively.
> I am using the following to read the data but i am facing errors.
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> v = fbindirread("ua.nov.ECMWF.ENSEMBLES.bin", 5, (/144,73,9,420,46/), "float")
> But i am facing error like
> fatal:fbindirread: The size implied by the dimension array and record number is greater that the size of the file, can't continue
>
> Is there any way to convert .bin file into .nc using NCL because even if i read the .bin file, the geographical coordinates like lat, lon are not assigned to the data. Using .bin file, we can not get information like ncdump.
>
> Any help would be highly appreciated.
>
> --
> Best Regards
>
> Waqar Younas
> PhD Candidate
> Natural Resources and Environmental Studies (NRES)
> University of Northern British Columbia (UNBC)
> Canada
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Dec 27 09:25:59 2012

This archive was generated by hypermail 2.1.8 : Fri Jan 04 2013 - 15:32:29 MST