From: Perry G. <pe...@st...> - 2005-02-22 21:03:55
|
On Feb 21, 2005, at 7:00 PM, Eric Firing wrote: > > Stephen, > >>> Are you suggesting something like this? Let each plotting function >>> have a new kwarg, perhaps called "validmask", with the same >>> dimensions as the dependent variable to be plotted, and with nonzero >>> where the variable is valid and 0 where it is missing. >> More or less, except that the mask is an attribute (?) of a >> MaskedArray object. I for one would be in favor of this capability. > > I agree that this is an alternative, but I am not sure that it is > better than what I described. It requires all the machinery of the > ma/MA module, which looks cumbersome to me. What does it gain? max > and min will do the right thing on the masked array input, so one > would not have to duplicate this inside matplotlib. It is not hard to > duplicate, however. How much more ma/MA functionality would actually > be useful? > > When it was originally developed, the MaskedArray may have been a good > way to get past Numeric's lack of nan-handling. In the long run, > however, it seems to me that Python needs a numeric module with good > nan-handling (as in Matlab and Octave), and that this will render the > Masked Array obsolete. If so, then specifying a mask as a kwarg in > matplotlib, and not using MA internally, may be simpler, more robust, > and more flexible. > > The user would still be free to use MA/ma externally, if desired. > > A variation would be to support MA/ma in matplotlib only to the extent > of checking for a MaskedArray input, and if it is present, breaking it > apart and using the mask as if it had come via the kwarg. One could > use either the kwarg or a Masked Array. > When we looked at the issue of using NaNs in place of masks or masked arrays, we concluded (well, I did anyway) that while NaNs could be used to replace masks in many instances, they could not be used in all. There are a lot of cases where people want to retain the value being masked (e.g., to do statistics on the rejected values). NaNs as masks only work for float and complex, not ints. So both approaches are useful and needed as far as I can tell. As far as keyword args go, it seems to me that they would be more convenient in many cases, but as Stephen mentions, may be a fair amount of work (and in essence, they are an attribute of the data, so that may be where they belong). Perry |