Re: Resizing the last plot in a panel - First 3 plots are CALIPSO, the last plot is WRF

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Jun 12 2014 - 12:29:19 MDT

Hi Mike,

Can you provide the data file(s) so I can run this script? It's hard to
debug a script this complex without being able to run it.

Maybe instead of calling maximize_output, you can try just drawing the plot
yourself and advancing the frame:

draw(plot(0))
frame(wks)

--Mary




On Wed, Jun 11, 2014 at 3:02 PM, James Madden <jmmadden@alaska.edu> wrote:

> Hello,
>
> I am putting together comparisons between CALIPSO products and WRF, and I
> am working on a panel.
>
> The first three plots come from CALIPSO, and I do not have any problems
> with those plots. However, when I try to add the WRF plot to the panel,
> the WRF plot becomes so incredibly huge that it lessens the quality of the
> other plots. They should all be the same size. The WRF plot is indeed
> attached to the above CALIPSO plots, but the only hindrance is its large
> size.
>
> I am not sure what is incorrect; I have added vpWidth and vpHeightF to the
> main resources, and have reiterated those statements in the WRF plot
> resources. I am just not sure of where it's going wrong.
>
> I have attached a picture of what's happening, and the code. The relevant
> material in the code is near the end. You will see the relevant parts
> following "ADD RESOURCES FOR WRF."
>
> Thank you very much,
> Mike
>
> ;**************************************************
> ; This will plot CALIPSO data for your domain
> ;**************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/ut_string.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> load "/import/u/u1/uaf/jmmadden/CALIPSO/color_map.ncl"
> ;**************************************************
> begin
>
> ; --- Read Calipso Data ------------;
>
> ; July 7th or July 27th?
> ; f =
> addfile("/import/archive/u1/uaf/jmmadden/WILDFIRE2009/CALIPSOdata/SUBSETS/CAL_LID_L1-ValStage1-V3-01.2009-07-07T12-22-31ZD.hdf_Subset.hdf","r")
> f =
> addfile("/import/archive/u1/uaf/jmmadden/WILDFIRE2009/CALIPSOdata/SUBSETS/CAL_LID_L1-ValStage1-V3-01.2009-07-27T11-56-14ZD.hdf_Subset.hdf","r")
>
> wks = gsn_open_wks("x11","PAB532_vert")
>
> ;;;; READ WRF OUTPUT FILE AND INCLUDE ALL CASES
>
> a =
> addfile("/import/archive/u1/uaf/jmmadden/WILDFIRE2009/WRFouts/wrfout_d01_2009-07-27_00:00:
> 00.nc","r")
>
>
> ;;;; SET THE HOUR IN WHICH THE WRF CROSS SECTION OCCURS
> hour = 12
>
>
> ;;;; GET BACKSCATTER, LATITUDE, LONGITUDE, AND WRF DATA, AND FORM
> DEPOLARIZATION DATA
>
> back1 = f->Total_Attenuated_Backscatter_532
> dims = getvardims(back1)
>
> ;reverse the vertical array
> back1 = back1(:,::-1)
>
> ; Reorder using string dimension names
> back = back1($dims(1)$|:,$dims(0)$|:)
> back@_FillValue = -9999
> back@units = "";"km~S~-1~NN~ sr~S~-1~NN~"
>
> ; Get the lat and lon arrays for the x-axis
> lat = (/f->Latitude/)
> lon = (/f->Longitude/)
> xlabel = sprintf("%.2f",lat)+"~C~"+sprintf("%.2f",lon)
>
> ; WRF DATA ---- Get the information necessary to do the WRF cross
> section
> asciiwrite("xlabel",xlabel)
> n = dimsizes(lat(:,0)) ; n is 1319 (1318 in some files, that's ok
> nn = dimsizes(lon(:,0)) ; n is 1319 (1318 in some files, that's ok
>
> minlat = lat(n-1,0)
> maxlat = lat(0,0) ; this is 67.xxx
> minlon = lon(nn-1,0)
> maxlon = lon(0,0) ; this is -150.xxx
>
> lats = (/maxlat,minlat/)
> lons = (/maxlon,minlon/)
>
> qc = a->QCLOUD(hour,:,:,:)
> qi = a->QICE(hour,:,:,:)
> qs = a->QSNOW(hour,:,:,:)
> qg = a->QGRAUP(hour,:,:,:)
> qr = a->QRAIN(hour,:,:,:)
>
> qt = qc + qi + qs + qg + qr
>
> z = wrf_user_getvar(a,"z",hour) ; grid point height
>
> zmin = 0.
> zmax = max(z) / 1000
> nz = floattoint(zmax/2 + 1)
> zmax = 20
>
> pm = a->PM10(hour,:,:,:)
>
> loc = wrf_user_latlon_to_ij(a,lats,lons)
>
> ys = loc(0,0) ; Starting y (j) location
> ye = loc(1,0) ; Ending y (j) location
> xs = loc(0,1) ; Starting x (i) location
> xe = loc(1,1) ; Ending x (i) location
>
> ; Interpolate WRF Model data vertically
> angle = 0
> opts = True ; start and end points not specified
>
> ; Establish starting and end points in domain
> plane = new(4,float)
> plane = (/ xs,xe, ys,ye /)
> pm_plane = wrf_user_intrp3d(pm,z,"v",plane,angle,opts)
>
> xcoord_wrf = ispan(0,dimsizes(pm_plane(0,:)) - 1, 1) ; has 157 values
> qt_plane = wrf_user_intrp3d(qt,z,"v",plane,angle,opts)
> dim = dimsizes(pm_plane)
> zspan = dim(0)
>
>
>
> ; Get orthogonal polarization data
>
> orth1 = f->Perpendicular_Attenuated_Backscatter_532
> orth1_dims = getvardims(orth1)
> ;reverse the vertical array
> orth1 = orth1(:,::-1)
>
> ; Reorder using string dimension names
> orth = orth1($orth1_dims(1)$|:,$orth1_dims(0)$|:)
> orth@_FillValue = -9999
> orth@units = "";"km~S~-1~NN~ sr~S~-1~NN~"
>
> ; Form the linear depolarization data
> parallel = back - orth
> parallel = where(parallel.ne.0, parallel, parallel@_FillValue)
>
> ldr1 = orth/parallel
> ldr1!0 = "first"
> ldr1!1 = "second"
> ldr_dims = getvardims(ldr1)
> ;reorder using string dimension names
> ldr = ldr1(first|:,second|:)
> ldr@_FillValue = -9999
>
> ; Work with the time fields to get a valid time string
> time = (/f->Profile_Time/)
> time@units = "seconds since 1993-01-01 00:00"
> tstring = ut_string(time(:,0), "%Y-%N-%D %H:%M:%S")
>
> ; Set stride intervals for x-axis
> stride = dimsizes(tstring)/7 ; used to be 15
> ; stride = 15
>
> ; Get the altitude values.
> hgt =
> asciiread("/import/u/u1/uaf/jmmadden/CALIPSO/lidar_altitudes.txt", -1,
> "float")
> hgt = hgt(::-1) ; Reverse this array too
> hgt!0 = "hgt"
> hgt@long_name = "Altitude, km"
> hgt@units = "km"
>
>
> ; ADD THE OTHER VARIABLES BESIDES BACKSCATTER (ORTH AND LDR)
>
> ; Assign new dimensions and attributes
> back!0 = "hgt"
> back&hgt = hgt
> xcoord = ispan(0,dimsizes(lat(:,0)) - 1,1)
> back!1 = "xcoord"
> back&xcoord = xcoord
>
> ; For orthogonal
> orth!0 = "hgt"
> orth&hgt = hgt
> xcoord = ispan(0,dimsizes(lat(:,0)) - 1,1)
> orth!1 = "xcoord"
> orth&xcoord = xcoord
>
> ; For LDR
> ldr!0 = "hgt"
> ldr&hgt = hgt
> xcoord = ispan(0,dimsizes(lat(:,0)) - 1,1)
> ldr!1 = "xcoord"
> ldr&xcoord = xcoord
>
>
> ;*************************
> ; create plot
> ;*************************
>
> ;;; ESTABLISH HEIGHT LIMIT
> ymax = 12
>
> ;;; ESTABLISH BACKSCATTER LEVELS
> backlevels =
> (/0.0001,0.0002,0.0003,0.0004,0.0005,0.0006,0.0007,0.0008,0.0009,0.001,0.0015,0.002,0.0025,0.003,0.0035,0.004,0.0045,0.005,0.0055,0.006,0.0065,0.007,0.0075,0.008,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1/)
>
> ;;; ESTABLISH FONT HEIGHT OF X BAR LABELS
> x_fontheight = 0.007
>
> ;;; ESTABLISH FONT HEIGHT OF BACKSCATTER AND DEPOLARIZATION BAR LABELS
> backlabelfontheight = 0.007;0.01
>
> ;;; ESTABLISH THE HEIGHT AND WIDTH OF EACH PLOT BOX
> height = 0.15
> width = 0.29
>
> setvalues NhlGetWorkspaceObjectId()
> "wsMaximumSize": 300000000
> end setvalues
>
> ;;; RESOURCES FOR PLOT ONE
> res = True
> res@gsnDraw = False
> res@gsnFrame = False
> res@cnFillOn = True ; color plot desired
> res@cnLinesOn = False
> res@cnRasterModeOn = True
> res@gsnSpreadColors = True ; use all colors
> res@gsnAddCyclic = False
> res@gsnLeftString = ""
> res@tiMainString = ""
> res@tiMainFontHeightF = 0.035;0.025
> res@tiYAxisFontHeightF = 0.035;0.027
>
> res@cnLevelSelectionMode = "ExplicitLevels"
> res@cnLevels = backlevels
> res@lbLabelStrings = backlevels
> res@tmXTOn = False
> res@tmXBMode = "Explicit"
> res@tmXBValues = xcoord(::stride)
> res@tmXBLabels = xlabel(::stride,0)
> res@tmXBLabelFontHeightF = x_fontheight
>
> res@trYMaxF = ymax
> res@lbLabelFontHeightF = backlabelfontheight
> res@lbLabelAngleF = 0.0
> res@lbOrientation = "vertical"
> res@lbLabelStride = 3
> res@lbBoxLinesOn = False
> res@vpWidthF = width
> res@vpHeightF = height
>
> ; ADD RESOURCES FOR ORTHOGONAL POLARIZATION (PLOT TWO)
> res_orth = res
>
>
> ; ADD RESOURCES FOR LDR (PLOT THREE)
> gsn_define_colormap(wks, "BlAqGrYeOrRe")
> colorMap = read_colormap_file("BlAqGrYeOrRe")
> colorMap(0,:) = (/ 0., 0., 0., 0./)
>
> res_ldr = True ;res
> res_ldr@cnFillOn = True ; color plot desired
> res_ldr@cnLinesOn = False
> res_ldr@cnRasterModeOn = True
> res_ldr@gsnAddCyclic = False
> res_ldr@gsnLeftString = ""
> res_ldr@tiMainString = ""
> res_ldr@tiMainFontHeightF = 0.035;0.025
> res_ldr@tiYAxisFontHeightF = 0.035;0.027
> res_ldr@cnLevelSelectionMode = "ExplicitLevels"
> res_ldr@cnFillPalette = colorMap
> res_ldr@cnSpanFillPalette = True
> res_ldr@cnMissingValFillColor = "black"
> res_ldr@cnMissingValFillPattern = 0
> res_ldr@cnLevels = (/0.01,0.025,0.05,0.075,0.1,0.15,0.25,0.35,0.45,
> 0.55, 0.85/)
> res_ldr@lbLabelStrings =
> (/0.01,0.025,0.05,0.075,0.1,0.15,0.25,0.35,0.45, 0.55, 0.85/)
> res_ldr@tmXTOn = False
> res_ldr@tmXBMode = "Explicit"
> res_ldr@tmXBValues = xcoord(::stride)
> res_ldr@tmXBLabels = xlabel(::stride,0)
> res_ldr@tmXBLabelFontHeightF = x_fontheight
>
> res_ldr@trYMaxF = ymax
> res_ldr@lbLabelFontHeightF = backlabelfontheight
> res_ldr@lbLabelAngleF = 0.0
> res_ldr@lbOrientation = "vertical"
> res_ldr@lbLabelStride = 2
> res_ldr@vpWidthF = width
> res_ldr@vpHeightF = height
> res_ldr@gsnDraw = False
> res_ldr@gsnFrame = False
>
> ; ADD RESOURCES FOR WRF (PLOT FOUR)
> res_wrf = True
> res_wrf@gsnDraw = False
> res_wrf@gsnFrame = False
> res_wrf@NoHeaderFooter = False
> pltres = True
> pltres@InitTime = False
> pltres@Footer = False
> pltres@lbOrientation = "vertical"
> pltres@pmLabelBarSide = "right"
> pltres@vpWidthF = width ; 0.29 NOT WORKING
> pltres@vpHeightF = height ; 0.15 NOT WORKING
> pltres@gsnDraw = False
> pltres@gsnFrame = False
> pltres@lbTitleOn = False
>
>
> ;ADD OPTIONS FOR WRF PARTICULATE MATTER
> opts_pm = pltres
> opts_pm@NoHeaderFooter = False
> opts_pm@gsnDraw = False
> opts_pm@gsnFrame = False
> opts_pm@cnFillOn = True
> opts_pm@cnFillMode = "RasterFill"
> opts_pm@cnRasterSmoothingOn = True
> opts_pm@cnLinesOn = False ; turn off contour lines
> opts_pm@cnLineLabelsOn = False ; turn off contour labels
> opts_pm@tiYAxisOn = True
> opts_pm@tiYAxisString = "Altitude, km"
> opts_pm@tiMainFontHeightF = 0.035
> opts_pm@tiYAxisFontHeightF = 0.035
> opts_pm@tmXTOn = False
> opts_pm@tmYROn = False
> opts_pm@tmXBMode = "Explicit"
> opts_pm@tmXBValues = xcoord(::stride)
> opts_pm@tmXBLabels = xlabel(::stride,0)
> opts_pm@tmXBLabelFontHeightF = x_fontheight
> opts_pm@vpWidthF = width
> opts_pm@vpHeightF = height
>
> ;ADD OPTIONS FOR WRF MIXING RATIOS
> opts_qt = pltres
> opts_qt@NoHeaderFooter = False
> opts_qt@gsnDraw = False
> opts_qt@gsnFrame = False
> opts_qt@cnInfoLabelOn = False ; turn off contour label
> opts_qt@cnMinLevelValF = 0.000006 ; good, data is in kg/kg
> opts_qt@tiXAxisOn = False
> opts_qt@vpWidthF = width
> opts_qt@vpHeightF = height
>
>
> ; COMBINE WRF CONTOURS
> contour_pm = wrf_contour(a,wks,pm_plane,opts_pm)
> contour_qt = wrf_contour(a,wks,qt_plane,opts_qt)
> wrf = (/contour_pm,contour_qt/)
>
> ; CREATE PLOTS
> plot = new(4,graphic)
>
> plot(0) = gsn_csm_contour(wks,back,res)
> plot(1) = gsn_csm_contour(wks,orth,res)
> plot(2) = gsn_csm_contour(wks,ldr,res_ldr)
> plot(3) = wrf_overlays(a,wks,wrf,pltres)
>
> ;;;;;; ATTACH PLOTS ALONG THE X AXES
> attachres1 = True
> attachres1@gsnAttachPlotsXAxis = True ;; attaches along x-axis
> attachres1@gsnAttachBorderOn = True ;; No border please
> attachres2 = True
> attachres2@gsnAttachPlotsXAxis = True ;; attaches along x-axis
> attachres2@gsnAttachBorderOn = True ;; No border please
>
> attachid1 = gsn_attach_plots(plot(0),plot(1:3),attachres1,attachres2)
>
> ;;;;;; MAXIMIZE OUTPUT ON THE PAGE AND DRAW EVERYTHING
> pres = False ; No resources needed
> maximize_output(wks,pres) ; Maximize plot on page
>
> draw(plot)
> frame(wks)
>
> end
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

Received on Thu Jun 12 06:29:19 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT