[ncl-talk] difference between using res at tfDoNDCOverlay and @lat2d @lon2d when overlaying wind vectors

Mary Haley haley at ucar.edu
Fri Apr 27 13:34:18 MDT 2018


Xiaoming,

I finally had a chance to look at this.

I first took your script and reduced it to just create a basic line vector
plot, because I wanted to make sure there were no extraneous resources
being set that could be the source of the problem.

Long story short: if you set tfDoNDCOverlay=False and use the special
lat2d/lon2d attributes to create the plot, then you also need to set:

  res at vcMapDirection = False

See the attached wrf_vectors.ncl (which I will make an official example on
the WRF examples page somewhere).

This script allows you to try different combinations of vcMapDirection and
tfDoNDCOverlay in one script so you can compare the images. You can also
plug in other WRF output files and it should work.

To try different combinations of these two resources setting, set
ndc_overlay and/or map_direction to True / False on the NCL command line.
For example:

ncl map_direction=False ndc_overlay=True wrf_vectors.ncl
ncl map_direction=False ndc_overlay=False wrf_vectors.ncl
ncl map_direction=True ndc_overlay=True wrf_vectors.ncl
ncl map_direction=True ndc_overlay=False wrf_vectors.ncl


For the case of map_direction = True (vcMapDirection) and ndc_overlay =
False (tfDoNDCOverlay), the vectors are slightly shifted (and incorrect as
you pointed out).

For the other three combinations of these two settings, the vector plots
are the same. I've attached all four PNGs to this email.

I have to admit that the vcMapDirection resource is a bit of a mystery to
me as to when it should be True or False.  It is documented on the vectors
resource page
<http://www.ncl.ucar.edu/Document/Graphics/Resources/vc.shtml#vcMapDirection>
:

*vcMapDirection*
This resource controls whether the vector direction is mapped into the same
coordinate space as the vector location, or whether it is rendered in a
locally uniform cartesian coordinate space. This resource has an effect
whenever a non-uniform transformation is in effect. These include most of
the MapTransformation transformations and IrregularTransformation
transformations. Also included are logarithmic transformations provided by
the LogLinTransformation and even linear transformations when the X and Y
unit sizes are different.
Default: True



If you look at our vectors examples page (which I just updated):

http://www.ncl.ucar.edu/Applications/vector.shtml

it talks about the vcMapDirection resource and how it must be set to False
if the latitude spacings are very different from the longitude spacings.
With your data, the latitude spacings vary from 0.097 to 0.11, whereas the
longitude spacings vary from 0.1 to 11.0. This is enough of a difference
that vcMapDirection needs to be set to False.

As an extra test, I asked Bill Ladwig to plot this same data using a Python
script that uses PyNIO to read in the data and matplotlib to plot it. I've
attached the Python script and the wrf_quiver.png file so you can compare.

To learn more about wrf-python, see:

http://wrf-python.readthedocs.io/en/latest/

Thanks for your patience.

--Mary



On Fri, Apr 20, 2018 at 1:47 PM, xiaoming Hu <yuanfangcan at hotmail.com>
wrote:

