Re: beginning and ending index of a certain color table

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed, 24 Sep 2008 09:16:01 -0600 (MDT)

On Wed, 24 Sep 2008, Dennis Shea wrote:

> I don't know how to directly get the number of colors
> without opening a workstation.

There's no way to do this. The color map is associated with a
workstation, and in order to query anything about it, a workstation
has to be opened first.

Dennis gave one approach for getting the size. Another approach that
does't require retrieving the color map itself is to query the
wkColorMapLen resource:

   wks = gsn_open_wks("x11","test1")
   gsn_define_colormap(wks,"BlWhRe")
   getvalues wks
     "wkColorMapLen" : cmap_len
   end getvalues

   print("Length of color map is " + cmap_len)

--Mary

> If someone does ... please respond.
> ----
>
> Here is one approach:
>
> wks = gsn_open_wks("x11","test1")
> gsn_define_colormap(wks,"BlWhRe")
>
> cmap = gsn_retrieve_colormap(wks)
> dimc = dimsizes(cmap)
> nMax = dimc(0) ; max colors
>
> For BlWhRe, it would be nMax=103
>
> Hence, the start/end indices would be 2,102(=nMax-1)
>
> You could create a function.
>
> function getNumberColors (wks:graphic]
> begin
> cmap = gsn_retrieve_colormap(wks)
> dimc = dimsizes(cmap)
> nMax = dimc(0) ; max colors
> return(nMax)
> end
>
>
>
> Kai Zhang wrote:
>> Dear all,
>>
>> Is there a function which can tell me the beginning and ending index
>> of a certain color table? I know that we can look it up on the NCL web
>> site, but it is always nice to let NCL do it automatically. Thanks!
>>
>> Kai
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk_at_ucar.edu
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 24 2008 - 09:16:01 MDT

This archive was generated by hypermail 2.2.0 : Mon Sep 29 2008 - 13:35:43 MDT