<DIV>
<DIV>Hi all:</DIV>
<DIV> I am trying to plot precipitation with wrfout data and try to add .shp on the plot.it says fatal:Variable (plot) is undefined .My NCL version is 6.2.0.</DIV>
<DIV> How can I slove those problem?</DIV>
<DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><SPAN style="LINE-HEIGHT: 24px"><FONT style="LINE-HEIGHT: 30px" size=2> <FONT size=4> </FONT></FONT></SPAN><SPAN style="LINE-HEIGHT: 24px"><FONT size=4> This is my script:</FONT></SPAN></DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><SPAN style="LINE-HEIGHT: 24px">; Example script to produce plots for a WRF real-data run,<BR>; with the ARW coordinate dynamics option.</SPAN></DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><SPAN style="LINE-HEIGHT: 24px">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<BR>load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"<BR>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" <BR>begin<BR>;<BR>; The WRF ARW input file. <BR>; This needs to have a ".nc" appended, so just do it.<BR> a = addfile("/public/home/huanglei/wrfdata/5km/wrfout_d03_2015-08-02_12:00:00.nc","r")</SPAN></DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><SPAN style="LINE-HEIGHT: 24px">; We generate plots, but what kind do we prefer?<BR> ; type = "x11"<BR> type = "pdf"<BR>; type = "ps"<BR>; type = "ncgm"<BR> wks = gsn_open_wks(type,"plt_Precip_5km0802")</SPAN></DIV><SPAN style="LINE-HEIGHT: 24px">
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><BR>; Set some basic resources<BR> res = True<BR> <A href="mailto:res@MainTitle">res@MainTitle</A> = "REAL-TIME WRF"</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> mpres = True ; Map resources<BR> <A href="mailto:mpres@mpOutlineOn">mpres@mpOutlineOn</A> = False ; Turn off map outlines<BR> <A href="mailto:mpres@mpFillOn">mpres@mpFillOn</A> = False ; Turn off map fill<BR> <A href="mailto:mpres@mpGridAndLimbOn">mpres@mpGridAndLimbOn</A> = True<BR> ;res@mpProjection = "Lambert"<BR> pltres = True ; Plot resources<BR> <A href="mailto:pltres@PanelPlot">pltres@PanelPlot</A> = True ; Tells wrf_map_overlays not to remove overlays</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><BR>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">; What times and how many time steps are in the data set?<BR> FirstTime = True<BR> times = wrf_user_getvar(a,"times",-1) ; get all times in the file<BR> ntimes = dimsizes(times) ; number of times in the file</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> do it = 0,24,3 ; TIME LOOP</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> print("Working on time: " + times(it) )<BR> if (FirstTime) then ; Save some times for tracking tendencies<BR> times_sav = times(it)<BR> end if<BR> <A href="mailto:res@TimeLabel">res@TimeLabel</A> = times(it) ; Set Valid time to use on plots</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>; First get the variables we will need </DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><BR> ; Get non-convective, convective and total precipitation of 5km <BR> rain_exp = wrf_user_getvar(a,"RAINNC",it)<BR> rain_con = wrf_user_getvar(a,"RAINC",it)<BR> rain_tot = rain_exp + rain_con<BR> <A href="mailto:rain_tot@description">rain_tot@description</A> = "Total Precipitation"</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><BR> ;calculate the precipitation <BR> if( FirstTime ) then<BR> if ( it .eq. 0 ) then<BR> rain_exp_save = rain_exp<BR> rain_con_save = rain_con<BR> rain_tot_save = rain_tot</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> else<BR> rain_exp_save = wrf_user_getvar(a,"RAINNC",it-1)<BR> rain_con_save = wrf_user_getvar(a,"RAINC",it-1)<BR> rain_tot_save = rain_exp_save + rain_con_save</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><BR> FirstTime = False<BR> times_sav = times(it-1)<BR> end if<BR> end if</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> rain_tot_tend = rain_tot - rain_tot_save</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> <A href="mailto:rain_tot_tend@description">rain_tot_tend@description</A> = "Precipitation of 5km"</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> ; Bookkeeping, just to allow the tendency at the next time step<BR> rain_exp_save = rain_exp<BR> rain_con_save = rain_con<BR> rain_tot_save = rain_tot</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> if( .not. FirstTime ) then ; We will skip the first time</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> ; Plotting options for Precipitation<BR> opts_r = res <BR> <A href="mailto:opts_r@UnitLabel">opts_r@UnitLabel</A> = "mm"<BR> <A href="mailto:opts_r@cnLevelSelectionMode">opts_r@cnLevelSelectionMode</A> = "ExplicitLevels"<BR> <A href="mailto:opts_r@cnLevels">opts_r@cnLevels</A> = (/ .1, .2, .4, .8, 1.6, 3.2, 6.4, \<BR> 12.8, 25.6, 51.2, 102.4/)<BR> <A href="mailto:opts_r@cnFillColors">opts_r@cnFillColors</A> = (/"White","White","DarkOliveGreen1", \<BR> "DarkOliveGreen3","Chartreuse", \<BR> "Chartreuse3","Green","ForestGreen", \<BR> "Yellow","Orange","Red","Violet"/)<BR> <A href="mailto:opts_r@cnInfoLabelOn">opts_r@cnInfoLabelOn</A> = False<BR> <A href="mailto:opts_r@cnConstFLabelOn">opts_r@cnConstFLabelOn</A> = False<BR> <A href="mailto:opts_r@cnFillOn">opts_r@cnFillOn</A> = True<BR> <BR> <A href="mailto:opts_r@gsnDraw">opts_r@gsnDraw</A> = False <BR> <A href="mailto:opts_r@gsnFrame">opts_r@gsnFrame</A> = False<BR> <BR> ; Precipitation Tendencies <BR> <A href="mailto:opts_r@SubFieldTitle">opts_r@SubFieldTitle</A> = "from " + times_sav + " to " + times(it)<BR> <BR> contour_tend = wrf_contour(a,wks, rain_tot_tend,opts_r) ; total (color)</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> delete(opts_r)</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> </DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> ; MAKE PLOTS <BR> plot = wrf_map_overlays(a,wks,contour_tend,pltres,mpres)</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><BR> end if ; END IF FOR SKIPPING FIRST TIME</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">;>============================================================<<BR>; add China map<BR>;>------------------------------------------------------------<</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> <BR> shp_name1 = "/public/home/huanglei/map/diquJie_polyline.shp"</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> lnres = True<BR> <A href="mailto:lnres@gsLineColor">lnres@gsLineColor</A> = "gray25"<BR> <A href="mailto:lnres@gsLineThicknessF">lnres@gsLineThicknessF</A> = 0.5 </DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> id = gsn_add_shapefile_polylines(wks,plot,shp_name1,lnres)<BR> ; shp_name2 = "/home/huanglei/map/China/cnmap/cnhimap.shp"</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">; prres=True<BR> ; <A href="mailto:prres@gsLineThicknessF">prres@gsLineThicknessF</A> = 2.0 <BR>; <A href="mailto:prres@gsLineColor">prres@gsLineColor</A> = "black"<BR> ; plotcn3 = gsn_add_shapefile_polylines(wks,plot,shp_name2,prres)<BR>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> times_sav = times(it)<BR> FirstTime = False<BR> draw(plot) ; This will draw the map and the shapefile outlines.<BR> frame(wks)<BR> end do ; END OF TIME LOOP</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">end<BR></SPAN></DIV></DIV></DIV>