> Realized ncl scripts are not attached in previous email.  Here again!
>
>
>  Thanks a lot for helping on this!
>
>  Now I changed to  NCl 6.3.0 and used wrf_map_resources and added
> res at gsnAddCyclic = False
>
>  But I still did not make the case of tfDoNDCOverlay not being set    to
> be consistent with  the case of tfDoNDCOverlay setting to True
>
>  I attached 2 cleaned script
>
>  with plot_geoHeight950mb_combine2episodes_with_ndc_overlay.ncl I got:
>
>
> with plot_geoHeight950mb_combine2episodes_without_ndc_overlay.ncl, I got:
>
>
> The previous issue still exists, plus the map is gone. :)
>
> See the difference between the 2 scripts:
>
> < ;  res at tfDoNDCOverlay       = True
> <   res at tfDoNDCOverlay       = False
> ---
> >   res at tfDoNDCOverlay       = True
> > ;  res at tfDoNDCOverlay       = False
> 134,140d132
> <    u_950 at lat2d = lat2d
> <    u_950 at lon2d = lon2d
> <    v_950 at lat2d = lat2d
> <    v_950 at lon2d = lon2d
> <    geoHeight_950 at lat2d = lat2d
> <    geoHeight_950 at lon2d = lon2d
> <
> 146,147c138,139
> < ;    plot                 = gsn_csm_vector_scalar_map(wks,
> u_950(:,n_cutoff:),v_950(:,n_cutoff:),geoHeight_950(:,n_cutoff:),res)
> <     plot                 = gsn_csm_vector_scalar_map(wks,
> u_950,v_950,geoHeight_950,res)
> ---
> >     plot                 = gsn_csm_vector_scalar_map(wks,
> u_950(:,n_cutoff:),v_950(:,n_cutoff:),geoHeight_950(:,n_cutoff:),res)
> > ;    plot                 = gsn_csm_vector_scalar_map(wks,
> u_950,v_950,geoHeight_950,res)
>
> Did I miss anything?
>
>   I put the data (1.9G) at
>
>  http://www.caps.ou.edu/micronet/HurricaneImpactonO3/
> WRFV3.9.1/YSU/wrfchem3.9.1_ERA2d_CONUS_NLCD_NEI2011_
> MEGAN_nudge2.2011082500/wrfout_d01_2011-08-08_12:00:00
>
>
> Thanks a lot!
>
> Xiaoming
> ------------------------------
> *From:* Mary Haley <haley at ucar.edu>
> *Sent:* Wednesday, April 18, 2018 7:18:48 PM
> *To:* xiaoming Hu
> *Cc:* ncl-talk at ucar.edu; Xiaoming Hu
> *Subject:* Re: [ncl-talk] difference between using res at tfDoNDCOverlay and
> @lat2d @lon2d when overlaying wind vectors
>
> Xiaoming,
>
> You have an out-dated function call (WRF_map_c) that might possibly be the
> source of the problem. This is a deprecated function and you should use
> wrf_map_resources to set your WRF map projection instead:
>
> http://www.ncl.ucar.edu/Document/Functions/WRF_arw/wrf_map_resources.shtml
> wrf_map_resources - CISL's NCAR Command Language (NCL)
> <http://www.ncl.ucar.edu/Document/Functions/WRF_arw/wrf_map_resources.shtml>
> www.ncl.ucar.edu
> NCL Home > Documentation > Functions > WRF, Graphics routines
> wrf_map_resources. Sets map plotting resources based on an input WRF-ARW
> file. Available in version 6.1.0 and later.
>
>
> I can't tell from your code why the two results are different, because
> it's not clear to me if the only thing you are changing is whether or not
> tfDoNDCOverlay is set.
>
> If I'm understanding your email correctly, it sounds like the plot that is
> created when tfDoNDCOverlay is set to True is the one that's correct.
> However, I'm surprised it's working for you because:
>
> [1] If you set tfDoNDCOverlay to True, you should NOT attach any
> lat2d/lon2d attributes to your data variables.
>
> [2] Also, if tfDoNDCOverlay is True, you must be using the EXACT map
> projection that was defined on the file.  But, you are using WRF_map_c
> which hasn't been updated in years, so this function could likely be giving
> you wrong results. Also, you are setting:
>
>   n_cutoff = 150
>   res at mpLeftCornerLonF = lon2d(0,n_cutoff)
>   res at mpLeftCornerLatF = lat2d(0,n_cutoff)
>
> which looks to me like you are zooming in on the map, but you haven't also
> zoomed in on the data in the same way, so again, I don't know how your
> plots can be correct.
>
> [3] For the case of tfDoNDCOverlay not being set, you may need to set
> res at gsnAddCyclic = False to prevent a longitude cyclic point from being
> added.
>
> Please visit this WRF examples page, which has examples of plotting WRF
> data with both tfDoNDCOverlay set and without it set:
>
> http://www.ncl.ucar.edu/Applications/wrfgsn.shtml
>
> I've attached two modified versions of your script. Since I don't have the
> data, I am unable to test these scripts. But, hopefully they help show the
> difference between these two scenarios.
>
> If you continue to have problems with this, please post back to ncl-talk,
> but include a clean, updated script if possible.
>
> Good luck,
>
> --Mary
>
>
>
>
>
>
>
> On Tue, Apr 17, 2018 at 11:04 PM, xiaoming Hu <yuanfangcan at hotmail.com>
> wrote:
>
> Hello
>
>
>  If I use res at tfDoNDCOverlay  I got the figure of
>
>
> But If I use @lat2d @lon2d without res at tfDoNDCOverlay  I got
>
>
> The wind vectors near the right edge in the left panel do not follow the
> pressure lines now.
>
>
> Any comments on overlaying wind vectors using res at tfDoNDCOverlay    or
> using @lat2d @lon2d without res at tfDoNDCOverlay ?
>
> I attached my ncl script
>
> Thanks
>
> Xiaoming
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180427/bcccf223/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 239315 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180427/bcccf223/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 238265 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180427/bcccf223/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrfout_d01_2011-08-08_12_00_00_ndc_False_mapdir_True.png
Type: image/png
Size: 209062 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180427/bcccf223/attachment-0009.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrfout_d01_2011-08-08_12_00_00_ndc_True_mapdir_True.png
Type: image/png
Size: 212673 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180427/bcccf223/attachment-0010.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrfout_d01_2011-08-08_12_00_00_ndc_False_mapdir_False.png
Type: image/png
Size: 213358 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180427/bcccf223/attachment-0011.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrfout_d01_2011-08-08_12_00_00_ndc_True_mapdir_False.png
Type: image/png
Size: 212945 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180427/bcccf223/attachment-0012.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrf_vectors.ncl
Type: application/octet-stream
Size: 3433 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180427/bcccf223/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrf_quiver.png
Type: image/png
Size: 255111 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180427/bcccf223/attachment-0013.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrf_quiver.py
Type: text/x-python-script
Size: 1679 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180427/bcccf223/attachment-0001.bin>


More information about the ncl-talk mailing list