Re: Duplicate contour line labels with overlay shading

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Wed, 02 Sep 2009 13:58:33 -0600

Hi Arlene,
Ah, I didn't catch that there are some draw/frame issues going on. First
of all, gsn_shade_contour expects that the plot that is to be modified
has not been drawn, nor has it been previously framed. Looking at the
documentation of wrf_overlays, there isn't an option to tell
wrf_overlays to not draw the plot. Thus, whenever you use wrf_overlays,
the plot is drawn.

So, looking at your original script:
1) wrf_overlays is called, the overlay plot is drawn, but the plot is
not framed (=the page is not flipped).
2) gsn_contour_shade is called.
3) You draw(plot) and frame(wks), which you should do after calling
gsn_contour_shade.

The problem is that the plot is drawn in 1), and gets drawn again in 3),
resulting in the duplicate labels. (Although I'm honestly not sure why
the 1st set of labels is visible after your draw the plot again. It
might have something to do with the fact that you're overlaying/using
wrf_overlays.)

The strange thing is with respect to your recent email, when you comment
our pltres_at_FramePlot = False, you should be getting two pages of
.ps/.png/x11 output.

So, the bad news is that if I'm reading the wrf_overlays function
correctly, you cannot set gsnDraw = False. Thus, you cannot use
gsn_contour_shade. The sorta good news is that you can do what
gsn_contour_shade does by hand, by using some of the resources I alluded
to earlier: cnFillOn, cnMonoFillPattern, cnMonoFillColor, and
cnFillPatterns.

There's a good example of how to do this by hand in the contour effects
applications page (#10) here:
http://www.ncl.ucar.edu/Applications/coneff.shtml#ex10
You're going to want to try setting these resources in your res_eth
resource list.

Hopefully this helps. If you still have trouble achieving what you want
with respect to your plot let us know.
Adam

Arlene Laing wrote:
> Hi Adam,
>
> Thanks for the quick response.
>
> The problem seems to be related to the following line:
>
> pltres_at_FramePlot = False
>
> I tried the following tests (see the corresponding jpg files attached)
>
> 1) Original (no duplication and no stippling, i.e., no gsm_contour_shade
> and resource settings)
> ; pltres_at_FramePlot = False
> see image, no_gsm_shade_single_label.jpg
>
> 2) Duplicate labels (no stippling, i.e., no gsm_contour_shade and
> resource settings)
> pltres_at_FramePlot = False
> see image, no_gsm_shade_duplicate_label.jpg
>
> 3) Stippled, duplicate labels (call to gsm_contour_shade and resource
> settings)
> pltres_at_FramePlot = False
> see image, gsm_shade_duplicate_label.jpg
>
> 4) Call to gsm_contour_shade and resource setting
> ; pltres_at_FramePlot = False
> resulting plot same as no_gsm_shade_single_label.jpg
>
> Perhaps this will help you to help me.
>
> Thanks.
> Arlene
>
> -------------
> Arlene Laing
> NCAR/MMM
>
> On Wed, 02 Sep 2009 11:04:42 -0600
> Adam Phillips <asphilli_at_ucar.edu> wrote:
>> Hi Arlene,
>> According to the documentation, the gsn_contour_shade function only
>> accepts a limited set of resources:
>> http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_contour_shade.shtml
>>
>> All other resources that are set beyond the possible 4 listed in the
>> documentation are ignored.
>>
>> All that being said, gsn_contour_shade simply modifies/sets some of
>> the following resources after a plot is drawn:
>> cnFillOn, cnMonoFillPattern, cnMonoFillColor, cnFillColors, and
>> cnFillPatterns. In other words, it doesn't change the behavior of the
>> line labels generated in the original plot. If you had line labels in
>> the original plot, gsn_contour_shade will not modify them. (The
>> opposite is true as well.)
>>
>> I wonder if you see the same duplicate line labels when omitting the
>> calling of gsn_contour_shade, as you are doing multiple overlays.
>>
>> If I'm off base here, include a .gif/.png/ or .jpg of the plot in your
>> reply to ncl-talk..
>> Adam
>>
>> Arlene Laing wrote:
>>> Good day,
>>>
>>> I am getting duplicate contour line labels after overlaying a
>>> stippling pattern for contours above a certain value of equivalent
>>> potential temperature (eth).
>>>
>>> As you can see from the excerpted script below, I reset the resource
>>> (res_eth) contour line and contour line label to "False" before
>>> calling "gsn_contour_shade". However, that does not stop the
>>> duplication.
>>>
>>> Your help with solving this problem will be greatly appreciated.
>>>
>>> Thanks.
>>> Arlene Laing
>>> NCAR/MMM
>>>
>>> ;***********************************************
>>> ; set plot resources
>>> res_at_vpWidthF = .9 ; overwrite basic plot size
>>> res_at_vpHeightF = 1.0
>>> pltres = True
>>>
>>> res_xy = res
>>> res_xy_at_tiYAxisString = "Pressure (hPa)"
>>> res_xy_at_AspectRatio = 0.75
>>> res_xy_at_cnMissingValPerimOn = True
>>> res_xy_at_cnMissingValFillColor = 0
>>> res_xy_at_cnMissingValFillPattern = 11
>>> res_xy_at_sfYCStartV = max(pressure_levels)
>>> res_xy_at_sfYCEndV = min(pressure_levels)
>>> res_xy_at_trYReverse = True ; reverse Y axis
>>> res_xy_at_trYLog = True ; Log scale
>>> res_xy_at_tmYLMode = "Explicit"
>>> res_xy_at_tmYLValues = (/1000., 850., 700., 600., 500., 400., \
>>> 300., 250., 200./)
>>> res_xy_at_tmYLLabels = (/"1000","850","700","600","500","400", \
>>> "300","250","200"/)
>>> ; res_xy_at_sfYArray = pressure_levels
>>> res_xy_at_tiXAxisFontHeightF = 0.02
>>> res_xy_at_tiYAxisFontHeightF = 0.02
>>> res_xy_at_tmXBMajorLengthF = 0.02
>>> res_xy_at_tmYLMajorLengthF = 0.02
>>> res_xy_at_tmYLLabelFontHeightF = 0.015
>>> res_xytxFontHeightF = 0.015
>>> res_xy_at_tiXAxisString = "Latitude"
>>> res_xy_at_sfXArray = lat2d(:,0)
>>>
>>> res_xy_at_gsnDraw = False ; Don't draw plots
>>> res_xy_at_gsnFrame = False ; Don't advance frame
>>>
>>> ; Plotting options for U
>>> res_u = res_xy
>>> ; res_u_at_cnInfoLabelOrthogonalPosF = 0.00
>>> res_u_at_cnInfoLabelOn = False ; turn off cn info label
>>> res_u_at_cnLineLabelPerimOn = False ; turn off label perimeter
>>> res_u_at_cnLabelMasking = True ; do not draw labels over contour
>>> res_u_at_cnLineLabelFontHeightF = 0.016
>>> res_u_at_cnLineLabelBackgroundColor = "white"
>>> res_u_at_cnLineThicknessF = 1.5
>>> res_u_at_ContourParameters = (/ -30., 20, 2. /)
>>> res_u_at_gsnContourNegLineDashPattern = 1
>>>
>>> ; Plotting options for RH
>>> res_rh = res_xy
>>> res_rh_at_pmLabelBarOrthogonalPosF = -0.07
>>> res_rh_at_ContourParameters = (/ 10., 90., 10. /)
>>> res_at_cnFillMode = "RasterFill" ; Raster Mode
>>> res_at_cnLinesOn = False ; Turn off contour lines
>>> res_at_cnLineLabelsOn = False ; Turn off contour lines
>>> res_rh_at_cnFillOn = True
>>> res_rh_at_cnFillColors = (/"White", "White","White",\
>>>
>>> "White","DarkOliveGreen1","Chartreuse","Green", \
>>> "Green3", \
>>>
>>> "ForestGreen","PaleGreen4"/)
>>>
>>> ; Plotting options for ETH, Equivalent Pot Temperature
>>> res_eth = res_xy
>>> res_eth_at_cnInfoLabelOrthogonalPosF = 0.00
>>> res_eth_at_cnLineColor = "Blue"
>>> res_eth_at_cnLineThicknessF = 1.0
>>> res_eth_at_cnLineLabelFontHeightF = 0.020
>>> res_eth_at_cnLabelMasking = True ; do not draw labels over contour
>>> res_eth_at_ContourParameters = (/ 320., 376., 2. /)
>>>
>>> ; Get the contour info (from WRF NCL example)
>>> contour_u = wrf_contour(a,wks,zave_u,res_u)
>>> contour_rh = wrf_contour(a,wks,zave_rh,res_rh)
>>> contour_eth = wrf_contour(a,wks,zave_eth,res_eth)
>>>
>>> ; MAKE PLOTS
>>> pltres_at_FramePlot = False ; do not frame plot - will do this
>>> later
>>>
>>> plot =
>>> wrf_overlays(a,wks,(/contour_eth,contour_u,contour_rh/),pltres)
>>>
>>> res_at_gsnRightString = ""
>>> res_at_gsnLeftString = ""
>>> res_at_gsnCenterString = ""
>>>
>>> ; testing shaded contour for eth > 343K
>>> res_eth_at_cnLinesOn = False ; Turn off contour lines
>>> res_eth_at_cnLineLabelsOn = False ; Turn off contour labels
>>> res_eth_at_cnMonoFillColor = True ; default color is fground
>>> [black]
>>> res_eth_at_cnMonoFillPattern = False ; want multiple patterns
>>> res_eth_at_cnMonoFillScale = False ; want patterns w/ diff
>>> densities
>>> res_eth_at_gsnShadeFillType = "Pattern"
>>> res_eth_at_gsnShadeHigh = 17 ; Use fill pattern #17 (stipple)
>>>
>>> ; plot=gsn_contour(wks,zave_eth,res_eth) ; plot zonal ave of eth
>>> plot = gsn_contour_shade(plot,-999.,343., res_eth) ; Pattern
>>> shade contours above 343
>>>
>>> draw(plot)
>>> frame(wks)
>>>
>>> ;***********************************************
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>> --
>> --------------------------------------------------------------
>> Adam Phillips asphilli_at_ucar.edu
>> National Center for Atmospheric Research tel: (303) 497-1726
>> ESSL/CGD/CAS fax: (303) 497-1333
>> P.O. Box 3000
>> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 02 2009 - 13:58:33 MDT

This archive was generated by hypermail 2.2.0 : Thu Sep 03 2009 - 07:55:08 MDT