[ncl-talk] Warning: The 'lon2d' attribute must either be the same dimension

Mary Haley haley at ucar.edu
Thu Jan 5 17:21:40 MST 2017


Thanks for cleaning up the script.

I was able to get it to run and I see what the problem is.

You are subscripting snowh_rate with:

  snowh_rate_dom  = snowh_rate(y_start:y_end,x_start:x_end)

and then trying to attach coordinate arrays to it with:

  lat_dom = xlat2d(y_start:y_end,x_start:x_end)
  lon_dom = xlon2d(y_start:y_end,x_start:x_end)
  snowh_rate_dom!0 = "lat_dom"
  snowh_rate_dom!1 = "lon_dom"
  snowh_rate_dom at lat_dom = lat_dom
  snowh_rate_dom at lon_dom = lon_dom

This is not going to work, because snowh_rate_dom is still a curvilinear
grid (i.e. a grid defined by 2D lat / lon coordinates), so you still need
to do the "@lat2d"  and "@lon2d" attachments.

Furthermore, when when you do this:

  snowh_rate_dom  = snowh_rate(y_start:y_end,x_start:x_end)

the original lat2d and lon2d attributes from snowh_rate are copied over,
and you end up with a lat2d and lon2d that are the wrong size. That's why
you are getting these two errors:

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) 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.

You almost have the right idea.

First, when you subscript snowh_rate, make sure the lat2d and lon2d don't
get copied over by using the special (/ and /) syntax:

  snowh_rate_dom  = (/snowh_rate(y_start:y_end,x_start:x_end/))  ;
enclosing a variable with (/ and /) will strip all metadata

Now you need to attach new lat2d and lon2d to snowh_rate_dom that are
subscripted the same way.  You already have this with lat_dom and lon_dom,
so just use those:

snowh_rate at lat2d = lat_dom
snowh_rate at lon2d = lon_dom

Make sure you remove these lines:

  snowh_rate_dom!0 = "lat_dom"
  snowh_rate_dom!1 = "lon_dom"
  snowh_rate_dom at lat_dom = lat_dom
  snowh_rate_dom at lon_dom = lon_dom

--Mary






On Thu, Jan 5, 2017 at 10:26 AM, Barry Lynn <barry.h.lynn at gmail.com> wrote:

