[ncl-talk] overlaying a hodograph onto a sounding

Joe Grim grim at ucar.edu
Mon Apr 9 18:04:32 MDT 2018


 That did it!  Thank you very much, Adam!  I just had to adjust
amres at amOrthogonalPosF a little to move it down some.

On Mon, Apr 9, 2018 at 4:04 PM, Adam Phillips <asphilli at ucar.edu> wrote:

> Hi Joe,
> I think you may be right about overlay using the native coordinate system
> of skewT_background. If you cannot get things to work with the overlay
> route, I recommend you shift to using gsn_add_annotation in lieu of
> overlay. There are numerous examples on the Annotations example page (
> http://www.ncl.ucar.edu/Applications/annotate.shtml) on how to do this. I
> think you should be able to get away with the following:
>
> 1) Draw the background using skewT_BackGround
> <https://www.ncl.ucar.edu/Document/Functions/Skewt_func/skewT_BackGround.shtml>
> .
> 2) Draw the hodograph using gsn_csm_xy
> <https://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_csm_xy.shtml>
>    - making sure to set gsnDraw and gsnFrame to False
>    - set vpXF, vpYF, vpWidthF, and vpHeightF to only plot in the
> upper-lefthand side of the plot
> 3) call gsn_add_annotation to overlay the hodograph on the
> skewT_background.
> 4) Draw the plot, like this: draw (skewt_bkgd)
> 5) Use the skewT_PlotData
> <https://www.ncl.ucar.edu/Document/Functions/Skewt_func/skewT_PlotData.shtml> to
> overlay the skewT data.
> 6) Advance the frame: frame(wks)
>
> Code:
>  skewt_bkgd             = skewT_BackGround (wks, skewtOpts)
>
>  hodo_res = True
>  hodo_res at vpXF      = 0.07
>  hodo_res at vpYF      = 0.92
>  hodo_res at vpWidthF  = 0.15
>  hodo_res at vpHeightF = 0.15
>  hodo_res at gsnDraw   = False
>  hodo_res at gsnFrame  = False
>  hodo_plot = gsn_csm_xy(wks,U_unstag(0,:,locY,locX),V_unstag(0,:,locY,loc
> X),hodo_res)
>
>
>  amres                  = True
>  amres at amParallelPosF   = -0.5    ; -0.5 is the left edge of the plot.
>  amres at amOrthogonalPosF =  -0.5   ; -0.5 is the top edge of the plot.
>  amres at amJust           = "BottomLeft"
>  anno1 = gsn_add_annotation(skewt_bkgd, hodo_plot, amres)
>  draw (skewt_bkgd)
>
> ; Draw the skew-T data
>  dataOpts           = True
>  dataOpts at Parcel          = 1
>  dataOpts at WspdWdir        = False  ; wind speed and dir [else: u,v]
>  skewT_data = skewT_PlotData(wks, skewt_bkgd, P_tot(:,locY,locX), \
>                                                TC(0,:,locY,locX), \
>                                                TD(0,:,locY,locX), \
>                                             z_tot(0,:,locY,locX), \
>                                          U_unstag(0,:,locY,locX), \
>                                          V_unstag(0,:,locY,locX), \
>                                              dataOpts)
>  frame(wks)
> end
>
> The only question I have with the above coding is whether the hodograph
> will be drawn in the correct order (=last).
> Hope that helps!
> Adam
>
>
>
> On Mon, Apr 9, 2018 at 2:33 PM, Joe Grim <grim at ucar.edu> wrote:
>
>> Hi,
>>
>> Could someone please help me with a conceptual skewT + hodograph plot?
>> My hope is to create a skewT plot with a hodograph overlaid, much like what
>> you see from other skewT plots, such as this one:
>> http://weather.rap.ucar.edu/upper/dnr.gif.  I couldn't find any examples
>> on the NCL website, so I thought I could create my own, but couldn't get it
>> to plot correctly.
>>
>> Conceptually, I imagine the script would be created in this order:
>> 1) Draw the background using skewT_BackGround
>> <https://www.ncl.ucar.edu/Document/Functions/Skewt_func/skewT_BackGround.shtml>
>> .
>> 2) Draw the hodograph using gsn_csm_xy
>> <https://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_csm_xy.shtml>
>>    - making sure to set gsnDraw and gsnFrame to False
>>    - set vpXF, vpYF, vpWidthF, and vpHeightF to only plot in the
>> upper-lefthand side of the plot
>> 3) Use the overlay procedure to overlay the two, like
>> this: overlay(skewt_bkgd,hodo_plot)
>> 4) Draw the plot, like this: draw (skewt_bkgd)
>> 5) Use the skewT_PlotData
>> <https://www.ncl.ucar.edu/Document/Functions/Skewt_func/skewT_PlotData.shtml> to
>> overlay the skewT data.
>> 6) Advance the frame: frame(wks)
>>
>> I almost got it to work, except the hodograph only plots on the bottom of
>> the image the portion of the hodograph with positive V component (I assume
>> the rest is "off screen" below); I assume it is using the native coordinate
>> system of skewT_BackGround
>> <https://www.ncl.ucar.edu/Document/Functions/Skewt_func/skewT_BackGround.shtml> instead
>> of having its own independent coordinate system.
>>
>> Does anyone have any thoughts or ideas of how I can do this?  Thanks!
>>
>> Joe
>>
>> P.S.  Here is the current version of my code:
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/skewt_func.ncl"
>> begin
>> ; Read in WRF data
>>  in_file = "/d3/ATEC/wrfout_misc/ATC/wrfout_d01_2017-09-02_05:00:00.
>> ATC_P+FCST"
>>  ncdf_in = addfile(in_file+".nc","r")
>>  P_tot      = wrf_user_getvar(ncdf_in,"pressure",0)
>>  z_tot      = wrf_user_getvar(ncdf_in,"z",-1)
>>  U          = wrf_user_getvar(ncdf_in,"U",-1)
>>  U_unstag = wrf_user_unstagger(U,U at stagger)
>>  V          = wrf_user_getvar(ncdf_in,"V",-1)
>>  V_unstag = wrf_user_unstagger(V,V at stagger)
>>  TC         = wrf_user_getvar(ncdf_in,"tc",-1)
>>  TD         = wrf_user_getvar(ncdf_in,"td",-1)
>>
>> ; Create skewT background
>>  PlotType = "png"
>>  PlotName = "Sounding_MartinAF"
>>  wks = gsn_open_wks(PlotType,PlotName)
>>   loc = wrf_user_ll_to_ij(ncdf_in,-76.42,39.33,True)
>>   locX = loc(0) - 1
>>   locY = loc(1) - 1
>>  skewtOpts          = True
>>  skewtOpts at vpXF              = 0.07    ; controls off-set from left
>>  skewtOpts at vpYF              = 0.92    ; controls off-set from top
>>  skewtOpts at vpWidthF          = 0.85    ; controls size of plot
>>  skewtOpts at vpHeightF         = 0.85    ; controls size of plot
>>  skewtOpts at tiMainString = "Sounding at 39.33N, 76.42W"
>>  skewt_bkgd             = skewT_BackGround (wks, skewtOpts)
>>  draw (skewt_bkgd)
>>
>> ; Draw hodograph here???
>>  hodo_res = True
>>  hodo_res at vpXF      = 0.07
>>  hodo_res at vpYF      = 0.92
>>  hodo_res at vpWidthF  = 0.15
>>  hodo_res at vpHeightF = 0.15
>>  hodo_res at gsnDraw   = False
>>  hodo_res at gsnFrame  = False
>>  hodo_plot = gsn_csm_xy(wks,U_unstag(0,:,locY,locX),V_unstag(0,:,locY,loc
>> X),hodo_res)
>>  overlay(skewt_bkgd,hodo_plot)
>>  draw (skewt_bkgd)
>>
>> ; Draw the skew-T data
>>  dataOpts           = True
>>  dataOpts at Parcel          = 1
>>  dataOpts at WspdWdir        = False  ; wind speed and dir [else: u,v]
>>  skewT_data = skewT_PlotData(wks, skewt_bkgd, P_tot(:,locY,locX), \
>>                                                TC(0,:,locY,locX), \
>>                                                TD(0,:,locY,locX), \
>>                                             z_tot(0,:,locY,locX), \
>>                                          U_unstag(0,:,locY,locX), \
>>                                          V_unstag(0,:,locY,locX), \
>>                                              dataOpts)
>>  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
>>
>>
>
>
> --
> Adam Phillips
> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
> www.cgd.ucar.edu/staff/asphilli/   303-497-1726
>
> <http://www.cgd.ucar.edu/staff/asphilli>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180409/2271a054/attachment.html>


More information about the ncl-talk mailing list