[ncl-talk] unable to plot simple netCDF file

Diana Stovern - NOAA Affiliate diana.stovern at noaa.gov
Mon Feb 24 16:01:05 MST 2020


Hello everyone,

I'm running into a problem that I'm hoping someone here can help me out
with.

I attached the ncl script I'm running but the netCDF file is too big, so
I'll try my best to explain the problem and maybe someone can offer advice
without having to run the script.

I'm working with netCDF grids that were originally converted from a
grib2 file.  The grib2 file contains a single grid of rainfall values
(units are in inches) over the continental United States.  The grid is on a
polar stereographic projection where the lat and lon dimensions are 2D.
The dimensions for lat and lon are both (881,1121).  Hence, I had to define
var at lat2d and var at lon2d in order for the rainfall data to plot correctly.
When the file was converted to netCDF, somehow the lat2d and lon2d
variables each became defined as an array of 987601 elements.  Because
lat2d and lon2d are now defined as a 1D array in the netCDF file, I get the
following error from lines 29/30 of the attached NCL code where lat2d and
lon2d are defined:

*fatal:Dimensions of attribute and right-hand side of assignment do not
match*

If I remove/comment 29 and 30, I get:








*(0)     is_valid_latlon2d_attr: Warning: The 'lat2d' attribute must either
be the same dimension sizes as the data, or one element larger in both
directions.  Your data will most likely not be overlaid on the map
correctly.(0)     check_for_y_lat_coord: Warning: Data either does not
contain a valid latitude coordinate array or doesn't contain one at all.(0)
    A valid latitude coordinate array should have a 'units' attribute equal
to one of the following values:(0)         'degrees_north' 'degrees-north'
'degree_north' 'degrees north' 'degrees_N' 'Degrees_north' 'degree_N'
'degreeN' 'degreesN' 'deg north'(0)     is_valid_latlon2d_attr: Warning:
The 'lon2d' attribute must either be the same dimension sizes as the data,
or one element larger in both directions.  Your data will most likely not
be overlaid on the map correctly.(0)     check_for_lon_coord: Warning: Data
either does not contain a valid longitude coordinate array or doesn't
contain one at all.(0)     A valid longitude coordinate array should have a
'units' attribute equal to one of the following values:(0)
'degrees_east' 'degrees-east' 'degree_east' 'degrees east' 'degrees_E'
'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'*


What fix should I apply to deal with the fact that lat2d and lon2d are
defined as 1D arrays in my netCDF file?  I think that if I can redefine
lat2d and lon2d to turn them from a 1D array of 987601 elements back to 2D
array of (881,1121) elements that it should fix the problem, but I don't
know how to do that.

Or is there another fix that will at least get the data to plot?  Right
now, this netCDF file just does not want to plot no matter what I do.

Thanks for your help!  Any insight is greatly appreciated!

- Diana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200224/35a8308a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plot_grid_test.ncl
Type: application/octet-stream
Size: 2636 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200224/35a8308a/attachment.obj>


More information about the ncl-talk mailing list