[Numpy-discussion] Advice on masked array implementation

Fred Clare fred@ucar....
Mon Feb 26 13:51:42 CST 2007


We would like some advice on how to proceed with implementing
masked array capabilities in a large package of climate-related
analysis functions.  We are in the initial stages of trying to
duplicate functionality from an existing package written in a
locally-developed scripting language.  The existing functionality
depends heavily on masked arrays (actually on variables with
attributes, with "fill_value" being one such).

We have polled our user base and, while all responders plan to
convert to NumPy, many have not started the conversion or are in
transition.  It is our experience that converting users to
new ways is usually a multi-year undertaking, so it seems
that we may need to support both Numeric and NumPy installations
for some time to come.  Even if people have converted to the
NumPy version of our package, they may still be importing
packages that have not been converted.

Our initial design attempts to deal with the possibility
of users potentially mixing (or using exclusively) Numeric
arrays, Numeric masked arrays, NumPy arrays, and NumPy masked
arrays.  For example, suppose you have a function:

    result = func(arg0, arg1)

where the two arguments and return variable can be any one of
the four types of arrays mentioned.  Currently we are testing
to see if either argument is a NumPy or Numeric masked array.
If just Numeric masked arrays, then we return a Numeric masked
array.  If just NumPy masked arrays, then we return a NumPy
masked array.  If one is a Numeric masked array and the other
is a NumPy masked array, then we return a NumPy masked array.
Similar checking is done for using just Numeric and/or NumPy
non-masked arrays.  Does this seem like a reasonable approach?

It is tempting just to go with NumPy, but then we will have a
large class of users who cannot access the new functionality.

We have followed the discussion on the development of the new
maskedarray module, but have not used it.  I went to

http://projects.scipy.org/scipy/numpy/attachment/wiki/MaskedArray/ 
maskedarray.py

as referenced in a posting from Pierre GM, but I got "Internal Error."

Has there been any decision as to whether maskedarray will be
in NumPy version 1.1?  Any estimate as to when 1.1 would be out?
If we commit to numpy.core.ma now, how much trouble will it be
to convert to the new maskedarray?  Is there any user documentation
on maskedarray and details on the differences between it and
numpy.core.ma?

Thanks,

Fred Clare



More information about the Numpy-discussion mailing list