<div dir="ltr"><div class="gmail_default" style="font-size:small">For the section that calls wrf_contour and wrf_map_overlays, why is it inside an "if" statement that doesn't get executed if FirstTime is True? </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">It looks like the first time through the "do" loop you don't create "plot", and then you get down to the gsn_add_shapefile_polyline call and it's trying to attach polylines to a plot object that doesn't exist yet.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 2, 2015 at 7:24 PM, grace <span dir="ltr"><<a href="mailto:313695096@qq.com" target="_blank">313695096@qq.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
<div>Hi all:</div>
<div> I am trying to plot precipitation with wrfout data and try to add .shp on the <a href="http://plot.it" target="_blank">plot.it</a> 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:<a href="http://00.nc" target="_blank">00.nc</a>","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" target="_blank">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" target="_blank">mpres@mpOutlineOn</a> = False ; Turn off map outlines<br> <a href="mailto:mpres@mpFillOn" target="_blank">mpres@mpFillOn</a> = False ; Turn off map fill<br> <a href="mailto:mpres@mpGridAndLimbOn" target="_blank">mpres@mpGridAndLimbOn</a> = True<br> ;res@mpProjection = "Lambert"<br> pltres = True ; Plot resources<br> <a href="mailto:pltres@PanelPlot" target="_blank">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" target="_blank">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" target="_blank">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" target="_blank">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" target="_blank">opts_r@UnitLabel</a> = "mm"<br> <a href="mailto:opts_r@cnLevelSelectionMode" target="_blank">opts_r@cnLevelSelectionMode</a> = "ExplicitLevels"<br> <a href="mailto:opts_r@cnLevels" target="_blank">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" target="_blank">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" target="_blank">opts_r@cnInfoLabelOn</a> = False<br> <a href="mailto:opts_r@cnConstFLabelOn" target="_blank">opts_r@cnConstFLabelOn</a> = False<br> <a href="mailto:opts_r@cnFillOn" target="_blank">opts_r@cnFillOn</a> = True<br> <br> <a href="mailto:opts_r@gsnDraw" target="_blank">opts_r@gsnDraw</a> = False <br> <a href="mailto:opts_r@gsnFrame" target="_blank">opts_r@gsnFrame</a> = False<br> <br> ; Precipitation Tendencies <br> <a href="mailto:opts_r@SubFieldTitle" target="_blank">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" target="_blank">lnres@gsLineColor</a> = "gray25"<br> <a href="mailto:lnres@gsLineThicknessF" target="_blank">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" target="_blank">prres@gsLineThicknessF</a> = 2.0 <br>; <a href="mailto:prres@gsLineColor" target="_blank">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></div></span></div></div><br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>