<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]--></head><body><div class="yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div>I hope someone can assist me where to put my shapefile drawing function so that it be attached to the plot. Currently I get my plot followed by the shapefile plotted separately.</div><div>I have ready the solution by Maxine to this here <a href="http://mailman.ucar.edu/pipermail/ncl-talk/2016-April/005561.html" rel="nofollow" target="_blank" class="enhancr_card_6946424738">[ncl-talk] I can't manage to create a plot with multiple lines on it, each line having different x and y values. Attribute assignment type issue,</a> were he solved his proble by:</div><div><span><pre> either both "delete(res)" and "delete(wks)" before each plot
- or a new "res" (like "res3" for a 3rd plot) and a new "wks" (like "wks3" for a 3rd plot) for</pre></span><div>I have tried these suggestions, but really not clear how to do it.</div><div>The wrf_pressureLevel1.ncl script I use is given below.</div><div><br></div><div>Help will be appreciated</div><div>;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;;<br></div><div><span>load "./Shapefiles/shapefile_utils.ncl"<br><br>begin<br>;---Open WRF output file.<br> dir = "./"<br> filename = "wrfout_d01_2019-03-28_00:00:00"<br> a = addfile(dir + filename,"r")<br><br>; 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_PressureLevel1")<br><br>; Set some Basic Plot options<br> res = True<br><br> res@gsnDraw = False ; don't draw<br> res@gsnFrame = False ; don't advance frame<br><br>; res@MainTitle = "REAL-TIME WRF"<br><br> res@gsnMaximize = True ; Maximize plot in frame.<br><br> pltres = True<br> mpres = True ; Plot options desired.<br></span><div><span> mpres@mpGeophysicalLineColor = "Black"</span></div><span> mpres@mpNationalLineColor = "Black"<br> mpres@mpInlandWaterFillColor = "Blue"<br> mpres@mpGridLineColor = "Black"<br> mpres@mpLimbLineColor = "Black"<br> mpres@mpPerimLineColor = "Black"<br> mpres@mpGeophysicalLineThicknessF = 2.0<br> mpres@mpGridLineThicknessF = 2.0<br> <br> mpres@mpDataBaseVersion = "MediumRes" ; use finer database<br> mpres@mpDataSetName = "Earth..4"<br> mpres@mpOutlineBoundarySets = "AllBoundaries"<br> mpres@mpOutlineOn = True<br> mpres@mpNationalLineThicknessF = 3.0 ; turn on country boundaries<br> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br><br> ; define shapefiles<br> shp_filename = ("Shapefiles/Zambia/ZMB_adm1.shp")<br><br> ; set shapefile resources<br> shpres = True<br> shpres@gsLineThicknessF = 3.9 ; increase line thickness<br> shpres@gsLineColor = "Purple" ; line colorgsLineThicknessF<br> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br><br>; What times and how many time steps are in the data set?<br> times = wrf_user_getvar(a,"times",-1) ; get all times in the file<br> ntimes = dimsizes(times) ; number of times in the file<br><br>; The specific pressure levels that we want the data interpolated to.<br> pressure_levels = (/ 850., 700., 500., 300./) ; pressure levels to plot<br> nlevels = dimsizes(pressure_levels) ; number of pressure levels<br><br> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br><br> do it = 0,ntimes-1,2 ; TIME LOOP<br><br> print("Working on time: " + times(it) )<br> res@TimeLabel = times(it) ; Set Valid time to use on plots<br><br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>; First get the variables we will need <br><br> tc = wrf_user_getvar(a,"tc",it) ; T in C<br> u = wrf_user_getvar(a,"ua",it) ; u averaged to mass points<br> v = wrf_user_getvar(a,"va",it) ; v averaged to mass points<br> p = wrf_user_getvar(a, "pressure",it) ; pressure is our vertical coordinate<br> z = wrf_user_getvar(a, "z",it) ; grid point height<br> rh = wrf_user_getvar(a,"rh",it) ; relative humidity<br><br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>;<br>; printVarSummary(t)<br><br> wks = gsn_open_wks("x11","contour_wrf") ; Open X11 window<br> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br> do level = 0,nlevels-1 ; LOOP OVER LEVELS<br><br> pressure = pressure_levels(level)<br><br> tc_plane = wrf_user_intrp3d(tc,p,"h",pressure,0.,False)<br> z_plane = wrf_user_intrp3d( z,p,"h",pressure,0.,False)<br> rh_plane = wrf_user_intrp3d(rh,p,"h",pressure,0.,False)<br> u_plane = wrf_user_intrp3d( u,p,"h",pressure,0.,False)<br> v_plane = wrf_user_intrp3d( v,p,"h",pressure,0.,False)<br><br> spd = (u_plane*u_plane + v_plane*v_plane)^(0.5) ; m/sec<br> spd@description = "Wind Speed"<br> spd@units = "m/s"<br> u_plane = u_plane*1.94386 ; kts<br> v_plane = v_plane*1.94386 ; kts<br> u_plane@units = "kts"<br> v_plane@units = "kts"<br><br> res@gsnDraw = False ; don't draw<br> res@gsnFrame = False ; don't advance frame<br><br> ; Plotting options for T <br> opts = res <br> opts@cnLineColor = "Red"<br> opts@ContourParameters = (/ 5.0 /)<br> opts@cnInfoLabelOrthogonalPosF = 0.07 ; offset second label information<br> opts@gsnContourLineThicknessesScale = 2.0<br> contour_tc = wrf_contour(a,wks,tc_plane,opts)<br> delete(opts)<br><br><br> ; Plotting options for RH <br> opts = res <br> opts@cnFillOn = True <br> opts@pmLabelBarOrthogonalPosF = -0.1<br> opts@ContourParameters = (/ 10., 90., 10./)<br> opts@cnFillColors = (/"White","White","White", \<br> "White","Chartreuse","Green",\<br> "Green3","Green4", \<br> "ForestGreen","PaleGreen4"/)<br> contour_rh = wrf_contour(a,wks,rh_plane,opts)<br> delete(opts)<br><br><br> ; Plotting options for Wind Speed <br> opts = res <br> opts@cnLineColor = "MediumSeaGreen"<br> opts@ContourParameters = (/ 10. /)<br> opts@cnInfoLabelOrthogonalPosF = 0.07 ; offset second label information<br> opts@gsnContourLineThicknessesScale = 3.0<br> contour_spd = wrf_contour(a,wks,spd,opts)<br> delete(opts)<br><br><br> ; Plotting options for Wind Vectors <br> opts = res <br> opts@FieldTitle = "Wind" ; overwrite Field Title<br> opts@NumVectors = 47 ; wind barb density<br> vector = wrf_vector(a,wks,u_plane,v_plane,opts)<br> delete(opts)<br><br><br> ; Plotting options for Geopotential Heigh<br> opts_z = res <br> opts_z@cnLineColor = "Blue"<br> opts_z@gsnContourLineThicknessesScale = 3.0<br><br><br> ; MAKE PLOTS <br><br> if ( pressure .eq. 850 ) then ; plot temp, rh, height, wind barbs<br> opts_z@ContourParameters = (/ 20.0 /)<br> contour_height = wrf_contour(a,wks,z_plane,opts_z)<br> plot = wrf_map_overlays(a,wks,(/contour_rh,contour_tc,contour_height, \<br> vector/),pltres,mpres)<br> end if<br><br> if ( pressure .eq. 700 ) then ; plot temp, height, wind barbs<br> opts_z@ContourParameters = (/ 30.0 /)<br> contour_height = wrf_contour(a,wks, z_plane,opts_z)<br> plot = wrf_map_overlays(a,wks,(/contour_tc,contour_height, \<br> vector/),pltres,mpres)<br> end if<br><br> if ( pressure .eq. 500 ) then ; plot temp, height, wind barbs<br> opts_z@ContourParameters = (/ 60.0 /)<br> contour_height = wrf_contour(a,wks, z_plane,opts_z)<br> plot = wrf_map_overlays(a,wks,(/contour_tc,contour_height, \<br> vector/),pltres,mpres)<br> end if<br><br> if ( pressure .eq. 300 ) then ; plot windspeed, height, wind barbs<br> opts_z@ContourParameters = (/ 60.0 /)<br> contour_height = wrf_contour(a,wks, z_plane,opts_z)<br> plot = wrf_map_overlays(a,wks,(/contour_spd,contour_height, \<br> vector/),pltres,mpres)<br> end if<br> delete(opts_z)<br><br> shp= gsn_add_shapefile_polylines(wks,plot,shp_filename,shpres)<br><br> draw(plot)<br> frame(wks)<br><br> end do ; END OF LEVEL LOOP<br> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br> end do ; END OF TIME LOOP<br><br>end<br><br></span><br></div><div><br></div></div><div><br></div><div id="ydpbc983f47enhancr_card_6946424738" class="ydpbc983f47yahoo-link-enhancr-card ydpbc983f47yahoo-link-enhancr-not-allow-cover ydpbc983f47ymail-preserve-class ydpbc983f47ymail-preserve-style" style="max-width:400px;font-family:"Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif" data-url="http://mailman.ucar.edu/pipermail/ncl-talk/2016-April/005561.html" data-type="YENHANCER" data-size="MEDIUM" contenteditable="false"><a href="http://mailman.ucar.edu/pipermail/ncl-talk/2016-April/005561.html" style="text-decoration:none !important;color:#000 !important" class="ydpbc983f47yahoo-enhancr-cardlink" rel="nofollow" target="_blank"><table class="ydpbc983f47card-wrapper ydpbc983f47yahoo-ignore-table" style="max-width:400px" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="400"><table class="ydpbc983f47card ydpbc983f47yahoo-ignore-table" style="max-width:400px;border-width:1px;border-style:solid;border-color:rgb(224, 228, 233);border-radius:2px" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td><table class="ydpbc983f47card-info ydpbc983f47yahoo-ignore-table" style="background-color: rgb(255, 255, 255); background-repeat: repeat; background-attachment: scroll; background-image: none; background-size: auto; position: relative; z-index: 2; width: 100%; max-width: 400px; border-radius: 0px 0px 2px 2px; border-top: 1px solid rgb(224, 228, 233);" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td style="background-color:#ffffff;padding:16px 0 16px 12px;vertical-align:top;border-radius:0 0 0 2px"></td><td style="vertical-align:middle;padding:12px 24px 16px 12px;width:99%;font-family:"Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;border-radius:0 0 2px 0"><h2 class="ydpbc983f47card-title" style="font-size:14px;line-height:19px;margin:0 0 6px 0;font-family:"Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;word-break:break-word;color:#26282a">[ncl-talk] I can't manage to create a plot with multiple lines on it, ea...</h2><p class="ydpbc983f47card-description" style="font-size:12px;line-height:16px;margin:0;color:#979ba7;word-break:break-word"></p></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></a></div><div><br></div><div><br></div></div></body></html>