Hi Friedrich,

Many thanks for your detailed response.  I've had to turn my attention
to other things in the past few weeks, but I am back to this task now.

I've implemented the Norm that you suggested by subclassing Normalize;
that was a great suggestion.  Now I have a two dimensional array where
water has value -1.5, missing data have -0.5, and valid data over land
have values in [0, 1].

After poking around in cm.py, _cm.py, and colors.py, I understand better
how to define a colormap, but I am not sure how to map negative values
like -0.5 or -1.5 to a color -- I believe the x values in the color
dictionary must be positive?

I can imagine various schemes to sidestep this by assigning water and
missing values positive discrete values (say, 0.1 and 0.2 or something)
and then putting valid data in the remaining portion of [0,1] -- maybe
[0.3, 1] or something.  But there's an elegance to valid data going into
[0, 1] and other invalid data getting values outside of that range...  I
think I'd lose a little readability in giving that up.

Anyway, thanks a whole lot for your helpful suggestions.

Best,
Tim

On Sat, Nov 2010, 06 at 10:52:48PM +0100, Friedrich Romstedt wrote:
> 2010/11/1 Timothy W. Hilton <hil...@meteo.psu.edu>:
> > [...]
> >
> > I want to have blue water, some other (bright) color for missing data,
> > and a nice-looking color transition (matplotlib.cm.Blues or something
> > similar) for the valid data over land (values from 0 to 50).  The
> > Cookbook example at
> > <http://www.scipy.org/Cookbook/Matplotlib/Plotting_Images_with_Special_Values>
> > addresses my problem, but I cannot get it to work.  After changing
> > instances of matplotlib.numerix to numpy, I get a long list of
> > exceptions, the last of which is
> > TypeError: __call__() got an unexpected keyword argument 'bytes'.
> > This has to do with sentinelNorm, I think, but I'm not sure how to fix it.
> 
> I think I would tackle this by writing a Norm that doesn't change
> negative values, and you might mask then the oceans by -0.5, and the
> nans by -1.5.  Then, you might create a colormap comprised of the
> ocean color for [-1, 0] and the nan color for [-2, -1], and for the
> normal normed range [0, 1] the normal Blues cm.  Have a look at cm.py
> and _cm.py how it works.  Basically, you can specify for all sections
> of the colormap the left and right color.  So you can mix discrete
> maps with continuous ones, because the continuous ones are just
> linearly interpolated with matching colors for left/right at each
> boundary position.  Looking at the code will clarify things a lot I
> believe.
> 
> I don't know what went wrong with the cb example you said.  From a
> quick look, it seems to have "sentinel rgb values", but this is not
> what we want, right?
> 
> > Eventually I would like to sub-classify missing data by the type of
> > missing input that caused a missing value, but for now a single
> > missing data color is enough.
> 
> That would be possible with the approach above, by just adding
> sections below zero.
> 
> _cm.py: Definitions of colormaps, like Blues.
> cm.py: among other things, how to load such specifications.
> colors.py: Defines Colormaps, and Norms.  Have a look at both of them,
> esp. at :class:`Normalize`.  I would subclass the Norm mentioned above
> from Normalize.
> 
> I hope this helps you,
> Friedrich
> 

------------------------------------------------------------------------------
This SF Dev2Dev email is sponsored by:

WikiLeaks The End of the Free Internet
http://p.sf.net/sfu/therealnews-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to