This function takes as input an array of workstation ids (any dimensionality) and an array of color names (any dimensionality) and returns an array of color map indexes that match the color names the closest.

Note: This function is only available in version 4.1.1 of NCL. If your site is licensed for version 4.1, then you can get version 4.1.1 for free. To get version 4.1.1 of NCAR Graphics software, please contact your site representative. If you don't know who your site representative is, then send email to ncarginf@ucar.edu or call (303) 497-1201.


    function NhlGetNamedColorIndex(
       wks        : graphic,
       color_name : string


An array of any dimensionality of NCL workstation ids
An array of any dimensionality of named colors from the $NCARG_ROOT/lib/ncarg/database/rgb.txt file


NhlGetNamedColorIndex looks up the given color names in the color maps of the given workstations and returns an integer array of color indexes for each workstation id that represent the closest match to each color. If a bogus color name is given, then the color index returned will be negative. The array returned will be dimensioned n x m where n represents the dimensions of wks and m represents the dimensions of color_name. If only one workstation is given, then the dimensions of the output will be equal to the dimensions of color_name.


If you have the following NCL script:
  wks = create "workstation" ncgmWorkstationClass defaultapp
    "wkColorMap" : (/"white","black","red","green","blue","yellow",\
  end create

  i = NhlGetNamedColorIndex(wks,(/"red","yellow","blue","green",\
  j = NhlGetNamedColorIndex(wks,(/"gray","brown"/))
then i will be equal to (/2,5,4,3,6,7/) and j will be equal to (/0,2/). There's no gray or brown defined in the above color map, so when the color map is searched for the closest match to gray and brown, it comes up with white and red, which are color indexes 0 and 2.

Reference Manual Control Panel

NG4.1 Home, Index, Examples, Glossary, Feedback, Ref Contents, Ref WhereAmI?

$Revision: 1.3 $ $Date: 1999/03/18 22:38:59 $