[ncl-talk] Lots of Problems with wrf_contour

Mary Haley haley at ucar.edu
Sun Jul 10 18:30:06 MDT 2016


If you are trying to use the wrf_xxxx plotting functions but with a lot of
customizations, like turning off titles, changing the labelbar, etc, then I
recommend using gsn_csm_xxxx scripts for plotting instead of wrf_xxxxx.

The wrf_xxxx plotting routines are nice because they figure out all the
correct map resources you need to set in order to correctly plot the data
in the native WRF map projection. However, they are really tailored to be
drawn to an 8.5 " x 11 " piece of paper (hence all the titles and the white
space).

With just a few changes, you can easily use the gsn_csm_xxxx scripts, and
not have to worry about all those titles.  Please see this page for more
information:

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

You may also want to see examples 3, 4, and 10 on this page:

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

I noticed that in your original script, you are doing things like this:

  hgt at lat2d = wrf_user_getvar(a, "XLAT", it)
  hgt at lon2d = wrf_user_getvar(a, "XLONG", it)
  spd at lon2d = hgt at lon2d
  spd at lat2d = hgt at lat2d

You generally do *not* want to do this when calling the wrf_xxxxx plotting
scripts, because they use the map projection on the file and don't need the
lat/lon coordinates.  If you try to do both lat2d/lon2d *and* use the wrf
map projection, you may confuse things.

The lat2d/lon2d stuff is for when you are plotting using
gsn_csm_contour_map, gsn_csm_vector_map, etc.  So, you are already part of
the way there if you switch from wrf_xxx to gsn_csm_xxxx.

--Mary


On Wed, Jul 6, 2016 at 3:57 PM, Rick Brownrigg <brownrig at ucar.edu> wrote:

