[ncl-talk] change dimensions to lat/lon

Rick Brownrigg brownrig at ucar.edu
Tue May 2 08:23:03 MDT 2017


Hi Jian,

This is from my colleague Dennis Shea;  it presumes you need to generate
the actual lat/lon values:

Re: the hdf5 question ... a (720,1440) is a 'classic' 0.25 degree grid.
This is offset from the poles an dateline by 0.125. The grisd point is the
cented of the local grid.

nlat = 720
lat  = *latGlobeFo*(nlat, "lat", "latitude", "degrees_north")
lat  = lat(::-1)   ; lat: [89.875..-89.875]

print(lat)

mlon = 1440
lon  = *lonGlobeFo*(mlon, "lon", "longitude", "degrees_east")
lon  = (/ lon - 180. /)  ; subtract 180 from all values
lon&lon = lon            ; update coordinate*print*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/print.shtml>(lon)
              ; lon: [-179.875..179.875]


   x    = f->pixTot
   x!0 = "lat"
   x!1 = "lon"
   x at _FillValue = x at CodeMissingValue
   fout->pixTot = x



On Tue, May 2, 2017 at 7:59 AM, Su, Jian (GSFC-610.2)[ADNET SYSTEMS INC] <
jian.su at nasa.gov> wrote:

> Thank you Rick,
>
>
>
> Filedimdef successfully added lat/lon, but how can we remove DIM_001/
> DIM_002 and assign lat/lon to the variable pixTot?
>
>
>
>
>
>    file global attributes:
>
>    dimensions:
>
>       DIM_001 = 1440
>
>       DIM_002 = 720
>
>       lat = 1440
>
>       lon = 720
>
>    variables:
>
>       integer pixTot ( DIM_001, DIM_002 )
>
>          CodeMissingValue :       -9999
>
>          DimensionNames :         nlon,nlat
>
>
>
>
>
>
>
> *From: *Rick Brownrigg <brownrig at ucar.edu>
> *Date: *Monday, May 1, 2017 at 4:15 PM
> *To: *"Su, Jian (GSFC-610.2)[ADNET SYSTEMS INC]" <jian.su at nasa.gov>
> *Cc: *"ncl-talk at ucar.edu" <ncl-talk at ucar.edu>
> *Subject: *Re: [ncl-talk] change dimensions to lat/lon
>
>
>
> Hi Jay,
>
> There are probably several ways to do this. One that occurs to me is to
> create the dimensions in the new file with the "filedimdef" procedure:
>
>     http://ncl.ucar.edu/Document/Functions/Built-in/filedimdef.shtml
>
> So in your case, that might look something like:
>
>     filedimdef(f,(/"lat","lon"/),(/1440, 720/), (/False,False/))
>
> You can add the other information directly as global attributes of the
> file:
>
>     f->LatitudeResolution=0.25
>
>     f->LongitudeResolution=0.25
>
>     ...etc...
>
> Hope that helps...
>
> Rick
>
>
>
> On Mon, May 1, 2017 at 12:28 PM, Su, Jian (GSFC-610.2)[ADNET SYSTEMS INC] <
> jian.su at nasa.gov> wrote:
>
> Hello,
>
>
>
> I am using ncl to convert HDF5 files to netCDF, and one of them looks like
> this:
>
>
>
> Variable: f
>
> Type: file
>
> filename:         out
>
> path:    out.nc4
>
>    file global attributes:
>
>    dimensions:
>
>       DIM_001 = 1440
>
>       DIM_002 = 720
>
>    variables:
>
>       integer pixTot ( DIM_001, DIM_002 )
>
>          CodeMissingValue :       -9999
>
>          DimensionNames :         nlon,nlat
>
>
>
>
>
> How can I change DIM_001 and DIM_002 to lat/lon, and add the grid
> information eg,
>
>
>
> LatitudeResolution=0.25;
>
> LongitudeResolution=0.25;
>
> NorthBoundingCoordinate=90;
>
> SouthBoundingCoordinate=-90;
>
> EastBoundingCoordinate=180;
>
> WestBoundingCoordinate=-180;
>
>
>
> Thanks,
>
> Jay
>
>
>
>
>
>
> _______________________________________________
> 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/20170502/5ffdf801/attachment.html 


More information about the ncl-talk mailing list