<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Huseyin,<div><br></div><div>You should be able to use the 'getvar' routine in WRF-Python if you supply the 'meta=False' keyword argument in your getvar call. This will turn off the metadata and give you back a numpy array, so it should bypass all the coordinate stuff if I've coded it correctly. WRF-Python itself doesn't do any plotting. It just has some helper routines to set up the mapping object for cartopy, basemap, or pyngl. These helper routines will fail because it can't get the geographic boundaries, so you'll have to set the mapping objects up yourself. For cartopy and basemap, you're going to have a problem, because both of those packages need the lat/lon location at each grid point so it can convert to meters when it plots. </div><div><br></div><div>Your best bet is to use PyNGL. In PyNGL, if you set the resource tfDoNDCOverlay to True, then you don't need the lat/lon location at each grid point. However, you WILL need to compute the lat/lon information for the corner points and you must make sure that the map projection is set up correctly.  Use the xy_to_ll_proj routine to get the corner points (<a href="https://wrf-python.readthedocs.io/en/latest/user_api/generated/wrf.xy_to_ll_proj.html#wrf.xy_to_ll_proj">https://wrf-python.readthedocs.io/en/latest/user_api/generated/wrf.xy_to_ll_proj.html#wrf.xy_to_ll_proj</a>) [sorry, I sent the wrong link in previous email].</div><div><br></div><div>Below is a snippet of code for how WRF-Python handles the polar stereographic projection (note: this is just for demonstration, you will have to modify/write it for your particular case)</div><div><br></div><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">t2 = getvar(f, "T2", meta=False)<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">last_x = t2.shape[-1] - 1<br>last_y = t2.shape[-2] - 1<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"># First, compute the corner points.</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"># You will have to fill in the '...' stuff with your projection information </blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">ll = xy_to_ll_proj([0,last_x], [0, last_y], ..., meta=False)<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"># Get this from your file global attributes<br>stand_lon = ...<br>_hemi = 1 # 1 for northern hemisphere,  0 for southern<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">_pyngl = pyngl.Resources()<br>_pyngl.mpProjection = <span class="gmail-s1" style="color:rgb(212,146,56)">"</span><span class="gmail-s2" style="text-decoration-line:underline;color:rgb(212,146,56)">Stereographic</span><span class="gmail-s1" style="color:rgb(212,146,56)">"<br></span>_pyngl.mpDataBaseVersion = <span class="gmail-s1" style="color:rgb(212,146,56)">"MediumRes"<br></span><span class="gmail-Apple-converted-space">        <br></span>_pyngl.mpCenterLonF = stand_lon<br><span class="gmail-s3" style="color:rgb(4,51,255)">if</span> _hemi > <span class="gmail-s4" style="color:rgb(148,17,0)">0</span>:<br>    _pyngl.mpCenterLatF = <span class="gmail-s4" style="color:rgb(148,17,0)">90.0<br></span><span class="gmail-s3" style="color:rgb(4,51,255)">else</span>:<br>    _pyngl.mpCenterLatF = -<span class="gmail-s4" style="color:rgb(148,17,0)">90.0<br></span><span class="gmail-Apple-converted-space">            <br></span>_pyngl.mpLimitMode = <span class="gmail-s1" style="color:rgb(212,146,56)">"Corners"<br></span>_pyngl.mpLeftCornerLonF = ll[0,0]<br>_pyngl.mpLeftCornerLatF = ll[1,0]<br>_pyngl.mpRightCornerLonF = ll[0,1]<br>_pyngl.mpRightCornerLatF = ll[1,1]</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">_pyngl.tfDoNDCOverlay = True </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> </blockquote><div><br></div><div>Once you have your PyNGL resources, then you should be able to make contour plots, etc of your data. You can see more examples here in the WRF section (<a href="http://www.pyngl.ucar.edu/Examples/gallery.shtml">http://www.pyngl.ucar.edu/Examples/gallery.shtml</a>), but these make use of get_pyngl for WRF-Python, which you can't use, so you'll have to set up the resources similar to above. </div><div><br></div><div>To be honest, how hard is it to redo your data to keep the coordinate information? Not having the lat/lon points for curvilinear data is going to make things difficult. If you can rerun the data, it might be worth it to avoid all of these hacks.</div><div><br></div><div>Hope this helps,</div><div><br></div><div>Bill</div><div> </div>












</div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Nov 4, 2018 at 5:07 PM Huseyin Ozdemir <<a href="mailto:huseyin@envs.au.dk" target="_blank">huseyin@envs.au.dk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div style="word-wrap:break-word">
<div>Hi Bill,</div>
<div><br>
</div>
<div>Thanks a lot for your answer. I tried the first one and it gave an error because of the lack of xlat variable, then tried the second routine with giving the parameters, and it is working now.</div>
<div><br>
</div>
<div>I am now wondering if i will be able to plot my wrf outputs with wrf-python, because I noticed that getvar routine doesn’t work due to missing lat-lon variables, do you have any advice for this?</div>
<div><br>
</div>
<div>All the best,</div>
<div><br>
</div>
<div>Huseyin</div>
<div><br>
</div>
<br>
<div>
<blockquote type="cite">
<div>Bill Ladwig <<a href="mailto:ladwig@ucar.edu" target="_blank">ladwig@ucar.edu</a>> şunları yazdı (29 Eki 2018 17:40):</div>
<br class="m_-2930833692861780873m_7747948888507240486Apple-interchange-newline">
<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">Hi Huseyin,
<div><br>
</div>
<div>Without that information in the files, you're going to have to calculate the latitude and longitude values. Since you're using Python, you can use wrf-python which contains a xy_to_ll routine that converts grid points to latitude and longitude
 points, as long as you're using one of the standard WRF projections, which it looks like you are (<a href="https://wrf-python.readthedocs.io/en/latest/user_api/generated/wrf.xy_to_ll.html#wrf.xy_to_ll" target="_blank">https://wrf-python.readthedocs.io/en/latest/user_api/generated/wrf.xy_to_ll.html#wrf.xy_to_ll</a>)</div>
<div><br>
</div>
<div>Note that this will only work if you have the map projection global parameters still in your file. If not, there is an xy_to_ll_proj version where you can specify the parameters yourself. (<a href="https://wrf-python.readthedocs.io/en/latest/user_api/generated/wrf.ll_to_xy_proj.html#wrf.ll_to_xy_proj" target="_blank">https://wrf-python.readthedocs.io/en/latest/user_api/generated/wrf.ll_to_xy_proj.html#wrf.ll_to_xy_proj</a>). </div>
<div><br>
</div>
<div>Hope this helps,</div>
<div><br>
</div>
<div>Bill</div>
</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Mon, Oct 29, 2018 at 7:17 AM Huseyin Ozdemir via pyngl-talk <<a href="mailto:pyngl-talk@ucar.edu" target="_blank">pyngl-talk@ucar.edu</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi everyone,<br>
<br>
I have a problem with reading wrf output file (Projection is Polar Stereographic); i want to compare wrf model output with observations at specific latitude-longitude coordinates, but output netcdf file has no latitude and longitude variables.
<br>
<br>
I am using my python environment for reading this netcdf file, where PyNGL and PyNIO are already installed. As an example, temp variable in this output has attributes below:<br>
<br>
short T2 [ Time|1, south_north|150, west_east|150 ]      <br>
      FieldType : 104<br>
      MemoryOrder : XY <br>
      description : TEMP at 2 M<br>
      units : K<br>
      stagger : <br>
      coordinates : XLONG XLAT XTIME<br>
      add_offset : 273.8086<br>
      scale_factor : -0.0005068767<br>
<br>
Here, T2 variable has “Time", “south_north" and “west_east” dimensions and “south_north" and "west _east" dimensions have both 150 grids.  There is no XLAT and XLONG variables in the netcdf output, so how can i get the temperatures at any lat-lon points with
 just grid numbers? <br>
<br>
Thanks in advance,<br>
<br>
Huseyin<br>
<br>
_______________________________________________<br>
pyngl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/pyngl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/pyngl-talk</a><br>
</blockquote>
</div>
</div>
</blockquote>
</div>
<br>
</div>

</blockquote></div>