[ncl-talk] The shp only appear on the last plot of a (/3, 1/)panel
Kim, Changhwan
changhwan.kim at metoffice.gov.uk
Thu Jul 28 03:29:21 MDT 2016
Hello,
Try this, please.
Id = new(3, graphic)
Id(0) = gsn_add_shapefile_polylines(wks,plot(0),shp_name1,lnres)
Id(1) = gsn_add_shapefile_polylines(wks,plot(1),shp_name1,lnres)
Id(2) = gsn_add_shapefile_polylines(wks,plot(2),shp_name1,lnres)
Cheers.
From: ncl-talk-bounces at ucar.edu [mailto:ncl-talk-bounces at ucar.edu] On Behalf Of grace
Sent: 28 July 2016 03:47
To: ncl-talk
Subject: [ncl-talk] The shp only appear on the last plot of a (/3,1/)panel
Hi:
All,I have write a script to plot a (/3,1/)panel,but the shp I added only appeared on the last plot.
The description only worked on the first plot.
[cid:image001.jpg at 01D1E8BA.E6FD8330]
This is my script:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
begin
;
; The WRF ARW input file.
; This needs to have a ".nc" appended, so just do it.
a = addfile("/public/home/huanglei/data/20160724/oldwrf/wrfout_d03_2016-07-23_12:00:00"+".nc","r")
; We generate plots, but what kind do we prefer?
; type = "x11"
type = "pdf"
; type = "ps"
; type = "ncgm"
wks = gsn_open_wks(type,"plt_Precip_oldwrf3km")
plot = new(3,graphic)
; Set some basic resources
res = True
mpres = True ; Map resources
mpres at mpOutlineOn = False ; Turn off map outlines
mpres at mpFillOn = False ; Turn off map fill
mpres at mpGridAndLimbOn = True
;res at mpProjection = "Lambert"
pltres = True ; Plot resources
pltres at PanelPlot = True ; Tells wrf_map_overlays not to remove overlays
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; What times and how many time steps are in the data set?
FirstTime = True
times = wrf_user_getvar(a,"times",-1) ; get all times in the file
ntimes = dimsizes(times) ; number of times in the file
; print(times)
; exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
it_end = 29
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; First get the variables we will need
; Get non-convective, convective and total precipitation of 5km
rain_exp = wrf_user_getvar(a,"RAINNC",it_end)
rain_con = wrf_user_getvar(a,"RAINC",it_end)
rain_tot = rain_exp + rain_con
rain_tot at description = "Total Precipitation"
;calculate the precipitation
it_start = 22
rain_exp_save = wrf_user_getvar(a,"RAINNC",it_start)
rain_con_save = wrf_user_getvar(a,"RAINC",it_start)
rain_tot_save = rain_exp_save + rain_con_save
times_sav = times(it_start)
rain_tot_tend = rain_tot - rain_tot_save
rainc_tend = rain_con - rain_con_save ; CUMULUS PRECIPITATION
rainnc_tend= rain_exp - rain_exp_save ; SCALE PRECIPITATION
rain_tot_tend at description = "Precipitation of 3km(old wrf)"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Plotting options for Precipitation
opts_r = res
opts_r at UnitLabel = "mm"
opts_r at cnLevelSelectionMode = "ExplicitLevels"
opts_r at cnLevels = (/ .1, .2, .4, .8, 1.6, 3.2, 6.4, \
12.8, 25.6, 51.2/)
opts_r at cnFillColors = (/"White","DarkOliveGreen1", \
"DarkOliveGreen3","Chartreuse", \
"Chartreuse3","Green","ForestGreen", \
"Yellow","Orange","Red","Violet"/)
opts_r at cnInfoLabelOn = False
opts_r at cnConstFLabelOn = False
opts_r at cnFillOn = True
opts_r at vpHeightF = 0.1
opts_r at vpWidthF = 0.9
opts_r at lgLegendOn = False
opts_r at gsnDraw = False
opts_r at gsnFrame = False
opts_r at lbLabelBarOn = False
opts_r at Footer = False
opts_r at NoHeaderFooter =True
; Precipitation Tendencies
; opts_r at SubFieldTitle = "from " + times(it_start) + " to " + times(it_end)
contour_tend = wrf_contour(a,wks, rain_tot_tend,opts_r) ; total (color)
contour_rainc_tend = wrf_contour(a,wks, rainc_tend,opts_r) ; total cumulus precipitation (color)
contour_rainnc_tend = wrf_contour(a,wks, rainnc_tend,opts_r) ; total scale precipitation(color)
delete(opts_r)
; MAKE PLOTS
plot(0) = wrf_map_overlays(a,wks,contour_tend,pltres,mpres)
plot(1) = wrf_map_overlays(a,wks,contour_rainc_tend,pltres,mpres)
plot(2) = wrf_map_overlays(a,wks,contour_rainnc_tend,pltres,mpres)
;>============================================================<
; add China map
;>------------------------------------------------------------<
shp_name1 = "/public/home/huanglei/map/xian.shp"
lnres = True
lnres at gsLineColor = "gray25"
lnres at gsLineThicknessF = 0.5
id = gsn_add_shapefile_polylines(wks,plot(0),shp_name1,lnres)
id = gsn_add_shapefile_polylines(wks,plot(1),shp_name1,lnres)
id = gsn_add_shapefile_polylines(wks,plot(2),shp_name1,lnres)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;creat panel;;;;;;;;;;;;;;;
resP = True
resP at gsnFrame =False
resP at gsnPanelLabelBar = True
resP at gsnPanelBottom = 0.05
resP at gsnPanelTop = 0.95 ; Make sure not too close to
resP at gsnPanelBottom = 0.35 ; edge, so it maximizes better.
resP at tyPolyDrawList = True
gsn_panel(wks,plot,(/3,1/),resP)
; draw(plot) ; This will draw the map and the shapefile outlines.
frame(wks)
end
How can I slove the problem?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160728/77fec3db/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 103149 bytes
Desc: image001.jpg
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160728/77fec3db/attachment-0001.jpg
More information about the ncl-talk
mailing list