<div dir="ltr"><div>Hi,</div><div><br></div><div>I am not expert at this, but based upon the docs for the function_latlon_cfd, it looks like it requires a rectilinear grid, which would imply you'll need to regrid your curvilinear WRF grid. NCL has numerous functions for doing this (I can't advise which one you should use):</div><div><br></div><div>   <a href="http://ncl.ucar.edu/Applications/regrid.shtml">http://ncl.ucar.edu/Applications/regrid.shtml</a><br></div><div><br></div><div>I also note in the second warning you provided, its complaining about 3 dimensions in parameter 1 (i.e., the lat variable) -- Is there a time dimension on that variable as well as X/Y?</div><div><br></div><div>Hope that helps...</div><div>Rick</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 4, 2019 at 1:25 PM Prashanth Bhalachandran via ncl-talk <<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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 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 style="font-variant-ligatures:no-common-ligatures">begin</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p 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 style="font-variant-ligatures:no-common-ligatures">a = addfile("wrfout_d04_2005-07-29_12:06:00","r")</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p 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 style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span style="font-variant-ligatures:no-common-ligatures"> = wrf_user_getvar(a,"</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span style="font-variant-ligatures:no-common-ligatures">",-1) ; Cloud top temperatures in degree Celsius</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures">lat = wrf_user_getvar(a,"XLAT",-1)</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures">lon = wrf_user_getvar(a,"XLONG",-1)</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p 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 style="font-variant-ligatures:no-common-ligatures">;Original Dimensions and sizes: [Time | 10] x [south_north | 480] x [west_east | 480]</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p 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 style="font-variant-ligatures:no-common-ligatures">; Take the horizontal gradient</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"><span>  </span></span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span style="font-variant-ligatures:no-common-ligatures">LatLon<span>  </span>= grad_latlon_cfd (</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span style="font-variant-ligatures:no-common-ligatures">, lat, lon, False, False)</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"><span>  </span></span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span style="font-variant-ligatures:no-common-ligatures">_grad_lat<span>  </span>= gradLatLon[0]<span>    </span>; Extract Individual gradients in latitudinal direction</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"><span>  </span></span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span style="font-variant-ligatures:no-common-ligatures">_grad_lon<span>  </span>= gradLatLon[1]<span>    </span>; Gradient in longitudinal directional</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"><span>  </span>delete(</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span style="font-variant-ligatures:no-common-ligatures">LatLon)</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"><span>   </span>if(all(ismissing(</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span style="font-variant-ligatures:no-common-ligatures">_grad_lat))) then</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"><span>    </span>print("</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span style="font-variant-ligatures:no-common-ligatures">_grad_lat contains all missing values, cannot continue.")</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"><span>    </span>return</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"><span>  </span>end if</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"><span>    </span>if(all(ismissing(</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span style="font-variant-ligatures:no-common-ligatures">_grad_lon))) then</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"><span>    </span>print("</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">ctt</span><span style="font-variant-ligatures:no-common-ligatures">_grad_lon contains all missing values, cannot continue.")</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"><span>    </span>return</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures"><span>  </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 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 style="font-variant-ligatures:no-common-ligatures">$ ncl -n -Q cloud_top.ncl<span> </span></span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures">fatal:Coordinate variables must have one dimension only</span></p>
<p 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 style="font-variant-ligatures:no-common-ligatures">fatal:No coordinate variable exists for dimension (lat) in variable (ctt)</span></p>
<p 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 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 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 style="font-variant-ligatures:no-common-ligatures"><br></span></p><p 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 style="font-variant-ligatures:no-common-ligatures">or use them as inputs to the gradient function: <br><br>





</span></p><p 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 style="font-variant-ligatures:no-common-ligatures">$ ncl -n -Q cloud_top.ncl<span> </span></span></p><p 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 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> </span></span></p><p 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 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 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 style="font-variant-ligatures:no-common-ligatures">


</span></p><p 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 style="font-variant-ligatures:no-common-ligatures"></span><br></p><p 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 style="font-variant-ligatures:no-common-ligatures"><br></span></p><p 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 style="font-variant-ligatures:no-common-ligatures"><br></span></p></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>