16.2 Installing and using MA

MA is one of the optional Packages and installing it requires a separate step as explained in the numarray README. To install just the MA package using Distutils, in the MA top directory enter:

python setup.py install
Use MA as a replacement for Numeric:
from MA import *
>>> x = array([1, 2, 3])
To create an array with the second element invalid, we would do:
>>> y = array([1, 2, 3], mask = [0, 1, 0])
To create a masked array where all values ``near'' 1.e20 are invalid, we can do:
>>> z = masked_values([1.0, 1.e20, 3.0, 4.0], 1.e20)
For a complete discussion of creation methods for masked arrays please see section ``Constructing masked arrays''.

The numarray module is an attribute in MA, so to execute a method foo from Numeric, you can reference it as numarray.foo.

Usually people use both MA and Numeric this way, but of course you can always fully-qualify the names:

>>> import MA
>>> x = MA.array([1, 2, 3])

The principal feature of module MA is class MaskedArray, the class whose instances are returned by the array constructors and most functions in module MA. We will discuss this class first, and later cover the attributes and functions in module MA. For now suffice it to say that among the attributes of the module are the constants from module numarray including those for declaring typecodes, NewAxis, and the mathematical constants such as pi and e. An additional typecode, MaskType, is the typecode used for masks.

Send comments to the NumArray community.