[ncl-talk] reading grd file

Paimazumder, Debasish Debasish.Paimazumder at aig.com
Mon Mar 9 11:46:33 MDT 2020


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<tel:%2B1%20215%20255%206371> | Cell +1 267 449 5226<tel:%2B1%20718%20913%206946> |Debasish.Paimazumder at aig.com<mailto:Debasish.Paimazumder at aig.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200309/6d72c450/attachment.html>


More information about the ncl-talk mailing list