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

Rabah Hachelaf hachelaf at sca.uqam.ca
Tue May 26 16:21:48 MDT 2015


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150526/a8e53506/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plt_geo_6.000001.png
Type: image/png
Size: 133821 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150526/a8e53506/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plt_geo_6.000002.png
Type: image/png
Size: 97433 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150526/a8e53506/attachment-0001.png 


More information about the ncl-talk mailing list