[ncl-talk] unable to plot simple netCDF file

Dennis Shea shea at ucar.edu
Mon Feb 24 17:58:16 MST 2020


I agree with DaveA. Use the original GRIB2 file. NCL makes it look like a
variable on a netCDF file.

%> *ncl_filedump*
<https://www.ncl.ucar.edu/Document/Tools/ncl_filedump.shtml>
new_100y_6h.grib2  |  less

*ncl_filedump* tells you how NCL 'sees' the file's contents.
*ncl_filedump* has many options. For a single time step file, the default
is to not show the time dimension.
For example, you can force a time dimension via

%> *ncl_filedump*
<https://www.ncl.ucar.edu/Document/Tools/ncl_filedump.shtml>
new_100y_6h.grib2  -itime |  less

===
>From within a script, options may be ste via:  *setfileoption*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/setfileoption.shtml>

*setfileoption*("grb","SingleElementDimensions","Initial_time") ;
initial_time0_hours
fgrb = addfile("new_100y_6h.grib2","r")


On Mon, Feb 24, 2020 at 4:48 PM Dave Allured - NOAA Affiliate via ncl-talk <
ncl-talk at ucar.edu> wrote:

> It would be better to just read the original grib2 file directly with NCL,
> as long as your NCL version is recent enough to support that particular
> polar stereographic grid.  If that works, then NCL should provide you with
> the proper 2-D coordinate arrays.
>
>
> On Mon, Feb 24, 2020 at 4:01 PM Diana Stovern - NOAA Affiliate via
> ncl-talk <ncl-talk at ucar.edu> wrote:
>
>> 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
>>
> _______________________________________________
> 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/20200224/bce0194b/attachment.html>


More information about the ncl-talk mailing list