Re: grid file

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Thu, 12 Feb 2009 13:24:34 -0700

Hello Jean,

If you don't know anything about the file you can sometimes figure
out the contents by trial and error.
In this case, some preliminary examination of the file using the unix
tool 'od' leads me to suspect that
it contains floating point data in little endian byte order (the
native ordering for machines with Intel or AMD processors).

Based on that assumption one can try to read it in using NCL's
'cbinread' function. There are other binary read functions
that work for data produced using Fortran I/O, but in this case
'cbinread' seems to work. Since at this point you don't know
anything about the size or shape of the data you should use '-1' for
the dimensionality.

Note that if you are on a big endian machine such as a Sun you would
need to set the file option 'ReadByteOrder':

setfileoption("bin","ReadByteOrder","LittleEndian")

ncl 0> v = cbinread("teste.grd",-1,"float")
ncl 1> printVarSummary(v)

Variable: v
Type: float
Total Size: 112640 bytes
             28160 values
Number of Dimensions: 1
Dimensions and sizes: [28160]
Coordinates:

This shows that there are 28160 values (assuming that we are correct
that the data is of type float).
You can do 'print' to look at some of the values to see if they seem
reasonable.

Variable: v
Type: float
Total Size: 112640 bytes
             28160 values
Number of Dimensions: 1
Dimensions and sizes: [28160]
Coordinates:
(0) 777.7
(1) 777.7
(2) -5.413627e-07
(3) -4.686144e-07
(4) -6.543725e-07
(5) -0.0003050262
(6) -0.001332043
(7) -0.002676598
(8) -0.003201173
(9) -0.003188876
(10) -0.002605822
(11) -0.000739796
(12) 0.001711554
(13) 0.002846484
(14) 0.003098317
(15) 0.003083683
(16) 0.00268075

Depending on what the data represents these values could be
plausible. At least they are not wildly strange and totally
discontinuous. We could speculate that the value 777.7 might
represent a missing value. Now the question is what are the
actual dimensions of the grid. Assuming it is 2 dimensional we could
find the factors of 28160 and then, as a starting guess,
take numbers that result in the 'squarest' grid (i.e. the integer
factors closest to the square root of 28160 -- 167.809). These turn
out to be 160 and 176. If we are lucky these will be the grid
dimensions, the only remaining question being which order are they
in.

Using the function 'onedtond' we can create new variables with these
shapes and try to visualize them to see whether they
look reasonable.

ncl 4> v1 = onedtond(v,(/160,176/))
ncl 5> v2 = onedtond(v,(/176,160/))

Visualizing these as simple raster plots produces the two plots
similar to these that I enclose. Note that I set the value 777.7 as
the missing value for both.
One of them looks visually pretty good so I am guessing that is the
correct representation of your data. The staggered appearance of the
'bad' plot is
a good indicator that something is wrong with the shape of the data.

Hope this helps,
   -dave

On Feb 12, 2009, at 10:08 AM, jean_at_met.com.br wrote:

> Hi all!
>
> I'm a new user and I need help.
> I would like to know how I can read a .grd file if I don't know the
> array
> and size of this file.
>
> I tried to send the file within this email, I hope you can see.
>
> Thank's
>
> Jean<teste.grd>_______________________________________________
> 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

good.png bad.png
Received on Thu Feb 12 2009 - 13:24:34 MST

This archive was generated by hypermail 2.2.0 : Thu Feb 19 2009 - 09:54:51 MST