[ncl-talk] change dimensions to lat/lon

Mary Haley haley at ucar.edu
Sun May 7 08:57:19 MDT 2017


I think I understand, but you need to elaborate on what the issue was on
the NCL end.

You stated, " It’s 2D but not Geo2D if you open it with eg, panoply."
​  By this do you mean you were having trouble plotting it with NCL? If you
tried plotting it with NCL and it wasn't right, it would help if you
include the script, the image, and the error message if any.

--Mary
​


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

> Thank you Mary,
>
>
>
> An easy way to tell if it’s a Geo2D is, to open the file with panoply and
> plot a variable with Geo2D, you will see the global grid as well.
> Otherwise, just a rectangle region.
>
>
>
> *From: *Mary Haley <haley at ucar.edu>
> *Date: *Thursday, May 4, 2017 at 7:05 PM
> *To: *"Su, Jian (GSFC-610.2)[ADNET SYSTEMS INC]" <jian.su at nasa.gov>
> *Cc: *Rick Brownrigg <brownrig at ucar.edu>, "ncl-talk at ucar.edu" <
> ncl-talk at ucar.edu>
>
> *Subject: *Re: [ncl-talk] change dimensions to lat/lon
>
>
>
> Jian,
>
>
>
> The first issue is that you cannot assign a missing value using a
> different type. For example, the following will produce the same error,
> because "x" is an integer array, and you are trying to assign a floating
> point _FillValue:
>
>
>
>   x = (/1,2,3,4,5,-999/)    ; x is an array of integers
>
>   x at _FillValue = -999.      ; -999. is a float, which is a "higher" type than an integer
>
>
> The fix in your case would be to use "totype":
>
>   x at _FillValue = totype(x at CodeMissingValue,typeof(x))
>
>
>
> You have to be careful with this kind of assignment, however, because you
> could lose precision when going from a higher type to a lower type.
>
>
>
> As for the second question, I'm not sure what you mean by "Geo2D".
>
>
>
> --Mary
>
>
>
>
>
> On Tue, May 2, 2017 at 8:44 AM, Su, Jian (GSFC-610.2)[ADNET SYSTEMS INC] <
> jian.su at nasa.gov> wrote:
>
> Thank you again Rick, and thank you Dennis.
>
>
>
> There are still two issues:
>
> 1.      x at _FillValue = x at CodeMissingValue
>
> fatal:Type Mismatch: The type of missing value could not be converted to
> type of variable (x)
>
>
>
> 2.      It’s 2D but not Geo2D if you open it with eg, panoply.
>
>
>
> *From: *Rick Brownrigg <brownrig at ucar.edu>
> *Date: *Tuesday, May 2, 2017 at 10:23 AM
>
>
> *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 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
>
>
>
>
>
>
> _______________________________________________
> 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/20170507/17e43cab/attachment.html 


More information about the ncl-talk mailing list