Re: Associating specific colors with specific contour levels?

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Thu, 31 Jul 2008 13:12:42 -0600

Hi Gary,

Gary Strand wrote:
>
> I'm attempting to replicate a Ferret code that I have in NCL, and one of
> the things Ferret allows you to do is associate specific colors with
> specific contour levels. One does this by giving the contour level and
> color triplet in the colormap file used, e.g.:
>
> RGB_Mapping By_Value
> ! Val R G B
> -6000. 0. 0. 20. ! blue-black
> -4000. 10. 18. 90.
> -2000. 20. 35. 100. ! blue
> -300. 40. 70. 100.
> -100. 50. 100. 100.
> -50. 40. 80. 70.
> -0.1 90. 100. 100. ! light green-blue
> 0. 0. 40. 00. ! dark green
> 100. 0. 70. 30. ! light green
> 300. 90. 100. 0. ! light yellow
> 1200. 60. 30. 0. ! rust
> 4000. 90. 90. 100. ! ice blue
> 5000. 100. 100. 100. ! white
>
> Is there a way to do something like this in NCL?

You can manually specify the contour levels via the cnLevels resource,
and then manually specify the fill colors using cnFillColors like this:

res_at_cnLevelSelectionMode = "ManualLevels"
res_at_cnLevels =
(/-6000,-4000,-2000,-300,-100,-50,-0.1,0,100,300,1200,4000,5000/)
res_at_cnFillOn = True
res_at_cnFillColors = (/2,4,5,6,8, etc /)

But I don't know of a way to set them together, or to use RGB values
instead of color index values. Someone else can chime in on this one.

>
> Also, can I specify contour levels in "chunks" without having to specify
> all of them explicitly? Ferret allows you to this via the "LEV" command:
>
> shade/lev=(-10250,-250,250)(-250,250,25)(250,8250,250) topo
>
> That is, from -10250 to -250, use 250 increments, from -250 to 250,
> increment by 25, and then from 250 to 8250, go back to 250.
>

Yes, although it's not as not nearly as neat as the Ferret way:

chunk1 = ispan(-10250,-250,250)
chunk2 = ispan(-225,250,25)
chunk3 = ispan(275,8250,250)
arr = new(dimsizes(chunk1)+dimsizes(chunk2)+dimsizes(chunk3),integer)
arr(:dimsizes(chunk1)-1) = (/ chunk1 /)
arr(dimsizes(chunk1):dimsizes(chunk1)+dimsizes(chunk2)-1) = (/ chunk2 /)
arr(dimsizes(chunk1)+dimsizes(chunk2):) = (/ chunk3 /)
res_at_cnLevelSelectionMode = "ManualLevels"
res_at_cnLevels = arr

Adam

> Thanks!
>
> Gary Strand
> strandwg_at_ucar.edu <mailto:strandwg_at_ucar.edu>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> 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
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jul 31 2008 - 13:12:42 MDT

This archive was generated by hypermail 2.2.0 : Thu Jul 31 2008 - 14:58:46 MDT