> (Sorry about the previous incomplete note)
>
> Hi,
>
> With regard to the field titles, both wrf_contour and wrf_vector take
> special resources FieldTitle, SubFieldTitle and UnitLabel that have default
> behaviors if not explicitly set; perhaps you can what you want by
> overriding their defaults:
>
> http://ncl.ucar.edu/Document/Functions/WRF_arw/wrf_contour.shtml
>
> I'm wondering if this line isn't causing the problem with the axis
> labeling (perhaps remove it?)
>
> res at pmTickMarkDisplayMode = "Always"
>
> How is it you want to adject the contours.
>
> I don't know about centering the labelbar.
>
> Rick
>
> On Wed, Jul 6, 2016 at 3:54 PM, Rick Brownrigg <brownrig at ucar.edu> wrote:
>
>> Hi,
>>
>> With regard to the field titles, both wrf_contour and wrf_vector take
>> special resources FieldTitle, SubFieldTitle and UnitLabel that have default
>> behaviors if not explicitly set; perhaps you can what you want by
>> overriding their defaults:
>>
>> http://ncl.ucar.edu/Document/Functions/WRF_arw/wrf_contour.shtml
>>
>> I'm wondering if this line isn't causing the problem with the axis
>> labeling (perhaps remove it?)
>>
>>
>> On Wed, Jun 29, 2016 at 1:51 PM, Kerwyn Texeira <ktish86 at gmail.com>
>> wrote:
>>
>>> Hi ncl-talk,
>>>
>>> I four question about wrf_contour
>>>
>>> 1.  How to remove the field titles?
>>> 2. How to fix the longitude and latitude axis
>>> 3. How do I adjust the contours
>>> 4. How do I fix the vertical bar title where it is centered?
>>>
>>> I tried using my code for a few days now and I had no luck. I'm not
>>> getting any errors but it just will not plot right. It's like it's not
>>> obeying the script. I have attached the figure. Could anyone help me
>>> please.  It would be greatly appreciated.
>>>
>>> Thanks
>>>
>>> Script:
>>>
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>>>
>>> ;-----------------------------------------------------------------------
>>>
>>> begin
>>>
>>>   a = addfile("./wrfout_d02_2014-01-11_16_00_00.nc","r")
>>>
>>>   it = 0
>>>   hgt       = wrf_user_getvar(a, "HGT", it)
>>>   hgt at lat2d = wrf_user_getvar(a, "XLAT", it)
>>>   hgt at lon2d = wrf_user_getvar(a, "XLONG", it)
>>>   u         = wrf_user_getvar(a, "ua", it)
>>>   v         = wrf_user_getvar(a, "va", it)
>>>   p         = wrf_user_getvar(a, "pressure", it)
>>>   z        = wrf_user_getvar(a, "z", it)
>>>   tc        = wrf_user_getvar(a, "tc", it)
>>>
>>>   u_wind    = wrf_user_intrp3d(u, p, "h", 700., 0.0, False)
>>>   v_wind    = wrf_user_intrp3d(v, p, "h", 700., 0.0, False)
>>>   z_plane   = wrf_user_intrp3d(z, p, "h", 700., 0.0, False)
>>>   tc_plane  = wrf_user_intrp3d(tc, p, "h", 700., 0.0, False)
>>>
>>>   spd = (u_wind*u_wind + v_wind*v_wind)^(0.5)  ;m/s
>>>   u_wind = u_wind*1.94384449
>>>   v_wind = v_wind*1.94384449
>>>
>>>   u_wind at lon2d =   hgt at lon2d
>>>   u_wind at lat2d =   hgt at lat2d
>>>
>>>   v_wind at lon2d =   hgt at lon2d
>>>   v_wind at lat2d =   hgt at lat2d
>>>
>>>   z_plane at lon2d = hgt at lon2d
>>>   z_plane at lat2d = hgt at lat2d
>>>
>>>   tc_plane at lon2d = hgt at lon2d
>>>   tc_plane at lat2d = hgt at lat2d
>>>
>>>
>>>   spd = spd*1.94384449
>>>
>>>   spd at lon2d = hgt at lon2d
>>>   spd at lat2d = hgt at lat2d
>>>
>>>  ; spd at units = "Wind Speed"
>>>  ; spd at units = "kts"
>>>
>>>
>>> ;-----------------------------------------------------------------------------
>>>
>>>   wks_type = "png"
>>>   wks_type at wkWidth = 2500.
>>>   wks_type at wkHeight = 2500.
>>>
>>>   wks = gsn_open_wks(wks_type, "temp")
>>>   gsn_define_colormap(wks,"matlab_jet")
>>>
>>>
>>> ;-----------------------------------------------------------------------------
>>>
>>>   res                       = True
>>>   res at InitTime              = False
>>>   res at FieldTitle            = ""
>>>   res at Footer                = False
>>>   ;res at gsnDraw               = False           ; do not draw the plot
>>>   ;res at gsnFrame              = False           ; do not advance the
>>> frame
>>>   res at cnLineLabelsOn        = False           ; do not use line labels
>>>   res at cnFillOn              = True            ; color fill
>>>   res at cnLinesOn             = False           ; do not draw contour
>>> lines
>>>   res at tiMainString          = "Winds (kts) at 700hpa on Jan 11 at
>>> 16:00UTC"
>>>   res at tiMainFont            = "helvetica"
>>>   res at tiMainFontHeightF     = 0.025
>>>   res at pmTickMarkDisplayMode = "Always"
>>>   ;res at mpOutlineOn           = True
>>>   res at lbOrientation         = "Vertical"
>>>   res at tiMainOffsetYF        = -0.03
>>>   ;res at mpFillOn              = False
>>>   ;res at mpOutlineOn           = True            ; turn the map outline on
>>>   res at lbTitleString           = "Temperature (C)"
>>>   res at lbOrientation = "vertical"
>>>   res at pmLabelBarSide = "right"
>>>   res at cnLevelSelectionMode  = "EqualSpacedLevels"
>>>   res at cnInfoLabelOn         = False
>>>
>>> ;-----------------------------------------------------------------------------
>>> ; For zooming in... don't need
>>>
>>>   ;res at mpMinLatF     = 34.5    ; 37.85      ; Zoomed in Lat and Lon
>>>   ;res at mpMaxLatF     = 35.2    ; 38.50
>>>   ;res at mpMinLonF     = -123.    ; -120.0
>>>   ;res at mpMaxLonF     = -115.5    ; -119.35
>>>
>>>
>>> ;-----------------------------------------------------------------------------
>>>
>>>   ;res at gsnLeftString = ""
>>>
>>>   ;res at gsnLeftString = "Geopotential Height (m) and Temperature (C)"
>>>   ;res at gsnStringFontHeightF = 0.020
>>>
>>>   ;res at gsnRightString = ""
>>>
>>>   res at lbTitleString   = "Temperature (C)"
>>>   res at lbTitlePosition = "Right"
>>>   res at lbTitleDirection = "Across"
>>>   res at lbTitleAngleF    = 90.
>>>   ;res at lbTitleFontHeightF = 0.020
>>>
>>>   ;res at gsnAddCyclic = False
>>>   res at cnLevelSelectionMode= "ManualLevels"
>>>   res at cnMinLevelValF = -7
>>>   res at cnMaxLevelValF = 4
>>>   res at cnLevelSpacingF = 1
>>>
>>> ;------wind vectors
>>>   res2 = True
>>>   ;res2 at gsnDraw = False
>>>   ;res2 at gsnFrame = False
>>>   res2 at vcWindBarbLineThicknessF= 4.0
>>>   res2 at vcRefLengthF= 0.018
>>>   res2 at vcRefMagnitudeF= 10
>>>   res2 at vcMinDistanceF = 0.05
>>>   ;res2 at vcGlyphStyle = "WindBarb"
>>>
>>>   res2 at FieldTitle = "Wind"   ; overwrite Field Title
>>>   res2 at NumVectors = 47       ; wind barb density
>>>
>>> ;-------Temps
>>>
>>>
>>> ;------Geopotential Height
>>>   res3 = True
>>>
>>>   res3 at cnLineColor = "Black"
>>>   res3 at cnLineThicknessF = 5.0
>>>
>>>   ;res3 at cnInfoLabelOn = False
>>>   res3 at cnLevelSpacingF = 2
>>>   res3 at cnLineLabelBackgroundColor = "white"
>>>   ;res3 at cnLineLabelDensityF = 0.5
>>>
>>> ;----------------------------------
>>>   pltres = True
>>>   mpres = True
>>>
>>>   mpres at mpGeophysicalLineColor      = "Black"
>>>   mpres at mpNationalLineColor         = "Black"
>>>   mpres at mpUSStateLineColor          = "Black"
>>>   mpres at mpGridLineColor             = "Black"
>>>   mpres at mpLimbLineColor             = "Black"
>>>   mpres at mpPerimLineColor            = "Black"
>>>   mpres at mpGeophysicalLineThicknessF = 3.0
>>>   pltres at gsnMaximize     = True
>>>
>>>
>>> ;-----contours/vectors
>>>   winds = wrf_vector(a, wks, u_wind, v_wind, res2)
>>>   temps = wrf_contour(a, wks, tc_plane, res)
>>>   geoPz = wrf_contour(a, wks, z_plane, res3)
>>>
>>>     plot = wrf_map_overlays(a, wks, (/ winds, temps, geoPz /), mpres,
>>> pltres)
>>>     ;draw(plot)
>>>     ;frame(wks)
>>>
>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>
>>>
>>> end
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
> _______________________________________________
> 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/20160710/e654e04e/attachment.html 


More information about the ncl-talk mailing list