<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>Dennis, Dave et al</div>
<div><br>
</div>
<div>Out of interest I went back and changed one of my older scripts that uses the NSIDC EASE grid, setting the sfXArray and sfYArray as suggested, I got the following error(s):</div>
<div><br>
</div>
<div>warning:ScalarFieldSetValues: 2d coordinate array sfXArray has an incorrect dimension size: defaulting sfXArray</div>
<div>warning:ScalarFieldSetValues: 2d coordinate array sfYArray has an incorrect dimension size: defaulting sfYArray</div>
<div><br>
</div>
<div>(Obviously this didn't print anything, since the 'default ' arrays don't match the data array).</div>
<div><br>
</div>
<div>It plots just fine using the inefficient attribute method (i.e. setting x@lat2d, x@lon2d.</div>
<div><br>
</div>
<div>I had a look at the description for sfXArray, sfYArray but can't find any reason why the dimensions are invalid.</div>
<div><br>
</div>
<div>Will </div>
<div><br>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>><br>
<span style="font-weight:bold">Date: </span>Saturday, 29 August 2015 8:34 AM<br>
<span style="font-weight:bold">To: </span>Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov">dave.allured@noaa.gov</a>><br>
<span style="font-weight:bold">Cc: </span>"<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>" <<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [ncl-talk] plotting model output where x/y are not lat/lon<br>
</div>
<div><br>
</div>
<div>
<div dir="auto">
<div>Yes. So much to do ... So little time. :-(<br>
<br>
Sent from my iPhone</div>
<div><br>
On Aug 28, 2015, at 4:15 PM, Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov">dave.allured@noaa.gov</a>> wrote:<br>
<br>
</div>
<blockquote type="cite">
<div>
<div dir="ltr">Dennis,
<div><br>
</div>
<div>Thank you for the information about preferred resources <span style="font-size:14px">sfXArray and </span><span style="font-size:14px">sfYArray for 2-D coordinates, and the reason why this is optimal. I learned something new here.</span></div>
<div><span style="font-size:14px"><br>
</span></div>
<div><span style="font-size:14px">Several NCL examples and at least one documentation page are advocating the less optimal method using lat2d and lon2d attributes. Perhaps these examples and pages could eventually be updated to use </span><span style="font-size:14px">sfXArray
and </span><span style="font-size:14px">sfYArray instead.</span></div>
<div><span style="font-size:14px"><br>
</span></div>
<div><span style="font-size:14px">--Dave</span></div>
<div><br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Aug 28, 2015 at 3:54 PM, Dennis Shea <span dir="ltr">
<<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Will's suggestion is correct.<br>
<br>
-----<br>
<br>
FYI: The ***only*** time you should assign the reserved attributes:<br>
@lat2d, @lon2d is for plotting.<br>
<br>
In fact, the NCL-team would prefer that people use the following<br>
rather than the reserved attributes.<br>
<br>
res@sfXArraya = lon2d<br>
res@sfYArray = lat2d<br>
res@trGridType = "TriangularMesh"<br>
<br>
---<br>
<br>
Each variable having an associated @lat2d, @lon2d takes up memory.<br>
If 5 variables a, a@lat2d, a@lon2d, ... b, c, d, e then each will<br>
require the necessary memory.<br>
Firther, if you write to netCDF via<br>
<br>
fnc->A = a<br>
fnc->B = b<br>
fnc->C = c<br>
fnc->D = d<br>
fnc->E = e<br>
<br>
Then the lat2d/lon2d arrays will be written 5 times (one for each variable).<br>
<br>
fnc->LAT2D = lat2d<br>
fnc->LON2D = lon2d<br>
<br>
Will write each variable only once!<br>
<br>
Cheers<br>
<br>
<br>
On Fri, Aug 28, 2015 at 3:38 PM, Will Hobbs <<a href="mailto:Will.Hobbs@utas.edu.au" target="_blank">Will.Hobbs@utas.edu.au</a>> wrote:<br>
> Mira<br>
><br>
> To keep all the attributes from 'sf'....<br>
><br>
>> sf_total = sf(0,:,:) ;sf_total is now a 2-da array with all the<br>
>>attributes and rightmost dimensions of sf<br>
>> sf_total = dim_sum_n(sf,0)<br>
><br>
> Will<br>
><br>
><br>
> On 29/08/15 5:26 AM, "<a href="mailto:mberdahl@envsci.rutgers.edu" target="_blank">mberdahl@envsci.rutgers.edu</a>"<br>
> <<a href="mailto:mberdahl@envsci.rutgers.edu" target="_blank">mberdahl@envsci.rutgers.edu</a>> wrote:<br>
><br>
>>Excellent, this worked! Thank you!<br>
>>I just have a quick follow-up question. Once I assign the lat and lon to<br>
>>my variables (for example: sf@lon2d = lon2d, sf@lat2d = lat2d), and then<br>
>>I would like to do a calculation with sf (eg. sf_total = dim_sum_n(sf,0)),<br>
>>it seems I have to assign the the new variable the lat and lon again. Is<br>
>>there a way to keep the lat and lon following through the calculations<br>
>>without always reassigning them?<br>
>>I hope that makes sense.<br>
>>Thanks,<br>
>>Mira<br>
>><br>
>><br>
>>> Here is more information about dat with 2-D coordinates. I was typing<br>
>>> this<br>
>>> up when I saw Will's reply. Some of the other examples indicate<br>
>>> that trGridTrype may not be needed with some data sets.<br>
>>><br>
>>> Please see section #2 on this documentation page, for a basic<br>
>>>description.<br>
>>> Notice the several different working examples:<br>
>>> <a href="https://www.ncl.ucar.edu/Document/Graphics/overlays_on_map.shtml" rel="noreferrer" target="_blank">
https://www.ncl.ucar.edu/Document/Graphics/overlays_on_map.shtml</a><br>
>>><br>
>>> (Please ignore the link "2D vertical coordinates", that is not about<br>
>>> geographic surface maps, and can be confusing.)<br>
>>><br>
>>> The simplest example for making map plots with 2-D coordinates is<br>
>>>example<br>
>>> 3<br>
>>> on this page:<br>
>>> <a href="https://www.ncl.ucar.edu/Applications/ice.shtml" rel="noreferrer" target="_blank">
https://www.ncl.ucar.edu/Applications/ice.shtml</a><br>
>>><br>
>>> I also like NARR example 4 because it shows how the 2-D coordinate<br>
>>>method<br>
>>> can be used with different map projections:<br>
>>> <a href="http://www.ncl.ucar.edu/Applications/narr.shtml" rel="noreferrer" target="_blank">
http://www.ncl.ucar.edu/Applications/narr.shtml</a><br>
>>><br>
>>> --Dave<br>
>>><br>
>>><br>
>>> On Thu, Aug 27, 2015 at 9:35 PM, Will Hobbs <<a href="mailto:Will.Hobbs@utas.edu.au" target="_blank">Will.Hobbs@utas.edu.au</a>><br>
>>> wrote:<br>
>>><br>
>>>> Mira<br>
>>>><br>
>>>> It looks like you have 2-d lat and lon arrays associated with your<br>
>>>>data,<br>
>>>> as is often the case with models (especially ocean models).<br>
>>>><br>
>>>> This can be plotted by NCL without regridding, see the examples here:<br>
>>>> <a href="http://www.ncl.ucar.edu/Applications/ease.shtml" rel="noreferrer" target="_blank">
http://www.ncl.ucar.edu/Applications/ease.shtml</a><br>
>>>> Although you are not using the EASE grid, the principal is exactly the<br>
>>>> same:<br>
>>>><br>
>>>> 1. Set your map plot grid type resource<br>
>>>> >res@trGridTrype = "TriangularMesh"<br>
>>>><br>
>>>> 2. Set the lat and lon arrays as attributes of the array you are<br>
>>>> plotting,<br>
>>>> so if your array is 'x'<br>
>>>> > x@lat2d = LAT<br>
>>>> > x@lon2d = LON<br>
>>>><br>
>>>> The just use one of the gsn_csm contour map plotting functions as<br>
>>>> normal.<br>
>>>><br>
>>>> I hope that's clear.<br>
>>>><br>
>>>> Will<br>
>>>><br>
>>>><br>
>>>> On 28/08/15 1:27 PM, "Yuqiang Zhang" <<a href="mailto:yuqiangzhang.thu@gmail.com" target="_blank">yuqiangzhang.thu@gmail.com</a>><br>
>>>>wrote:<br>
>>>><br>
>>>> >Hi Mira,<br>
>>>> ><br>
>>>> >Check the link here<br>
>>>> ><a href="http://www.ncl.ucar.edu/FAQ/" rel="noreferrer" target="_blank">http://www.ncl.ucar.edu/FAQ/</a><br>
>>>> >For Q 27:<br>
>>>> ><br>
>>>> >When I call one of the gsn_csm_xxxx_map plotting scripts, I get an<br>
>>>> error<br>
>>>> >message about a units attribute not being correct.<br>
>>>> >If you are using one of the gsn_csm_xxx_map functions to overlay data<br>
>>>> on a<br>
>>>> >map, and seeing one or both of the following error messages:<br>
>>>> ><br>
>>>> > (0) is_valid_lat_ycoord: Warning: The units attribute of<br>
>>>> > the Y coordinate array is not set to one of the allowable<br>
>>>> > units values (i.e. 'degrees_north'). Your latitude labels<br>
>>>> > may not be correct.<br>
>>>> ><br>
>>>> > (0) is_valid_lat_xcoord: Warning: The units attribute of<br>
>>>> > the X coordinate array is not set to one of the allowable<br>
>>>> > units values (i.e. 'degrees_east'). Your longitude labels<br>
>>>> > may not be correct.<br>
>>>> >then this means that your data contains coordinate arrays, but the<br>
>>>> >coordinate arrays either don't have the necessary "units" attribute,<br>
>>>>or<br>
>>>> >it's<br>
>>>> >not set to one of the allowable values ("degrees_east" for longitude<br>
>>>> >values<br>
>>>> >and "degrees_north" for latitude values).<br>
>>>> >If your coordinate arrays are indeed degrees east and degrees north,<br>
>>>> then<br>
>>>> >you can set the units attribute as follows (this code snippet assumes<br>
>>>> your<br>
>>>> >data array is called "data" and that the coordinate arrays are called<br>
>>>> >"lat"<br>
>>>> >and "lon"):<br>
>>>> ><br>
>>>> > data&lat@units = "degrees_north"<br>
>>>> > data&lon@units = "degrees_east"<br>
>>>> ><br>
>>>> >Regards,<br>
>>>> >Yuqiang<br>
>>>> ><br>
>>>> >-----Original Message-----<br>
>>>> >From: <a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.edu</a> [mailto:<a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.edu</a>] On<br>
>>>> >Behalf<br>
>>>> >Of <a href="mailto:mberdahl@envsci.rutgers.edu" target="_blank">mberdahl@envsci.rutgers.edu</a><br>
>>>> >Sent: Thursday, August 27, 2015 10:21 PM<br>
>>>> >To: <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
>>>> >Subject: [ncl-talk] plotting model output where x/y are not lat/lon<br>
>>>> ><br>
>>>> >Hi all,<br>
>>>> ><br>
>>>> >I'm trying to make a simple plot of cumulative snowfall with data from<br>
>>>> a<br>
>>>> >model I did not run. When I try to make a simple plot, I receive the<br>
>>>> >following error:<br>
>>>> ><br>
>>>> >(0) check_for_y_lat_coord: Warning: Data either does not contain a<br>
>>>> >valid latitude coordinate array or doesn't contain one at all.<br>
>>>> >(0) A valid latitude coordinate array should have a 'units'<br>
>>>> attribute<br>
>>>> >equal to one of the following values:<br>
>>>> >(0) 'degrees_north' 'degrees-north' 'degree_north' 'degrees<br>
>>>> north'<br>
>>>> >'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg<br>
>>>>north'<br>
>>>> >(0) check_for_lon_coord: Warning: Data either does not contain a<br>
>>>> valid<br>
>>>> >longitude coordinate array or doesn't contain one at all.<br>
>>>> >(0) A valid longitude coordinate array should have a 'units'<br>
>>>> attribute<br>
>>>> >equal to one of the following values:<br>
>>>> >(0) 'degrees_east' 'degrees-east' 'degree_east' 'degrees east'<br>
>>>> >'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'<br>
>>>> ><br>
>>>> ><br>
>>>><br>
>>>>>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>
>>>> ><br>
>>>> >When I dump the file it looks like this:<br>
>>>> ><br>
>>>> >netcdf ICE.1983.01-12.f77 {<br>
>>>> >dimensions:<br>
>>>> > TIME = UNLIMITED ; // (365 currently)<br>
>>>> > X10_69 = 60 ;<br>
>>>> > Y18_127 = 110 ;<br>
>>>> > SECTOR = 2 ;<br>
>>>> > SECTOR1_1 = 1 ;<br>
>>>> > ATMLAY14_23 = 10 ;<br>
>>>> > bnds = 2 ;<br>
>>>> > ATMLAY23_23 = 1 ;<br>
>>>> > ATM6H3_3 = 1 ;<br>
>>>> > OUTLAY = 20 ;<br>
>>>> > OUTLAY1_1 = 1 ;<br>
>>>> ><br>
>>>> >variables:<br>
>>>> > double TIME(TIME) ;<br>
>>>> > TIME:units = "HOURS since 1901-01-15 00:00:00" ;<br>
>>>> > TIME:long_name = "time" ;<br>
>>>> > TIME:time_origin = "15-JAN-1901 00:00:00" ;<br>
>>>> > TIME:axis = "T" ;<br>
>>>> > float DATE(TIME) ;<br>
>>>> > DATE:units = "YYYYMMDDHH" ;<br>
>>>> > DATE:long_name = "Date(YYYY MM DD HH)" ;<br>
>>>> > DATE:history = "From ICE.f77.1983.01.01-15" ;<br>
>>>> > double X10_69(X10_69) ;<br>
>>>> > X10_69:units = "km" ;<br>
>>>> > X10_69:long_name = "x" ;<br>
>>>> > X10_69:point_spacing = "even" ;<br>
>>>> > X10_69:axis = "X" ;<br>
>>>> ><br>
>>>> > double Y18_127(Y18_127) ;<br>
>>>> > Y18_127:units = "km" ;<br>
>>>> > Y18_127:long_name = "y" ;<br>
>>>> > Y18_127:point_spacing = "even" ;<br>
>>>> > Y18_127:axis = "Y" ;<br>
>>>> > float LON(Y18_127, X10_69) ;<br>
>>>> > LON:units = "degrees" ;<br>
>>>> > LON:long_name = "Longitude" ;<br>
>>>> > LON:history = "From ICE.f77.1983.01.01-15" ;<br>
>>>> > float LAT(Y18_127, X10_69) ;<br>
>>>> > LAT:units = "degrees" ;<br>
>>>> > LAT:long_name = "Latitude" ;<br>
>>>> > LAT:history = "From ICE.f77.1983.01.01-15" ;<br>
>>>> ><br>
>>>> >Clearly there are lats and lons associated with the x and y spacing,<br>
>>>> but<br>
>>>> >I'm<br>
>>>> >not sure how to tell NCL how to use those. Does anyone have advice on<br>
>>>> >this?<br>
>>>> ><br>
>>>> >Thanks in advance,<br>
>>>> >Mira<br>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
<blockquote type="cite">
<div><span>_______________________________________________</span><br>
<span>ncl-talk mailing list</span><br>
<span><a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a></span><br>
<span>List instructions, subscriber options, unsubscribe:</span><br>
<span><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></span><br>
</div>
</blockquote>
</div>
</div>
</span>
<p style="font-size:10pt; line-height:10pt; calibri"><br>
<br>
University of Tasmania Electronic Communications Policy (December, 2014). <br>
This email is confidential, and is for the intended recipient only. Access, disclosure, copying, distribution, or reliance on any of it by anyone outside the intended recipient organisation is prohibited and may be a criminal offence. Please delete if obtained
in error and email confirmation to the sender. The views expressed in this email are not necessarily the views of the University of Tasmania, unless clearly intended otherwise.
</p>
</body>
</html>