[ncl-talk] Overlay a box and a marker over WRF field

Rabah Hachelaf hachelaf at sca.uqam.ca
Tue May 26 19:06:45 MDT 2015


Hi Alex ,

When i add
 opts at gsnDraw = False
 opts at gsnFrame = False
 or
 res at gsnDraw = False
 res at gsnFrame = False

and also

 pltres at gsnDraw = False
 pltres at gsnFrame = False

I get only grid with the box and the marker like attached.



2015-05-26 20:47 GMT-04:00 Alex Schaefer <alexander.schaefer at mines.sdsmt.edu
>:

> Rabah,
>
> Where in your script did you add the resources suggested by Jared?
>
> Since you have a bunch of different resource objects you will need to set
> it in each going into plots controlling plot resources. For you this should
> include res or opts and likely pltres.
>
> -Alex
>
>
> On May 26, 2015, at 6:36 PM, Rabah Hachelaf <hachelaf at sca.uqam.ca> wrote:
>
> Hi Jared,
>
> Thanks for your reponse,
>
> But add
>
>
> res at gsnDraw = False
> res at gsnFrame = False
>
> doesn't change any things.
>
> Rabah
>
>
> 2015-05-26 18:34 GMT-04:00 Jared Lee <jaredlee at ucar.edu>:
>
>> Hi Rabah,
>>
>> I believe what you're missing is these two lines where you set other
>> 'res' resources:
>>
>> res at gsnDraw = False
>> res at gsnFrame = False
>>
>> By default they're both set to True, which would give you two separate
>> images. If you set both to false you should get a single plot with your
>> polymarker overlaid.
>>
>> Hope that helps.
>>
>> Jared
>>
>> On Tue, May 26, 2015 at 4:21 PM, Rabah Hachelaf <hachelaf at sca.uqam.ca>
>> wrote:
>>
>>>
>>>
>>> Hello NCL users,
>>>
>>> I am using the script below to plot a box and a marker dot over
>>> topography field from WRF outputs,
>>>
>>> My problem is i can not get one figure, i get two separate figures like
>>> attached.
>>>
>>> Any suggestion to solve this.
>>>
>>>
>>>
>>>
>>>
>>> ;   Example script - plot terrain (using some basic WRF scripts)
>>> ;   Overwrite basic map background settings
>>> ;   November 2008
>>>
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>>>
>>> begin
>>>
>>>   a = addfile("../geo_em.d02.nc","r")           ; Open a file
>>>   filename = "../namelist.wps"
>>>
>>>   npres= True
>>>   npres at ref_lat   = stringtofloat(systemfunc("grep ref_lat    "
>>> +filename+ " | cut -f2 -d'=' | cut -f1 -d','" ) )
>>>   npres at ref_lon   = stringtofloat(systemfunc("grep ref_lon    "
>>> +filename+ " | cut -f2 -d'=' | cut -f1 -d','" ) )
>>>
>>>  type = "png"
>>>   wks = gsn_open_wks(type,"plt_geo_6")         ; Create a plot
>>> workstation
>>>
>>>
>>>   opts = True                                  ; Set some Basic Plot
>>> options
>>>   opts at MainTitle = "GEOGRID FIELDS"
>>>   opts at InitTime = False                        ; Do not plot time or
>>> footers
>>>   opts at Footer = False
>>>
>>>   ter = wrf_user_getvar(a,"HGT_M",0)           ; Read the variable to
>>> memory
>>>   lon = a->XLONG_U(0,:,:)
>>>   lat = a->XLAT_U(0,:,:)
>>>  printVarSummary(lat)
>>>
>>>  print (lat(0,0)+", "+lon(0,0)+",0,")
>>>  print (lat(0,60)+", "+lon(0,60)+",0,")
>>>  print (lat(59,60)+", "+lon(59,60)+",0,")
>>>  print (lat(59,0)+", "+lon(59,0)+",0")
>>>
>>>
>>>   res = opts                                   ; Use basic options for
>>> this field
>>>   res at cnFillOn = True                          ; Create a color fill
>>> plot
>>>   res at ContourParameters = (/ 0., 1000., 50. /) ; Set the levels
>>>
>>>   contour = wrf_contour(a,wks,ter,res)
>>>
>>>   pltres = True                                ; Set plot options
>>>   mpres = True                                 ; Set map options
>>>   mpres at mpGeophysicalLineColor      = "Black"  ; Overwrite basic map
>>> settings
>>>   mpres at mpGridLineColor             = "Black"
>>>   mpres at mpLimbLineColor             = "Black"
>>>   mpres at mpNationalLineColor         = "Black"
>>>   mpres at mpPerimLineColor            = "Black"
>>>   mpres at mpUSStateLineColor          = "Black"
>>>      mpres at mpProjection = "LambertConformal"
>>>        mpres at mpLambertParallel1F = 30
>>>        mpres at mpLambertParallel2F = 60
>>>        mpres at mpLambertMeridianF = -98
>>>        mpres at mpGridSpacingF     = 0.25
>>> ;************************************************
>>> ; add the box
>>> ;************************************************
>>> ;************************************************
>>>  ypts = (/ lat(10,10), lat(10,50), lat(49,50),  lat(49,10),  lat(10,10)/)
>>>  xpts = (/ lon(10,10), lon(10,50), lon(49,50),  lon(49,10),  lon(10,10)/)
>>> ;************************************************
>>>
>>>   resp                  = True                      ; polyline mods
>>> desired
>>>   resp at gsLineColor      = "black"                     ; color of lines
>>>   resp at gsLineThicknessF = 2.0                       ; thickness of lines
>>> ;  resp at gsLineLabelString= "test"                    ; adds a line
>>> label string
>>>
>>>
>>>
>>>   plot = wrf_map_overlays(a,wks,(/contour/),pltres,mpres) ; Plot field
>>> over map background
>>>
>>>
>>>   dum = new(4,graphic)
>>>   do i = 0 , 3
>>>     dum(i)=gsn_add_polyline(wks,plot,xpts(i:i+1),ypts(i:i+1),resp)
>>>   end do
>>> ;*********************************************************
>>>   mpres at gsMarkerColor = "Black"
>>>   mpres at gsMarkerIndex = 16
>>>   mpres at gsMarkerSizeF = 0.005
>>>   gsn_polymarker(wks,plot,npres at ref_lon,npres at ref_lat,mpres)
>>>
>>>   draw(plot)
>>>   frame(wks)
>>>
>>> end
>>>
>>> --
>>> ------------------------------
>>> Cordialement,
>>> Best regards,
>>> Rabah Hachelaf
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>>
>> --
>> ===============================
>> Jared A. Lee, Ph.D.
>> Project Scientist I
>> Research Applications Laboratory
>> National Center for Atmospheric Research
>> Boulder, Colorado, USA
>>
>> Email: jaredlee at ucar.edu (w)
>> Phone: 303.497.8485 (w)
>> Web: https://staff.ucar.edu/users/jaredlee
>> ===============================
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
>
> --
> ------------------------------
> Cordialement,
> Best regards,
> Rabah Hachelaf
>  _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>


-- 
------------------------------
Cordialement,
Best regards,
Rabah Hachelaf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150526/294a6ab0/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plt_geo_6.png
Type: image/png
Size: 97433 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150526/294a6ab0/attachment.png 


More information about the ncl-talk mailing list