[ncl-talk] Cross section overlays

Mary Haley haley at ucar.edu
Wed Oct 7 09:25:26 MDT 2015


Hi Stavros,

We have it on our list to add a "cnFillOpacities" resource (NCL-2058) which
will allow you to individually specify opacities for each level.

There are a few other ways to specify the opacity for each contour level.
One of them is by using RGBA arrays to define the colors, so that you can
then set the "A" component of these arrays to a value from 0 to 1 to
indicate the level of opacity you want.

Since you are using named colors to define the contour colors, then you can
use the "namedcolor2rgba" function to convert them to an RGBA array, and
set the transparencies there.

See the attached example, which you should be able to run as-is.

--Mary


On Wed, Oct 7, 2015 at 8:09 AM, Stavros Dafis <sdafis at cc.uoi.gr> wrote:

> Hello from Paris,
>
> I am trying to overlay 3 shaded contours in a cross section plot and the
> only
> way that I have found to make this is by using the "cnFillOpacityF" for
> every
> contour. Is there any other way to overlay these variables (graupel, ice,
> snow)? I have attached a link with my plot and part of my code:
>
> Plot : http://oi62.tinypic.com/2iszdyx.jpg
>
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>       ; Plotting options for Ice
>         opts_qi = opts_xy
>         ;opts_qi at ContourParameters       = (/ 0., 1., 0.2 /)
>         opts_qi at pmLabelBarOrthogonalPosF = 0.1
>         ;opts_qi at lbOrientation           =   "vertical"          ;
> vertical
> label bar
>         ;opts_qi at pmLabelBarSide          = "Right"
>         opts_qi at cnFillOn                 = True
>         opts_qi at cnFillOpacityF           = 0.8
>         opts_qi at cnFillColors             =
> (/"White","WhiteSmoke","Chartreuse","Green","Green1","Green2","Green3",\
>
>  "DarkGreen","DarkOliveGreen4"/)
>
>         ;colors2 = read_colormap_file("MPL_winter")
>         ;opts_qi at cnFillColors             = colors2
>         ;opts_qi at gsnSpreadColorEnd        =    -1  ; End third from the
> last
> color in color map
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>       ; Plotting options for Snow
>         opts_qs = opts_xy
>        ;opts_qs at ContourParameters        = (/ 0., 3., 0.5 /)
>         opts_qs at pmLabelBarOrthogonalPosF = 0.3
>        ;opts_qs at pmLabelBarParallelPosF   = 0.6
>         ;opts_qs at pmLabelBarSide          = "Right"
>         ;opts_qs at lbOrientation           =   "vertical"          ;
> vertical
> label bar
>         opts_qs at cnFillOn                 = True
>         opts_qs at cnFillOpacityF           = 0.9
>         opts_qs at cnFillColors             =
>
> (/"White","WhiteSmoke","Gray85","DodgerBlue","DodgerBlue1","DodgerBlue2","DodgerBlue3",
> \
>
> "DodgerBlue4","SteelBlue","SteelBlue1","SteelBlue2"/)
>         ;colors3 = read_colormap_file("CBR_wet")
>         ;opts_qs at cnFillColors            = colors3
>         ;opts_qs at gsnSpreadColorEnd        =    -1  ; End third from the
> last
> color in color map
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>       ; Plotting options for Temperature
>         opts_tc = opts_xy
>         opts_tc at cnInfoLabelZone = 1
>         opts_tc at cnInfoLabelSide = "Top"
>         opts_tc at cnInfoLabelPerimOn = True
>         opts_tc at cnInfoLabelOrthogonalPosF = -0.00005
>         opts_tc at ContourParameters  = (/ 5. /)
>
>    ;Contour terrain cross section
>         contour_ter = gsn_csm_xy(wks,X_plane,ter_plane,opts_ter)
>
>
>       ; Get the contour info for the rh and temp (the 2 plots have smooth
> terrain)
>         contour_tc2 = wrf_contour(a,wks,tc_plane2(0:zmax_pos,:),opts_tc)
>         contour_qg2 = wrf_contour(a,wks,qg_plane2(0:zmax_pos,:),opts_qg)
>         contour_qi2 = wrf_contour(a,wks,qi_plane2(0:zmax_pos,:),opts_qi)
>         contour_qs2 = wrf_contour(a,wks,qs_plane2(0:zmax_pos,:),opts_qs)
>         ;contour_GIS2 =
> wrf_contour(a,wks,GIS_plane2(0:zmax_pos,:),opts_GIS)
>
> ;--------------------------------------------------------------------------
>   ; MAKE PLOTS
>
>         if (FirstTimeMap) then
>           lat_plane = wrf_user_intrp2d(xlat,plane,angle,opts)
>           lon_plane = wrf_user_intrp2d(xlon,plane,angle,opts)
>           mpres = True
>           pltres = True
>           pltres at FramePlot = False
>           optsM = res
>           optsM at NoHeaderFooter = True
>           optsM at cnFillOn = True
>           optsM at lbTitleOn = False
>           contour  = wrf_contour(a,wks,ter,optsM)
>           ;plot = wrf_map_overlays(a,wks,(/contour/),pltres,mpres)
>           lnres = True
>           lnres at gsLineThicknessF = 2.0
>           lnres at gsLineColor = "Red"
>          ; do ii = 0,dimsX(0)-2
>            ;
>
> gsn_polyline(wks,plot,(/lon_plane(ii),lon_plane(ii+1)/),(/lat_plane(ii),lat_plane(ii+1)/),lnres)
>           ;end do
>           frame(wks)
>           delete(lon_plane)
>           delete(lat_plane)
>           ;pltres at FramePlot = True
>          ; pltres at PanelPlot = True
>        end if
>
>  plot =
>
> wrf_overlays(a,wks,(/contour_qs2,contour_qi2,contour_qg2,contour_tc2,contour_ter/),pltres)
> ; plot x-section
>
>
>
>
> thank you in advance for any comments!
>
>
>
> --
> Stavros Dafis
> MSc student Atmospheric Sciences and Environment
> University of Ioannina
> LATMOS Laboratoire Atmosph&#232;res, Milieux,Observations Spatiales;
> Versailles,
> France.
> Tel: +30 2651008499,  Mobile: +30 6970420242
> e-mails: sdafis at noa.gr or dafis91 at yahoo.gr or sdafis at cc.uoi.gr
> Weather charts: http://www.metar.gr
> http://www.meteovolos.gr
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151007/480ea34c/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: opacity_example.ncl
Type: application/octet-stream
Size: 1219 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151007/480ea34c/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: opacity_example.png
Type: image/png
Size: 359778 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151007/480ea34c/attachment-0001.png 


More information about the ncl-talk mailing list