<div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Hi<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">I am trying to panel my WRF domains: domain1 and domain3 which have very different aspect ratios and sizes. Currently using the following script I'm able to panel them together but not change their size. I tried using vp resources but without success. Can you please let me know what changes I make to this script to make the D03 same in height as D01 without changing aspect ratios?<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Here's the script:<br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><span style="font-family:tahoma,sans-serif"><font size="1">; PANELPLOT OF WRF-CHEM D01 AND D03 PM2.5 CONCENTRATIONS CONTOUR MAPS ALONG WITH OBSERVATIONS<br></font></span></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><span style="font-family:tahoma,sans-serif"><font size="1"><span style="font-family:verdana,sans-serif">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"<br><br>;----------------------------------------------------------------------<br>; Procedure to attach colored markers to an NCL map, given 1D<br>; data, and lat/lon arrays, a set of levels, and a color map.<br>;----------------------------------------------------------------------<br>procedure add_obs_markers_to_map(wks,plot,levels,colormap,data_1d,lat_1d,lon_1d)<br>local mkres, nlevels, colors, nlevels, n, ii<br>begin<br><br>;---Set resources for the markers<br>  mkres = True<br>  mkres@gsMarkerIndex = 16<br>  mkres@gsMarkerSizeF = 0.0035<br>; Based on the levels we had for the contour plot and the colormap used,<br>; get an array of colors that span the colormap. This uses the same<br>; algorithm that the contour used, so the colors will be identical.<br>;<br>  nlevels = dimsizes(levels)<br>  colors = span_color_rgba(colormap,nlevels+1)   ; Need one more color than number of levels<br><br>;<br>; Loop through each level, gather all the data values in the given level<br>; range, and add colored markers to the existing map.<br>;<br>  do n=0,nlevels<br><br>;---These "if" statements are how color contours are handled in NCL.<br>    if(n.eq.0) then<br>      ii := ind(data_1d.lt.levels(n))<br>    else if(n.eq.nlevels) then<br>      ii := ind(data_1d.ge.levels(n-1))<br>    else<br>      ii := ind(data_1d.ge.levels(n-1).and.data_1d.lt.levels(n))<br>    end if<br>    end if<br>    if(any(ismissing(ii))) then<br>      continue<br>    end if<br><br>;---Add the markers<br>    mkres@gsMarkerColor = colors(n,:)    ; colors is an N x 4 array<br>    plot@$unique_string("markers")$ = gsn_add_polymarker(wks,plot,lon_1d(ii),lat_1d(ii),mkres)<br>  end do<br>end<br><br>;----------------------------------------------------------------------<br>; Main code<br>;----------------------------------------------------------------------<br>begin<br><br>;---Open WRF output file and read data<br><br>DATADir = "/data2/tabish/control-run-so4-ECMWF/"<br>FILES = systemfunc (" ls -1 " + DATADir + "wrfout_d01_2014-10* ")<br>numFILES = dimsizes(FILES)<br><br>s=1<br>a = addfile(FILES(0)+".nc","r"); THIS IS JUST FOR INITIALIZATION OF PM25 ARRAY, IT WILL BE SUBSTRACTED FROM THE SUM IN THE END<br>pm25init =  a->PM2_5_DRY(15,0,:,:)<br>pm25sum =  pm25init<br>times = wrf_user_getvar(a,"times",-1)  ; get all times in the file<br>ntimes = dimsizes(times)<br>do it = 16,ntimes-1,1             ; TIME LOOP<br>    s=s+1<br>    print("Working on time: " + times(it) )<br>    pm25sum = pm25sum + a->PM2_5_DRY(it,0,:,:)<br>end do ; END OF TIME LOOP<br><br>do ifil = 1,numFILES-2             ; FILE LOOP<br>  a = addfile(FILES(ifil)+".nc","r")   ; Open the next file<br>  times = wrf_user_getvar(a,"times",-1)  ; get all times in the file<br>  ntimes = dimsizes(times)<br>  do it = 0,ntimes-1,1             ; TIME LOOP<br>    s=s+1<br>    print("Working on time: " + times(it) )<br>    pm25sum = pm25sum + a->PM2_5_DRY(it,0,:,:)<br>  end do ; END OF TIME LOOP<br>end do<br><br>a = addfile(FILES(numFILES-1)+".nc","r")   ; Open the next file<br>  times = wrf_user_getvar(a,"times",-1)  ; get all times in the file<br>  ntimes = dimsizes(times)<br>  do it = 0,16,1             ; TIME LOOP<br>    s=s+1<br>    print("Working on time: " + times(it) )<br>    pm25sum = pm25sum + a->PM2_5_DRY(it,0,:,:)<br>  end do ; END OF TIME LOOP<br><br>pm25_avg=  pm25sum/s<br>pm25_avg@description = "PM2.5 conc in ug/m3"<br><br>  lat2d = wrf_user_getvar(a,"XLAT",it)   ; latitude/longitude<br>  lon2d = wrf_user_getvar(a,"XLONG",it)<br><br>  pm25_avg@lat2d = lat2d    ; for plotting<br>  pm25_avg@lon2d = lon2d<br>;---Will use this for contours and filled markers<br>  colormap = "BlAqGrYeOrReVi200"<br>  ;levels   = ispan(0,180,9)<br>  levels   = (/0,2,5,10,15,20,25,30,35,40,45,50,55,60,65,70,80,90,100,110,160,200/)<br><br>  wks = gsn_open_wks("x11","wrf_obs_d01-d03_pm25")<br><br>;---Common resources shared by both contour plot and marker plot<br>  res                        = True<br>  res@gsnMaximize            = True<br>  res@gsnLeftString          = ""<br>  res@gsnRightString         = ""<br><br>  res@mpDataBaseVersion      = "MediumRes"<br> ; res@mpFillOn               = False<br> ; res@mpMinLatF              = min(pm25_avg@lat2d)<br> ; res@mpMaxLatF              = max(pm25_avg@lat2d)<br> ; res@mpMinLonF              = min(pm25_avg@lon2d)<br> ; res@mpMaxLonF              = max(pm25_avg@lon2d)<br> ; res@pmTickMarkDisplayMode  = "Always"      ; better map tickmarks<br><br> res@mpLimitMode       = "Corners"            ; choose range of map<br> res@mpLeftCornerLatF  = 51.8<br> res@mpLeftCornerLonF  = 82.6<br> res@mpRightCornerLatF = 22.66<br> res@mpRightCornerLonF = 130.499<br> res@mpProjection         = "LambertConformal"<br> res@mpLambertParallel1F = 20<br> res@mpLambertParallel2F = 50<br> res@mpLambertMeridianF  = 110<br><br><br><br>;---Resources for filled contour plot<br>  cnres                      = res<br>  cnres@cnFillOn             = True<br>  cnres@cnLevelSelectionMode = "ExplicitLevels"<br>  cnres@cnLevels             = levels<br>  cnres@cnFillPalette        = colormap<br>  cnres@cnLinesOn            = False<br>  cnres@cnLineLabelsOn       = False<br>  cnres@lbLabelBarOn         = False   ; will add in panel later<br>  cnres@pmTitleZone          = 2       ; move title down<br>  cnres@gsnAddCyclic         = False<br>  cnres@mpLimitMode       = "Corners"            ; choose range of map<br>  cnres@mpLeftCornerLatF  = 51.8<br>  cnres@mpLeftCornerLonF  = 82.6<br>  cnres@mpRightCornerLatF = 22.66<br>  cnres@mpRightCornerLonF = 130.499<br>  cnres@mpProjection         = "LambertConformal"<br>  cnres@mpLambertParallel1F = 20<br>  cnres@mpLambertParallel2F = 50<br>  cnres@mpLambertMeridianF  = 110<br><br>  cnres@mpFillOn                    =  True<br>  cnres@mpOutlineDrawOrder          = "PostDraw"<br>  cnres@mpFillDrawOrder             = "PreDraw"<br> ; cnres@mpOutlineBoundarySets       = "National"<br>  cnres@mpOutlineBoundarySets       = "Allboundaries"<br>  cnres@mpUSStateLineDashPattern    = 2<br>  cnres@mpOutlineOn           = True<br>  cnres@mpDataBaseVersion        = "MediumRes"<br>  cnres@mpDataSetName            = "Earth..4"      ; U.S. counties<br>  ;cnres@mpGridAndLimbOn = True<br>  ;cnres@mpGridLineColor = "Grey"<br>  cnres@mpFillColors = (/"transparent","transparent","gray","transparent"/)<br>  cnres@pmTickMarkDisplayMode = "Always"<br>  cnres@tiMainString = "Domain 1 @ 27km"<br>  cnres@tiDeltaF = 3.3<br>  cnres@tfDoNDCOverlay = True<br><br>  cnres@gsnDraw  = False                          ; don't draw<br>  cnres@gsnFrame = False                          ; don't advance frame<br><br>; cnres@vpWidthF         = 0.40<br> cnres@vpHeightF        = 0.20<br><br>;---Create smooth contour plot<br>  plot_wrf_d01 = gsn_csm_contour_map(wks,pm25_avg,cnres)<br><br><br>delete(pm25init)<br>delete(pm25sum)<br>delete(pm25_avg)<br>delete(s)<br>delete(lat2d)<br>delete(lon2d)<br>;----------------------------------------------------------------------<br>; Recreate similar plot, but by using filled markers drawn over a map.<br>;----------------------------------------------------------------------<br> fname = "surfacedata_12-31_Octmean_improved_nomissingval.txt"<br>  lines = asciiread(fname,-1,"string")<br>  lon = tofloat(str_get_field(lines(:),2," "))<br>  lat = tofloat(str_get_field(lines(:),3," "))<br>  pm25 = tofloat(str_get_field(lines(:),4," "))<br><br><br>;*****************************************<br>; add black circles over obs data<br>;*****************************************<br>  polyres               = True          ; poly marker mods desired<br>  polyres@gsMarkerIndex = 4            ; choose circle as polymarker<br>  polyres@gsMarkerSizeF = 5           ; select size to avoid streaking<br>  polyres@gsMarkerColor = (/"black"/)   ; choose color<br>  polyres@gsMarkerThicknessF  = 2.0<br>  tabish1=gsn_add_polymarker(wks,plot_wrf_d01,lon,lat,polyres)  ; draw polymarkers<br><br>;---Add colored markers to the map<br>  add_obs_markers_to_map(wks,plot_wrf_d01,levels,colormap,pm25,lat,lon)<br><br>;  draw(plot_wrf)<br>;  frame(wks)<br><br>;***********************************************<br>; NOW REPEATING THE SAME ROUTINE FOR D03<br>;***********************************************<br><br><br>  DATADir = "/data2/tabish/control-run-so4-ECMWF/"<br>FILES = systemfunc (" ls -1 " + DATADir + "wrfout_d03_2014-10* ")<br>numFILES = dimsizes(FILES)<br><br>s=1<br>a = addfile(FILES(0)+".nc","r"); THIS IS JUST FOR INITIALIZATION OF PM25 ARRAY, IT WILL BE SUBSTRACTED FROM THE SUM IN THE END<br>pm25init =  a->PM2_5_DRY(15,0,:,:)<br>pm25sum =  pm25init<br>times = wrf_user_getvar(a,"times",-1)  ; get all times in the file<br>ntimes = dimsizes(times)<br>do it = 16,ntimes-1,1             ; TIME LOOP<br>    s=s+1<br>    print("Working on time: " + times(it) )<br>    pm25sum = pm25sum + a->PM2_5_DRY(it,0,:,:)<br>end do ; END OF TIME LOOP<br><br>do ifil = 1,numFILES-2             ; FILE LOOP<br>  a = addfile(FILES(ifil)+".nc","r")   ; Open the next file<br>  times = wrf_user_getvar(a,"times",-1)  ; get all times in the file<br>  ntimes = dimsizes(times)<br>  do it = 0,ntimes-1,1             ; TIME LOOP<br>    s=s+1<br>    print("Working on time: " + times(it) )<br>    pm25sum = pm25sum + a->PM2_5_DRY(it,0,:,:)<br>  end do ; END OF TIME LOOP<br>end do<br>pm25_avg= pm25sum/s<br>;pm25_avg@description = "NO2 conc in ppbv"<br><br>  lat2d = wrf_user_getvar(a,"XLAT",it)   ; latitude/longitude<br>  lon2d = wrf_user_getvar(a,"XLONG",it)<br><br>  pm25_avg@lat2d = lat2d    ; for plotting<br>  pm25_avg@lon2d = lon2d<br> res@mpLimitMode       = "Corners"            ; choose range of map<br> res@mpLeftCornerLatF  = 36.05806<br> res@mpLeftCornerLonF  = 113.3356<br> res@mpRightCornerLatF = 42.4514<br> res@mpRightCornerLonF = 120.2583<br>  cnres@mpLimitMode       = "Corners"            ; choose range of map<br>  cnres@mpLeftCornerLatF  = 36.05806<br>  cnres@mpLeftCornerLonF  = 113.3356<br>  cnres@mpRightCornerLatF = 42.4514<br>  cnres@mpRightCornerLonF = 120.2583<br>cnres@tiMainString = "Domain 3 @ 3km"<br>cnres@vpKeepAspect = True<br> cnres@vpHeightF        = 0.20<br><br>;---Create smooth contour plot<br>  plot_wrf_d03 = gsn_csm_contour_map(wks,pm25_avg,cnres)<br>;*****************************************<br>; add black circles over obs data<br>;*****************************************<br>  polyres               = True          ; poly marker mods desired<br>  polyres@gsMarkerIndex = 4            ; choose circle as polymarker<br>  polyres@gsMarkerSizeF = 5           ; select size to avoid streaking<br>  polyres@gsMarkerColor = (/"black"/)   ; choose color<br>  polyres@gsMarkerThicknessF  = 2.0<br>tabish3=gsn_add_polymarker(wks,plot_wrf_d03,lon,lat,polyres)  ; draw polymarkers<br><br>;---Add colored markers to the map<br>  add_obs_markers_to_map(wks,plot_wrf_d03,levels,colormap,pm25,lat,lon)<br><br><br>;---Panel both plots for comparison.<br>  pres                    = True<br>  pres@gsnMaximize        = True<br>  pres@gsnPanelLabelBar   = True<br>  pres@pmLabelBarWidthF   = 0.8<br>  pres@lbLabelFontHeightF = 0.01<br>  pres@gsnFrame = False<br>  pres@gsnPanelBottom   = 0.05                   ; add space at bottom<br>  gsn_panel(wks,(/plot_wrf_d01,plot_wrf_d03/),(/1,2/),pres)<br><br>; Draw a text string at the bottom<br>  txres               = True<br>  txres@txFontHeightF = 0.012<br>  gsn_text_ndc(wks,"PM2.5 in ug/m3",0.5,0.28,txres)<br>  frame(wks)<br></span><span style="font-family:comic sans ms,sans-serif"><span style="font-family:verdana,sans-serif">; Maximize plots in frame.<br>; psres = True<br>; maximize_output(wks,psres)  ; calls draw and frame for you</span><br><br><br>end</span></font></span><br>        <br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Your help will be greatly appreciated.<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Thanks<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Tabish<br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">                                                                                     <br clear="all"></div><div><div class="gmail_signature"><div dir="ltr"><div><div><font size="1"><span style="font-family:tahoma,sans-serif">Tabish U Ansari<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">PhD student, Lancaster Environment Center<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">Lancaster Univeristy<br> <span>Bailrigg</span>, <span>Lancaster</span>, <br><span>LA1 4YW</span>, <span>United Kingdom</span></span></font><br></div></div></div>
</div>