<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 &quot;if&quot; statement that doesn&#39;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 &quot;do&quot; loop you don&#39;t create &quot;plot&quot;, and then you get down to the gsn_add_shapefile_polyline call and it&#39;s trying to attach polylines to a plot object that doesn&#39;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">&lt;<a href="mailto:313695096@qq.com" target="_blank">313695096@qq.com</a>&gt;</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:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;"><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:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;"><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:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;"><span style="LINE-HEIGHT:24px">load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;<br>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl&quot;<br>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl&quot; <br>begin<br>;<br>; The WRF ARW input file.  <br>; This needs to have a &quot;.nc&quot; appended, so just do it.<br>  a = addfile(&quot;/public/home/huanglei/wrfdata/5km/wrfout_d03_2015-08-02_12:00:<a href="http://00.nc" target="_blank">00.nc</a>&quot;,&quot;r&quot;)</span></div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;"><span style="LINE-HEIGHT:24px">; We generate plots, but what kind do we prefer?<br> ; type = &quot;x11&quot;<br> type = &quot;pdf&quot;<br>; type = &quot;ps&quot;<br>; type = &quot;ncgm&quot;<br>  wks = gsn_open_wks(type,&quot;plt_Precip_5km0802&quot;)</span></div><span style="LINE-HEIGHT:24px">
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;"><br>; Set some basic resources<br>  res = True<br>  <a href="mailto:res@MainTitle" target="_blank">res@MainTitle</a> = &quot;REAL-TIME WRF&quot;</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">  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          = &quot;Lambert&quot;<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:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;"><br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">; What times and how many time steps are in the data set?<br>  FirstTime = True<br>  times = wrf_user_getvar(a,&quot;times&quot;,-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:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">  do it = 0,24,3            ; TIME LOOP</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">    print(&quot;Working on time: &quot; + 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:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>; First get the variables we will need        </div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;"><br>  ; Get non-convective, convective and total precipitation of 5km                          <br>    rain_exp = wrf_user_getvar(a,&quot;RAINNC&quot;,it)<br>    rain_con = wrf_user_getvar(a,&quot;RAINC&quot;,it)<br>    rain_tot = rain_exp + rain_con<br>    <a href="mailto:rain_tot@description" target="_blank">rain_tot@description</a> = &quot;Total Precipitation&quot;</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;"><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:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">      else<br>        rain_exp_save = wrf_user_getvar(a,&quot;RAINNC&quot;,it-1)<br>        rain_con_save = wrf_user_getvar(a,&quot;RAINC&quot;,it-1)<br>        rain_tot_save = rain_exp_save + rain_con_save</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;"><br>        FirstTime = False<br>        times_sav = times(it-1)<br>      end if<br>    end if</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">    rain_tot_tend = rain_tot - rain_tot_save</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">    <a href="mailto:rain_tot_tend@description" target="_blank">rain_tot_tend@description</a> = &quot;Precipitation of 5km&quot;</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">  ; 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:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">    if( .not. FirstTime ) then     ; We will skip the first time</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">      ; Plotting options for Precipitation<br>        opts_r = res                        <br>        <a href="mailto:opts_r@UnitLabel" target="_blank">opts_r@UnitLabel</a>            = &quot;mm&quot;<br>        <a href="mailto:opts_r@cnLevelSelectionMode" target="_blank">opts_r@cnLevelSelectionMode</a> = &quot;ExplicitLevels&quot;<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>         = (/&quot;White&quot;,&quot;White&quot;,&quot;DarkOliveGreen1&quot;, \<br>                                        &quot;DarkOliveGreen3&quot;,&quot;Chartreuse&quot;, \<br>                                        &quot;Chartreuse3&quot;,&quot;Green&quot;,&quot;ForestGreen&quot;, \<br>                                        &quot;Yellow&quot;,&quot;Orange&quot;,&quot;Red&quot;,&quot;Violet&quot;/)<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> = &quot;from &quot; + times_sav + &quot; to &quot; + 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:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">        delete(opts_r)</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;"> </div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">      ; MAKE PLOTS                                       <br>         plot = wrf_map_overlays(a,wks,contour_tend,pltres,mpres)</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;"><br>    end if    ; END IF FOR SKIPPING FIRST TIME</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">;&gt;============================================================&lt;<br>;                      add China map<br>;&gt;------------------------------------------------------------&lt;</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">     <br>  shp_name1    = &quot;/public/home/huanglei/map/diquJie_polyline.shp&quot;</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">  lnres                  = True<br>  <a href="mailto:lnres@gsLineColor" target="_blank">lnres@gsLineColor</a>      = &quot;gray25&quot;<br>  <a href="mailto:lnres@gsLineThicknessF" target="_blank">lnres@gsLineThicknessF</a> = 0.5   </div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;"> id = gsn_add_shapefile_polylines(wks,plot,shp_name1,lnres)<br> ; shp_name2    = &quot;/home/huanglei/map/China/cnmap/cnhimap.shp&quot;</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">;  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> = &quot;black&quot;<br> ; plotcn3 = gsn_add_shapefile_polylines(wks,plot,shp_name2,prres)<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div>
<div style="LINE-HEIGHT:23px;FONT-FAMILY:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">    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:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;">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>