[ncl-talk] best way to overlay two color filled contour maps?

Mary Haley haley at ucar.edu
Thu Sep 1 12:39:42 MDT 2016


Xiaoming,

If you need to use transparency, or more than two colormaps per plot, then
you can't to use the workstation color map for setting the contour colors
(i.e. the gsn_define_colormap procedure).

Instead, use the cnFillPalette resource.  This powerful resource allows you
to directly associate a predefined color map (like "BlAqGrYeOrReVi200") or
an RGB/RGBA directly with a contour plot.

So, for the case where you want to reverse the "gsdtol" color map, you can
do this:

  cmap = read_colormap_file("gsdtol")
  res at cnFillPalette = cmap(::-1,:)      ; reverse the color map

But, there's already a reversed version of "gsdtol" called "gsltod", so you
could also use that directly:

res at cnFillPalette = "gsltod"

Then, for the overlaid contours, set:

res2 at cnFillPalette = "BlAqGrYeOrReVi200"

Remove all calls to "gsn_define_colormap" and "gsn_reverse_colormap".  They
are no longer needed.

There are some other things you may want to clean up in your plot:

[1] Don't use WRF_map_c. This is not an advertised function and was
deprecated a long time ago.  Instead, use:

  wrf_map_resources(fmap, res)

[2] You are setting a bunch of resource inside a do loop. This can cause
your script to run slowly, if you have a do loop with a lot of increments,
because it's needlessly executing the same code over and over.  I recommend
moving all code that doesn't need to be inside the loop, to outside the
loop.

I tried to fix your code to illustrate what you mean, but since I can't run
it, I can't guarantee that it is bug free. See the attached script.


--Mary



On Wed, Aug 31, 2016 at 10:10 PM, xiaoming Hu <yuanfangcan at hotmail.com>
wrote:

> I actually looked at those pages.
> See what I got
>
>
> using my script of http://www.caps.ou.edu/micronet/YangYi/WRF_QTT/V3.7.
> 1/wrfERA2d_Sichuan_forQTT_UCM_YSU.2014070912/plot_totalRain_
> daily_spatial.ncl
>
> Apparently it is not as nice as
>
>
> There are a few issues,
> 1. I need the two contour maps using different colormaps, one is gsdtol,
> the other is BlAqGrYeOrReVi200
> 2. In the exemplary figure, the overlay is done not through Opacity
> setting, but setting the 1st color transparent.
> If I set gsn_define_colormap(wks,"BlAqGrYeOrReVi200") , how can I make
> the fist used color transparent?
>
> Thanks
> Xiaoming
>
> ------------------------------
> CC: ncl-talk at ucar.edu; xhu at ou.edu
> From: shea at ucar.edu
> Subject: Re: [ncl-talk] best way to overlay two color filled contour maps?
> Date: Wed, 31 Aug 2016 17:11:20 -0600
> To: yuanfangcan at hotmail.com
>
>
> Did you look at the overlay page?
>
> Applications/overlay.shtml
> Applications/rgbacolor.shtml
>
> Sent from my iPhone
>
> On Aug 31, 2016, at 12:36 PM, xiaoming Hu <yuanfangcan at hotmail.com> wrote:
>
> What is the best way to overlay two color-filled contour maps (like
> below) in NCl?
>
> <overlay.png>
>
>
> Thanks
> Xiaoming
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
> _______________________________________________
> 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/20160901/8f5d8457/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: overlay.png
Type: image/png
Size: 40998 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/8f5d8457/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrfout_d02_hourlyRAIN_0.png
Type: image/png
Size: 79641 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/8f5d8457/attachment-0001.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plot_mod.ncl
Type: application/octet-stream
Size: 4372 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/8f5d8457/attachment.obj 


More information about the ncl-talk mailing list