- 积分
- 1502
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-4-12
- 最后登录
- 1970-1-1
|
NCL
系统平台: |
|
问题截图: |
- |
问题概况: |
添加shp底图出错fatal:Variable (plot) is undefined,可是我之前明明已经
plot = wrf_map_overlays(a5,wks,contour_tend,pltres,mpres)
了,不知道为啥,请各位指点啊。找了半天没找出啥错误 |
我看过提问的智慧: |
看过 |
自己思考时长(天): |
3 |
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
添加shp底图出错fatal:Variable (plot) is undefined,可是我之前明明已经
plot = wrf_map_overlays(a5,wks,contour_tend,pltres,mpres)
了,不知道为啥,请各位指点啊。找了半天没找出啥错误
这是我的脚本:
; Example script to produce plots for a WRF real-data run,
; with the ARW coordinate dynamics option.
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/wrfdata/5km/wrfout_d03_2015-08-02_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_5km0802")
; Set some basic resources
res = True
res@MainTitle = "REAL-TIME WRF"
mpres = True ; Map resources
mpres@mpOutlineOn = False ; Turn off map outlines
mpres@mpFillOn = False ; Turn off map fill
mpres@mpGridAndLimbOn = True
;res@mpProjection = "Lambert"
pltres = True ; Plot resources
pltres@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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
do it = 0,24,3 ; TIME LOOP
print("Working on time: " + times(it) )
if (FirstTime) then ; Save some times for tracking tendencies
times_sav = times(it)
end if
res@TimeLabel = times(it) ; Set Valid time to use on plots
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; First get the variables we will need
; Get non-convective, convective and total precipitation of 5km
rain_exp = wrf_user_getvar(a,"RAINNC",it)
rain_con = wrf_user_getvar(a,"RAINC",it)
rain_tot = rain_exp + rain_con
rain_tot@description = "Total Precipitation"
;calculate the precipitation
if( FirstTime ) then
if ( it .eq. 0 ) then
rain_exp_save = rain_exp
rain_con_save = rain_con
rain_tot_save = rain_tot
else
rain_exp_save = wrf_user_getvar(a,"RAINNC",it-1)
rain_con_save = wrf_user_getvar(a,"RAINC",it-1)
rain_tot_save = rain_exp_save + rain_con_save
FirstTime = False
times_sav = times(it-1)
end if
end if
rain_tot_tend = rain_tot - rain_tot_save
rain_tot_tend@description = "Precipitation of 5km"
; Bookkeeping, just to allow the tendency at the next time step
rain_exp_save = rain_exp
rain_con_save = rain_con
rain_tot_save = rain_tot
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if( .not. FirstTime ) then ; We will skip the first time
; Plotting options for Precipitation
opts_r = res
opts_r@UnitLabel = "mm"
opts_r@cnLevelSelectionMode = "ExplicitLevels"
opts_r@cnLevels = (/ .1, .2, .4, .8, 1.6, 3.2, 6.4, \
12.8, 25.6, 51.2, 102.4/)
opts_r@cnFillColors = (/"White","White","DarkOliveGreen1", \
"DarkOliveGreen3","Chartreuse", \
"Chartreuse3","Green","ForestGreen", \
"Yellow","Orange","Red","Violet"/)
opts_r@cnInfoLabelOn = False
opts_r@cnConstFLabelOn = False
opts_r@cnFillOn = True
opts_r@gsnDraw = False
opts_r@gsnFrame = False
; Precipitation Tendencies
opts_r@SubFieldTitle = "from " + times_sav + " to " + times(it)
contour_tend = wrf_contour(a,wks, rain_tot_tend,opts_r) ; total (color)
delete(opts_r)
; MAKE PLOTS
plot = wrf_map_overlays(a,wks,contour_tend,pltres,mpres)
end if ; END IF FOR SKIPPING FIRST TIME
;>============================================================<
; add China map
;>------------------------------------------------------------<
shp_name1 = "/public/home/huanglei/map/diquJie_polyline.shp"
lnres = True
lnres@gsLineColor = "gray25"
lnres@gsLineThicknessF = 0.5
id = gsn_add_shapefile_polylines(wks,plot,shp_name1,lnres)
; shp_name2 = "/home/huanglei/map/China/cnmap/cnhimap.shp"
; prres=True
; prres@gsLineThicknessF = 2.0
; prres@gsLineColor = "black"
; plotcn3 = gsn_add_shapefile_polylines(wks,plot,shp_name2,prres)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
times_sav = times(it)
FirstTime = False
draw(plot) ; This will draw the map and the shapefile outlines.
frame(wks)
end do ; END OF TIME LOOP
end
|
|