Re: Issue setting text of cnInfoLabelString

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Sun Jan 19 2014 - 21:52:42 MST

Hi Larissa,

It looks like "wrf_contour" is setting cnInfoLabelString regardless of what you set it to.

I've modified the "set_cn_resources" internal function in WRFUserARW.ncl to fix this. To try out the fix, save the attached file, and add the following "load" command after your other load commands:

load "./set_cn_resources_mine.ncl"

Let me know if this works, and I'll make the change permanent.

Thanks,

--Mary

On Jan 16, 2014, at 10:03 AM, "Reames, Larissa J." <lreames@ou.edu> wrote:

> I’m attempting to change the text of my cnInfoLabelString to reflect my, at times, unequally spaced contours in my third panel plot made using WRF output. I can successfully move the location and justification of the Info Label with @cnInfoLabelSide and @cnInfoLabelJust, but NCL seems to be ignoring my attempts to set @cnInfoLabelString, with no indications in the output file that it’s encountering any errors. I’ve copied my code here, and the plot res in question is “optstd” to be used in creating “contourtd”, then plotted in plot(2).
>
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>
> begin
> ;
> ; The WRF ARW input file.
> ; This needs to have a ".nc" appended, so just do it.
> a = addfile("/work/lreames/MAY10_CTRL/OUT/out.2010-05-10_19:00:00.d02.nc","r")
> b = addfile("/work/lreames/MAY10_OKCM/OUT/out.2010-05-10_19:00:00.d02.nc","r")
>
> urbf = b->FRC_URB2D
> contourst = (/270.,310.,2./)
> contoursq = (/4.,16., 2./)
> it = ispan(0,11,1)
> times = wrf_user_getvar(a,"times",-1)
>
> ; Import variables and calculate time averages
> lata = a->XLAT
> lat = lata(0,:,:)
> lona = a->XLONG
> lon = lona(0,:,:)
> ter = b->HGT
> urbf = b->FRC_URB2D
>
> tc = a->T
> tc = tc+300
> tcavg = dim_avg_n_Wrap(tc,0)
> tcavg@description = "AVG POTENTIAL TEMPERATURE"
> tcavg@Units = "K"
> tm = b->T
> tm = tm+300
> tmavg= dim_avg_n_Wrap(tm,0)
> tmavg@description = "AVG POTENTIAL TEMPERATURE"
> tmavg@Units = "K"
>
> tdiff = tmavg-tcavg
> tdiff@description = "AVG POTENTIAL TEMPERATURE DIFF"
> tdiff@Units = "K"
>
> qc = a->QVAPOR
> qc = qc*1000
> qcavg = dim_avg_n_Wrap(qc,0)
> qcavg@description = "AVG MIXING RATIO"
> qcavg@units = "g kg~S~-1~N~"
> qm = b->QVAPOR
> qm = qm*1000
> qmavg = dim_avg_n_Wrap(qm,0)
> qmavg@units = "g kg~S~-1~N~"
> qmavg@description = "AVG MIXING RATIO"
>
> qdiff = qmavg-qcavg
> qdiff@units = "g kg~S~-1~N~"
> qdiff@description = "AVG MIXING RATIO DIFF"
>
> uac = a->U
> uc = wrf_user_unstagger(uac,uac@stagger)
> ucavg = dim_avg_n_Wrap(uc,0)
> ucavg = 1.94384449*ucavg
> ucavg@description = "AVG WIND BARBS"
> ucavg@units = "kts"
>
> vac = a->W
> vc = wrf_user_unstagger(vac,vac@stagger)
> vcavg = dim_avg_n_Wrap(vc,0)
> vcavg = vcavg * 1.94384449
>
> uam = b->U
> um = wrf_user_unstagger(uam,uam@stagger)
> umavg = dim_avg_n_Wrap(um,0)
> umavg = 1.94384449*umavg
> umavg@description = "AVG WIND BARBS "
> umavg@units = "kts"
> vam = b->W
> vm = wrf_user_unstagger(vam,vam@stagger)
> vmavg = dim_avg_n_Wrap(vm,0)
> vmavg = 1.94384449 * vmavg
>
> udiff = umavg-ucavg
> udiff@description = "AVG WIND BARBS DIFF"
> udiff@units = "kts"
> vdiff = vmavg-vcavg
>
> zamsl = wrf_user_getvar(a, "z",0)
>
> zn = conform_dims((/71,400,400/),ter(0,:,:),(/1,2/))
> z = zamsl-zn
>
> ; Determine angle for cross-section
> angle = 90.
> opts = False
> plane = (/225,275/)
> X_plane = wrf_user_intrp2d(lon,plane,angle,opts)
> X_desc = "longitude"
>
> ;Define level of 2.0km height
> zmin = 0.
> zmax = 1.5
> nz = 4
> zz = wrf_user_intrp3d(z,z,"v",plane,angle,opts)
> c = ind(zz(:,0) .gt. zmax*1000. )
> zmax_pos = c(0) - 1
> if ( abs(zz(zmax_pos,0)-zmax*1000.) .lt. abs(zz(zmax_pos+1,0)-zmax*1000.) ) then
> zspan = c(0) - 1
> else
> zspan = c(0)
> end if
> delete(zz)
> delete(c)
> print(zspan)
>
> ; X-axis lables
> dimsX = dimsizes(X_plane)
> xmin = X_plane(0)
> xmax = X_plane(dimsX(0)-1)
> xspan = dimsX(0)-1
> nx = 10
>
> ; Create cross-section variables
> q_planec = wrf_user_intrp3d(qcavg,z,"v",plane,angle,opts)
> t_planec = wrf_user_intrp3d(tcavg,z,"v",plane,angle,opts)
> u_planec = wrf_user_intrp3d(ucavg,z,"v",plane,angle,opts)
> v_planec = wrf_user_intrp3d(vcavg,z,"v",plane,angle,opts)
>
> q_planem = wrf_user_intrp3d(qmavg,z,"v",plane,angle,opts)
> t_planem = wrf_user_intrp3d(tmavg,z,"v",plane,angle,opts)
> u_planem = wrf_user_intrp3d(umavg,z,"v",plane,angle,opts)
> v_planem = wrf_user_intrp3d(vmavg,z,"v",plane,angle,opts)
>
> q_planed = wrf_user_intrp3d(qdiff,z,"v",plane,angle,opts)
> t_planed = wrf_user_intrp3d(tdiff,z,"v",plane,angle,opts)
> u_planed = wrf_user_intrp3d(udiff,z,"v",plane,angle,opts)
> v_planed = wrf_user_intrp3d(vdiff,z,"v",plane,angle,opts)
>
> dim = dimsizes(q_planec)
>
>
> ; We generate plots, but what kind do we prefer?
> type = "pdf"
> wks = gsn_open_wks(type,"plt_cross")
> plot = new(3,graphic)
>
> ; Set some basic resources
> res = True
> res@tiMainOn = False
> ;res@MainTitle = "REAL-TIME WRF"
> res@gsnDraw = False ; don't draw
> res@gsnFrame = False ; don't advance frame
> res@lbLabelBarOn = True ; Turn off invortidual labelbars so we can
> ; turn on panel labelbar.
> res@NoTitles = True
> res@CommonTitle = True
> res@NoHeaderFooter = True
> res@gsnSpreadColors = True
> pltres = True
> res@lbTitleOn = True
> ; Set resources specific to each plot type
>
> ; Options for all plots
> opts_xy = res
> opts_xy@tiXAxisString = X_desc
> opts_xy@tiYAxisString = "Height AGL (km)"
> opts_xy@cnMissingValPerimOn = True
> opts_xy@cnMissingValFillColor = 0
> opts_xy@cnMissingValFillPattern = 11
> opts_xy@tmXTOn = False
> opts_xy@tmYROn = False
> opts_xy@tmXBMode = "Explicit"
> opts_xy@tmXBValues = fspan(0,xspan,nx) ; Create tick marks
> opts_xy@tmXBLabels = sprintf("%.1f",fspan(xmin,xmax,nx)) ; Create labels
> opts_xy@tmXBLabelFontHeightF = 0.015
> opts_xy@tmYLMode = "Explicit"
> opts_xy@tmYLValues = fspan(0,zspan,nz) ; Create tick marks
> opts_xy@tmYLLabels = sprintf("%.1f",fspan(zmin,zmax,nz)) ; Create labels
> opts_xy@tiXAxisFontHeightF = 0.020
> opts_xy@tiYAxisFontHeightF = 0.020
> opts_xy@tmXBMajorLengthF = 0.02
> opts_xy@tmYLMajorLengthF = 0.02
> opts_xy@tmYLLabelFontHeightF = 0.015
> opts_xy@PlotOrientation = t_planec@Orientation
>
> ; Temp contour resources
> optst = opts_xy
> optst@cnFillOn = False
> optst@ContourParameters = contourst
> optst@cnLineColor = "red"
>
> ; Q resources
> optsq = opts_xy
> optsq@cnFillOn = True
> optsq@ContourParameters = contoursq
>
> ; Wind arrows resources
> optsw = opts_xy
> optsw@vcRefMagnitudeF = 20
> optsw@vcGlyphStyle = "CurlyVector"
> optsw@vcMonoLineArrowColor = True
> optsw@vcLineArrowColor = "grey38"
> ; Added text resources
> optstx = res
> optstx@txFontHeightF = 0.01
>
> ; T diff resources
> optstd = opts_xy
> optstd@cnFillOn = False
> optstd@cnLevelSelectionMode = "ExplicitLevels"
> optstd@cnLevels = (/-1.,-0.8,-0.6,-0.4,-0.2,0.2,0.4,0.6,0.8,1.0/)
> ;optstd@cnInfoLabelOn =
> optstd@cnInfoLabelOrthogonalPosF = -0.11
> optstd@cnInfoLabelString = "CONTOURS FROM $CMN$ to %CMX$ BY 0.2"
> ;optstd@cnInfoLabelSide = "Top"
> ;optstd@cnInfoLabelJust = "CenterCenter"
>
> ; Q diff resources
> optsqd= opts_xy
> optsqd@gsnSpreadColors = True
> optsqd@gsnSpreadColorStart = 2
> optsqd@gsnSpreadColorEnd = 128
> optsqd@cnFillOn = True
> optsqd@ContourParameters = (/-1.,1.,0.1/)
>
> ; Wind diff resources
> optswd = opts_xy
> optswd@vcRefMagnitudeF = 2
> optswd@vcGlyphStyle = "CurlyVector"
> optswd@vcMonoLineArrowColor = True
>
>
> gsn_merge_colormaps(wks,"MPL_BrBG","MPL_Summer")
> ; gsn_draw_colormap(wks)
>
> ; Create contour, vector plots but don't plot yet
> contourtc = wrf_contour(a,wks,t_planec(0:zmax_pos,:),optst)
> contourtm = wrf_contour(b,wks,t_planem(0:zmax_pos,:),optst)
> contourtd = wrf_contour(b,wks,t_planed(0:zmax_pos,:),optstd)
> contourqc = wrf_contour(a,wks,q_planec(0:zmax_pos,:),optsq)
> contourqm = wrf_contour(b,wks,q_planem(0:zmax_pos,:),optsq)
> contourqd = wrf_contour(b,wks,q_planed(0:zmax_pos,:),optsqd)
> vectorc = wrf_vector(a,wks,u_planec(0:zmax_pos,:),v_planec(0:zmax_pos,:),optsw)
> vectorm = wrf_vector(b,wks,u_planem(0:zmax_pos,:),v_planem(0:zmax_pos,:),optsw)
> vectord = wrf_vector(b,wks,u_planed(0:zmax_pos,:),v_planed(0:zmax_pos,:),optswd)
>
> pltres = True
> pltres@PanelPlot = True
> pltres@gsnSpreadColorStart = 129
> pltres@gsnSpreadColorEnd = 256
> pltres@lbLabelBarOn = False
> plot(0) = wrf_overlays(a,wks,(/contourtc,contourqc,vectorc/),pltres)
> plot(1) = wrf_overlays(b,wks,(/contourtm,contourqm,vectorm/),pltres)
> pltres@gsnSpreadColorStart = 2
> pltres@gsnSpreadColorEnd = 128
> plot(2) = wrf_overlays(b,wks,(/contourtd,contourqd,vectord/),pltres)
>
> ;************************************************
> ; create panel
> ;************************************************
> resP = True ; modify the panel plot
> resP@gsnPanelLabelBar = False ; add common colorbar
> ;resP@TimeLabel = times(i)
> resP@txString = "BL East-West Cross Section 19-20Z"
> resP@NoTitles = True
> resP@lbLabelAutoStride = True ; Spacing of lbar labels.
> resP@lbBoxMinorExtentF = 0.13
> resP@gsnMaximize = True
> resP@gsnPaperOrientation = "auto"
> resP@gsnPaperMargin = 0.05
> label1 = "CTRL"
> label2 = "OKCM"
> gsn_panel(wks,plot,(/1,3/),resP) ; now draw as one plot
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> end
>
> Thank you,
>
> Larissa
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Sun Jan 19 21:52:54 2014

This archive was generated by hypermail 2.1.8 : Sun Jan 19 2014 - 21:56:35 MST