> Hi Mary:
>
> This reads the files that I previously attached.
>
> I left the wrf calls, but put them in a logical if statement.
>
> I did not remove the code that sets the label bars, makes nice maps.
>
> If I need to do this, please let me know.
>
> The code now gives these errors (below), but I think you can ignore them.
> (I am not sure how to manually add this information, for this "clean"
> version.
>
> It still gives the one about the dimensions.
>
> (Thanks.)
>
> 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' '
>
> On Thu, Jan 5, 2017 at 7:11 PM, Mary Haley <haley at ucar.edu> wrote:
>
>> Barry,
>>
>> Offline for a bit. I still can't run your script because it's assuming
>> that I have a WRF output file, but the "file_for_ncltalk.nc" file you
>> gave me is not a WRF output file.  I
>> ​t's very time-consuming for me to try to figure out how to change your
>> script to work with this file, so please, send me a *clean* script that
>> works with the files you've sent me so far.
>>
>> Thanks,
>>
>> --Mary
>>
>>>>
>> On Thu, Jan 5, 2017 at 9:58 AM, Barry Lynn <barry.h.lynn at gmail.com>
>> wrote:
>>
>>> Hello:
>>>
>>> I have attached the wrf_times.file.
>>>
>>> However, I added res at gsnAddCyclic = False
>>>
>>> and sres at gsnAddCyclic = False, but the error remains.
>>>
>>> The problem pertains not to the mapping of the terrain ("res"), but of
>>> the snowh_rate_dom variable.
>>>
>>> Since, I am plotting a subdomain of terrain by setting:
>>>
>>>   res at mpFillOn     = False
>>>   res at mpMaxLatF    = lat_end                  ; specify the plot domain
>>>   res at mpMinLatF    = lat_beg
>>>   res at mpMinLonF    = lon_beg                  ;
>>>   res at mpMaxLonF    = lon_end
>>>
>>> I need to excerpt snowh_rate_dom from snowh_rate.
>>>
>>> I do this as follows, and this is where the error message pertains to.
>>>
>>> (Note, if you try to run the program, you have to read in the uploaded
>>> nc file, not wrf_output, and set ntimes = 0.)
>>>
>>>  i_loc = 1
>>>   j_loc = 1
>>>   GET_IJ::get_ij(xlat2d,xlon2d,lat_beg,lon_beg,i_loc,j_loc,dim
>>> s2d(0),dims2d(1))
>>>   x_start = i_loc
>>>   y_start = j_loc
>>>
>>>   print("x_start = " + x_start)
>>>   print("y_start = " + y_start)
>>>   GET_IJ::get_ij(xlat2d,xlon2d,lat_end,lon_end,i_loc,j_loc,dim
>>> s2d(0),dims2d(1))
>>>   x_end = i_loc
>>>   y_end = j_loc
>>>   print("x_end = " + x_end)
>>>   print("y_end = " + y_end)
>>>   snowh_rate_dom  = snowh_rate(y_start:y_end,x_start:x_end)
>>>   printVarSummary(snowh_rate_dom)
>>>   printVarSummary(snowh_rate)
>>>
>>>   lat_dom = xlat2d(y_start:y_end,x_start:x_end)
>>>   lon_dom = xlon2d(y_start:y_end,x_start:x_end)
>>>   snowh_rate_dom!0 = "lat_dom"
>>>   snowh_rate_dom!1 = "lon_dom"
>>>   snowh_rate_dom at lat_dom = lat_dom
>>>   snowh_rate_dom at lon_dom = lon_dom
>>>
>>>
>>>
>>> On Thu, Jan 5, 2017 at 5:45 PM, Mary Haley <haley at ucar.edu> wrote:
>>>
>>>> Barry,
>>>>
>>>> I was unable to run the script because I was missing an ASCII file.
>>>>
>>>> I think the problem is that NCL is trying to add a longitude cyclic
>>>> point, and you don't want to do this for WRF data. What's happening is that
>>>> NCL is taking your 270 x 270 data array and turning it into a 270 x 271
>>>> array, but the lat2d and lon2d are untouched (because gsnAddCyclic doesn't
>>>> touch these), and hence you end up with two arrays of different sizes.
>>>>
>>>> Try setting:
>>>>
>>>>   res at gsnAddCyclic = False
>>>>
>>>> --Mary
>>>>
>>>>
>>>> On Thu, Jan 5, 2017 at 1:42 AM, Barry Lynn <barry.h.lynn at gmail.com>
>>>> wrote:
>>>>
>>>>> Hello:
>>>>>
>>>>> I thought that I have done what was indicated on this page, but I
>>>>> continue to get an error in dimensioning the second variable.  I am trying
>>>>> to plot a subset of the first variable (no problem), and then extract the
>>>>> same subset from the second variable. I've done it before, but
>>>>> it doesn't work here.
>>>>>
>>>>> I been at this about 4 or 5 hours, tried different things, including
>>>>> adapting the suggestions here:
>>>>>
>>>>> https://www.ncl.ucar.edu/Support/talk_archives/2012/2697.html
>>>>>
>>>>> I uploaded an extraction of the original WRF file, in case this is
>>>>> need.
>>>>>
>>>>> Thank you.
>>>>>
>>>>> ftp> put wrfsnow.ncl
>>>>> local: wrfsnow.ncl remote: wrfsnow.ncl
>>>>> 229 Entering Extended Passive Mode (|||49155|).
>>>>> 150 Ok to send data.
>>>>> 100% |********************************************************************|
>>>>>  7521        3.06 MiB/s    00:00 ETA
>>>>> 226 Transfer complete.
>>>>> 7521 bytes sent in 00:00 (11.93 KiB/s)
>>>>> ftp> put wrfsnow.out.file
>>>>> local: wrfsnow.out.file remote: wrfsnow.out.file
>>>>> 229 Entering Extended Passive Mode (|||49161|).
>>>>> 150 Ok to send data.
>>>>> 100% |********************************************************************|
>>>>>  2566        8.21 MiB/s    00:00 ETA
>>>>> 226 Transfer complete.
>>>>> 2566 bytes sent in 00:00 (6.15 KiB/s)
>>>>> ftp> put file_for_ncltalk.nc
>>>>> local: file_for_ncltalk.nc remote: file_for_ncltalk.nc
>>>>> 229 Entering Extended Passive Mode (|||49179|).
>>>>> 150 Ok to send data.
>>>>> 100% |********************************************************************|
>>>>>  2279 KiB  278.71 KiB/s    00:00 ETA
>>>>> 226 Transfer complete.
>>>>> 2333728 bytes sent in 00:08 (260.45 KiB/s)
>>>>>
>>>>>
>>>>> --
>>>>> Barry H. Lynn, Ph.D
>>>>> Senior Lecturer,
>>>>> The Institute of the Earth Science,
>>>>> The Hebrew University of Jerusalem,
>>>>> Givat Ram, Jerusalem 91904, Israel
>>>>> Tel: 972 547 231 170
>>>>> Fax: (972)-25662581
>>>>>
>>>>> C.E.O, Weather It Is, LTD
>>>>> Weather and Climate Focus
>>>>> http://weather-it-is.com
>>>>> Jerusalem, Israel
>>>>> Local: 02 930 9525
>>>>> Cell: 054 7 231 170
>>>>> Int-IS: x972 2 930 9525
>>>>> US 914 432 3108 <(914)%20432-3108>
>>>>>
>>>>> _______________________________________________
>>>>> ncl-talk mailing list
>>>>> ncl-talk at ucar.edu
>>>>> List instructions, subscriber options, unsubscribe:
>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> Barry H. Lynn, Ph.D
>>> Senior Lecturer,
>>> The Institute of the Earth Science,
>>> The Hebrew University of Jerusalem,
>>> Givat Ram, Jerusalem 91904, Israel
>>> Tel: 972 547 231 170
>>> Fax: (972)-25662581
>>>
>>> C.E.O, Weather It Is, LTD
>>> Weather and Climate Focus
>>> http://weather-it-is.com
>>> Jerusalem, Israel
>>> Local: 02 930 9525
>>> Cell: 054 7 231 170
>>> Int-IS: x972 2 930 9525
>>> US 914 432 3108 <(914)%20432-3108>
>>>
>>
>>
>
>
> --
> Barry H. Lynn, Ph.D
> Senior Lecturer,
> The Institute of the Earth Science,
> The Hebrew University of Jerusalem,
> Givat Ram, Jerusalem 91904, Israel
> Tel: 972 547 231 170
> Fax: (972)-25662581
>
> C.E.O, Weather It Is, LTD
> Weather and Climate Focus
> http://weather-it-is.com
> Jerusalem, Israel
> Local: 02 930 9525
> Cell: 054 7 231 170
> Int-IS: x972 2 930 9525
> US 914 432 3108 <(914)%20432-3108>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170105/f612d11d/attachment.html 


More information about the ncl-talk mailing list