[ncl-talk] read_colormap_file suggestion

David Brown dbrown at ucar.edu
Wed Sep 16 15:11:42 MDT 2015


The original colormap reader for NCL was built to be reasonably
permissive in the format of the file. It ignores lines that start with
non-numeric characters, allows any amount of whitespace and/or a comma
in between numbers, and figures out from the range of the numbers
encountered whether the rgb components are represented as 8 bit or 16
bit integers or as 0-1 floating point values. Also it doesn't care
whether there are 1 or 3 or N components to a line. It will stop
reading the file once it has encountered 3 * 256 valid numbers.
The code was tested using files containing native NCL format floating
point rgb triplets in the 0-1 range, as well as .gp files from the
GIST plotting package, and .ncmap files from ncview.
 -dave


On Wed, Sep 16, 2015 at 1:09 PM, Rick Brownrigg <brownrig at ucar.edu> wrote:
> Hi Alan,
>
> That's a good suggestion, and I'll make sure it gets into 6.3.1.
>
> FWIW, I don't know of any formal spec for these file; the current version of
> read_colormap_file() was written to accommodate all the variations we had at
> the time.
>
> Thanks for the suggestion!
> Rick
>
>
> On Wed, Sep 16, 2015 at 12:49 PM, Alan Brammer <abrammer at albany.edu> wrote:
>>
>> line 199 $NCARG_ROOT/lib/ncarg/nclscripts/utilities.ncl  (v6.3.0)
>>
>>     tokens = str_split(lines(i), " ")
>>
>> This only allows for space separated rgb files.  I can't find any true
>> specifications on rgb file format but I have csv rgb files that work with
>> the other NCL functions but not read_colormap_file().
>>
>> If the above line is edited to the below it allows both space and comma
>> delimiters.
>>
>>     tokens = str_split(lines(i), " ,")
>>
>> Side note, there's no documentation that str_split accepts multiple
>> delimiters.
>>
>> Thanks,
>> Alan.
>>
>> _______________________________________________
>> 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
>


More information about the ncl-talk mailing list