[ncl-talk] reading grd file

Dennis Shea shea at ucar.edu
Mon Mar 9 20:31:51 MDT 2020


It would be nice if you provided mor information on the file.

[1] The binary file is "LittleEndian" not "BigEndian"
[2] I think there is a header record because nlat*mlon=424*1327=562648
     is less than the total file length.

Attached is a guess at how to read the file.

%> ncl  VIENTO_MUNDO.ncl

Good luck


On Mon, Mar 9, 2020 at 11:47 AM Paimazumder, Debasish via ncl-talk <
ncl-talk at ucar.edu> wrote:

> Hi NCL users
>
> I’m trying to open/read/plot a grd file in NCL. Frist I read the file in R
> to identify the dimensions
>
> > r
>
> class      : RasterLayer
>
> dimensions : 424, 1327, 562648  (nrow, ncol, ncell)
>
> resolution : 0.2713213, 0.2713213  (x, y)
>
> extent     : -180.1357, 179.9078, -55.13566, 59.90459  (xmin, xmax, ymin,
> ymax)
>
> crs        : NA
>
> source     : H:/MunichRe_Wind/VIENTO_MUNDO_TR100_INT1.grd
>
> names      : VIENTO_MUNDO_TR100_INT1
>
> values     : 0, 444.2024  (min, max)
>
>
>
> When I read it in NCL, the max and min number are different
>
>
>
> Variable: x
>
> Type: float
>
> Total Size: 2250592 bytes
>
>             562648 values
>
> Number of Dimensions: 2
>
> Dimensions and sizes:   [lat | 424] x [lon | 1327]
>
> Coordinates:
>
>             lat: [-55.13566..59.90459]
>
>             lon: [-180.1357..179.9078]
>
> Number Of Attributes: 3
>
>   units :       ??
>
>   long_name :   100 year windspeed
>
>   _FillValue :  -999
>
> (0)     min(x)=-3.39951e+38
>
> (0)     max(x)=3.40086e+38
>
>
>
> Max/Min number in R looks more reasonable. Here is file –
>
> https://data.humdata.org/dataset/cyclone-wind-100-years-return-period
>
>
>
> here is my NCL code-
>
>
>
>    diri  = "./"
>
>   fili  = "VIENTO_MUNDO_TR100_INT1.grd"                      ; DSET
>
>   fName = diri+fili
>
>
>
>   nlat  = 424                               ; YDEF
>
>   mlon  = 1327                             ; XDEF
>
>
>
>                                          ; generate lat/lon
>
>   lon = fspan(-180.1357,179.9078,1327)
>
>   lon!0 = "lon"
>
>   lon at long_name = "longitude"
>
>   lon at units     = "degrees_east"
>
>
>
>
>
>   lat = fspan(-55.13566,59.90459,424)
>
>   lat!0 = "lat"
>
>   lat at long_name = "latitude"
>
>   lat at units     = "degrees_north"
>
>
>
>                                           ; create an array to contain data
>
>   UNDEF = -999.                           ; UNDEF
>
>   x     = new ( (/nlat,mlon/), float, UNDEF)
>
>
>
>   x!0   = "lat"
>
>   x!1   = "lon"
>
>
>
>   x&lat =  lat
>
>   x&lon =  lon
>
>
>
>   x at long_name = "100 year windspeed"         ; VARS
>
>   x at units     = "??"
>
>
>
> ;setfileoption("bin","ReadByteOrder","Native")       ; a033 default
>
> ;setfileoption("bin","ReadByteOrder","LittleEndian")
>
>   setfileoption("bin","ReadByteOrder","BigEndian")
>
>                                           ; read each record: store in x
>
>                           ; the ::-1 changes the latitude order
>
>      x = fbinrecread(fName,0, (/nlat,mlon/), "float")
>
>
>
>
>
>   printVarSummary(x)
>
>   print ("min(x)="+min(x))
>
>   print ("max(x)="+max(x))
>
>
>
> with regards
>
>
>
> *Debasish PaiMazumder, PhD |*Tel +1 215 255 6052 <%2B1%20215%20255%206371>
> | Cell +1 267 449 5226 <%2B1%20718%20913%206946> |*Debasish.Paimazumder at aig.com
> <Debasish.Paimazumder at aig.com>*
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200309/1e925679/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: VIENTO_MUNDO.ncl
Type: application/octet-stream
Size: 1781 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200309/1e925679/attachment.obj>


More information about the ncl-talk mailing list