<div dir="ltr"><div class="gmail_default" style="font-family:garamond,"times new roman",serif">Dear NCL'ers, </div><div class="gmail_default" style="font-family:garamond,"times new roman",serif">I have a question on dealing with the 2D lat and long variables from WRF output. For example, in my code below, I am having trouble using the lat long information to either use them as coordinate variables or to be used as inputs to the horizontal gradient function. What is the best way to create or extract 1D lat and long information so that I can use them here? </div><div class="gmail_default" style="font-family:garamond,"times new roman",serif"><br></div><div class="gmail_default" style="font-family:garamond,"times new roman",serif">Thank you, </div><div class="gmail_default" style="font-family:garamond,"times new roman",serif">Prashanth </div><div class="gmail_default" style="font-family:garamond,"times new roman",serif"><br></div>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">begin</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0);min-height:22px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">a = addfile("wrfout_d04_2005-07-29_12:06:00","r")</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0);min-height:22px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"> = wrf_user_getvar(a,"</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">",-1) ; Cloud top temperatures in degree Celsius</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">lat = wrf_user_getvar(a,"XLAT",-1)</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">lon = wrf_user_getvar(a,"XLONG",-1)</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0);min-height:22px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">;Original Dimensions and sizes: [Time | 10] x [south_north | 480] x [west_east | 480]</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0);min-height:22px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">; Take the horizontal gradient</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span></span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">LatLon<span class="gmail-Apple-converted-space"> </span>= grad_latlon_cfd (</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">, lat, lon, False, False)</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0);min-height:22px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span></span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">_grad_lat<span class="gmail-Apple-converted-space"> </span>= gradLatLon[0]<span class="gmail-Apple-converted-space"> </span>; Extract Individual gradients in latitudinal direction</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span></span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">_grad_lon<span class="gmail-Apple-converted-space"> </span>= gradLatLon[1]<span class="gmail-Apple-converted-space"> </span>; Gradient in longitudinal directional</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0);min-height:22px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>delete(</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">LatLon)</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0);min-height:22px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>if(all(ismissing(</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">_grad_lat))) then</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>print("</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">_grad_lat contains all missing values, cannot continue.")</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>return</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>end if</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0);min-height:22px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>if(all(ismissing(</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">_grad_lon))) then</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>print("</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">_grad_lon contains all missing values, cannot continue.")</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>return</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>end if</span></p>
<div class="gmail_default" style="font-family:garamond,"times new roman",serif"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0);font-family:Courier;font-size:18px">end</span></div><div class="gmail_default" style="font-family:garamond,"times new roman",serif"><br></div><div class="gmail_default" style="font-family:garamond,"times new roman",serif"><br></div><div class="gmail_default" style="font-family:garamond,"times new roman",serif">Output: </div><div class="gmail_default" style="font-family:garamond,"times new roman",serif"><br></div><div class="gmail_default" style="font-family:garamond,"times new roman",serif">I can't prescribe lat and lon as coordinate variables since they are 2D. </div><div class="gmail_default" style="font-family:garamond,"times new roman",serif">
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">$ ncl -n -Q cloud_top.ncl<span class="gmail-Apple-converted-space"> </span></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">fatal:Coordinate variables must have one dimension only</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">fatal:No coordinate variable exists for dimension (lat) in variable (ctt)</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">fatal:["Execute.c":8637]:Execute: Error occurred at or near line 12 in file cloud_top.ncl</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><br></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">or use them as inputs to the gradient function: <br><br>
</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">$ ncl -n -Q cloud_top.ncl<span class="gmail-Apple-converted-space"> </span></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">fatal:Number of dimensions in parameter (1) of (grad_latlon_cfd) is (3), (1) dimensions were expected<span class="gmail-Apple-converted-space"> </span></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">fatal:["Execute.c":8637]:Execute: Error occurred at or near line 12 in file cloud_top.ncl</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">
</span></p><p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0);min-height:22px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><br></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:18px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><br></span></p></div></div>