Package numpy :: Package core :: Module ma
[hide private]
[frames] | no frames]

Module ma

source code

MA: a facility for dealing with missing observations MA is generally used as a numpy.array look-alike. by Paul F. Dubois.

Copyright 1999, 2000, 2001 Regents of the University of California. Released for unlimited redistribution. Adapted for numpy_core 2005 by Travis Oliphant and (mainly) Paul Dubois.

Classes [hide private]
  MAError
  MaskedArray
Arrays with possibly masked values.
  _MaskedPrintOption
One instance of this class, masked_print_option, is created.
  _maximum_operation
Object to calculate maxima
  _minimum_operation
Object to calculate minima
  array
Arrays with possibly masked values.
  domain_check_interval
domain_check_interval(a,b)(x) = true where x < a or y > b
  domain_greater
domain_greater(v)(x) = true where x <= v
  domain_greater_equal
domain_greater_equal(v)(x) = true where x < v
  domain_safe_divide
  domain_tan
domain_tan(eps) = true where abs(cos(x)) < eps)
  domained_binary_operation
Binary operations that have a domain, like divide.
  masked_binary_operation
  masked_unary_operation
Functions [hide private]
 
_clip(self, a_min, a_max, out=None) source code
 
_cumprod(self, axis=None, dtype=None, out=None) source code
 
_cumsum(self, axis=None, dtype=None, out=None) source code
 
_ptp(a, axis=None, out=None) source code
 
_squeeze(self) source code
 
_std(self, axis=None, dtype=None, out=None) source code
 
_swapaxes(self, axis1, axis2) source code
 
_var(self, axis=None, dtype=None, out=None) source code
 
allclose(a, b, fill_value=1, rtol=1e-05, atol=1e-08)
Returns true if all components of a and b are equal subject to given tolerances.
source code
 
allequal(a, b, fill_value=1)
True if all entries of a and b are equal, using fill_value as a truth value where either or both are masked.
source code
 
alltrue(target, axis=0, dtype=None)
Reduce target along the given axis with this function.
source code
 
arange(start, stop=None, step=1, dtype=None)
Just like range() except it returns a array whose type can be specified by the keyword argument dtype.
source code
 
argmax(x, axis=-1, out=None, fill_value=None)
Treating masked values as if they have the value fill_value, return sort indices for maximum along given axis.
source code
 
argmin(x, axis=-1, out=None, fill_value=None)
Treating masked values as if they have the value fill_value, return indices for minimum values along given axis.
source code
 
argsort(x, axis=-1, out=None, fill_value=None)
Treating masked values as if they have the value fill_value, return sort indices for sorting along given axis.
source code
 
arrayrange(start, stop=None, step=1, dtype=None)
Just like range() except it returns a array whose type can be specified by the keyword argument dtype.
source code
 
asarray(data, dtype=None)
asarray(data, dtype) = array(data, dtype, copy=0)
source code
 
average(a, axis=None, weights=None)
Computes average along indicated axis.
source code
 
choose(indices, t, out=None, mode='raise')
Returns array shaped like indices with elements chosen from t
source code
 
common_fill_value(a, b)
The common fill_value of a and b, if there is one, or None
source code
 
compress(condition, x, dimension=-1, out=None)
Select those parts of x for which condition is true.
source code
 
concatenate(arrays, axis=0)
Concatenate the arrays along the given axis
source code
 
count(a, axis=None)
Count of the non-masked elements in a, or along a certain axis.
source code
 
default_fill_value(obj)
Function to calculate default fill value for an object.
source code
 
diagonal(a, k=0, axis1=0, axis2=1)
diagonal(a,k=0,axis1=0, axis2=1) = the k'th diagonal of a
source code
 
dot(a, b)
dot(a,b) returns matrix-multiplication between a and b.
source code
 
filled(a, value=None)
a as a contiguous numeric array with any masked areas replaced by value if value is None or the special element "masked", get_fill_value(a) is used instead.
source code
 
fromfunction(f, s)
apply f to s to create array as in umath.
source code
 
fromstring(s, t)
Construct a masked array from a string.
source code
 
get_fill_value(a)
The fill value of a, if it has one; otherwise, the default fill value for that type.
source code
 
getmask(a)
Mask of values in a; could be nomask.
source code
 
getmaskarray(a)
Mask of values in a; an array of zeros if mask is nomask or not a masked array, and is a byte-sized integer.
source code
 
identity(n)
identity(n) returns the identity matrix of shape n x n.
source code
 
indices(dimensions, dtype=None)
indices(dimensions,dtype=None) returns an array representing a grid of indices with row-only, and column-only variation.
source code
 
inner(a, b)
inner(a,b) returns the dot product of two arrays, which has shape a.shape[:-1] + b.shape[:-1] with elements computed by summing the product of the elements from the last dimensions of a and b.
source code
 
innerproduct(a, b)
inner(a,b) returns the dot product of two arrays, which has shape a.shape[:-1] + b.shape[:-1] with elements computed by summing the product of the elements from the last dimensions of a and b.
source code
 
isMA(x)
Is x a masked array, that is, an instance of MaskedArray?
source code
 
isMaskedArray(x)
Is x a masked array, that is, an instance of MaskedArray?
source code
 
is_mask(m)
Is m a legal mask? Does not check contents, only type.
source code
 
isarray(x)
Is x a masked array, that is, an instance of MaskedArray?
source code
 
left_shift(a, n)
Left shift n bits
source code
 
make_mask(m, copy=0, flag=0)
return m as a mask, creating a copy if necessary or requested.
source code
 
make_mask_none(s)
Return a mask of all zeros of shape s.
source code
 
mask_or(m1, m2)
Logical or of the mask candidates m1 and m2, treating nomask as false.
source code
 
masked_array(a, mask=False, fill_value=None)
masked_array(a, mask=nomask) = array(a, mask=mask, copy=0, fill_value=fill_value)
source code
 
masked_equal(x, value, copy=1)
masked_equal(x, value) = x masked where x == value For floating point consider masked_values(x, value) instead.
source code
 
masked_greater(x, value, copy=1)
masked_greater(x, value) = x masked where x > value
source code
 
masked_greater_equal(x, value, copy=1)
masked_greater_equal(x, value) = x masked where x >= value
source code
 
masked_inside(x, v1, v2, copy=1)
x with mask of all values of x that are inside [v1,v2] v1 and v2 can be given in either order.
source code
 
masked_less(x, value, copy=1)
masked_less(x, value) = x masked where x < value
source code
 
masked_less_equal(x, value, copy=1)
masked_less_equal(x, value) = x masked where x <= value
source code
 
masked_not_equal(x, value, copy=1)
masked_not_equal(x, value) = x masked where x != value
source code
 
masked_object(data, value, copy=1)
Create array masked where exactly data equal to value
source code
 
masked_outside(x, v1, v2, copy=1)
x with mask of all values of x that are outside [v1,v2] v1 and v2 can be given in either order.
source code
 
masked_values(data, value, rtol=1.e-5, atol=1.e-8)
Create a masked array; mask is nomask if possible.
source code
 
masked_where(condition, x, copy=1)
Return x as an array masked where condition is true.
source code
 
maximum_fill_value(obj)
Function to calculate default fill value suitable for taking maxima.
source code
 
minimum_fill_value(obj)
Function to calculate default fill value suitable for taking minima.
source code
 
nonzero(a)
returns the indices of the elements of a which are not zero and not masked
source code
 
ones(shape, dtype=<type 'float'>)
ones(n, dtype=float) = an array of all ones of the given length or shape.
source code
 
outer(a, b)
outer(a,b) = {a[i]*b[j]}, has shape (len(a),len(b))
source code
 
outerproduct(a, b)
outer(a,b) = {a[i]*b[j]}, has shape (len(a),len(b))
source code
 
power(a, b, third=None)
a**b
source code
 
product(target, axis=None, dtype=None) source code
 
put(a, indices, values, mode='raise')
sets storage-indexed locations to corresponding values.
source code
 
putmask(a, mask, values)
putmask(a, mask, values) sets a where mask is true.
source code
 
rank(object) source code
 
ravel(a)
a as one-dimensional, may share data and mask
source code
 
repeat(a, repeats, axis=None)
repeat elements of a repeats times along axis repeats is a sequence of length a.shape[axis] telling how many times to repeat each element.
source code
 
reshape(a, *newshape)
Copy of a with a new shape.
source code
 
resize(a, new_shape)
resize(a, new_shape) returns a new array with the specified shape.
source code
 
right_shift(a, n)
Right shift n bits
source code
 
set_fill_value(a, fill_value)
Set fill value of a if it is a masked array.
source code
 
shape(object) source code
 
size(object, axis=None) source code
 
sometrue(target, axis=0, dtype=None)
Reduce target along the given axis with this function.
source code
 
sort(x, axis=-1, fill_value=None)
If x does not have a mask, return a masked array formed from the result of numeric.sort(x, axis).
source code
 
sum(target, axis=None, dtype=None) source code
 
swapaxes(a, axis1, axis2) source code
 
take(a, indices, axis=None, out=None, mode='raise')
returns selection of items from a.
source code
 
trace(a, offset=0, axis1=0, axis2=1, dtype=None, out=None)
trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals (defined by the last two dimenions) of the array.
source code
 
transpose(a, axes=None)
reorder dimensions per tuple axes
source code
 
where(condition, x, y)
where(condition, x, y) is x where condition is nonzero, y otherwise.
source code
 
zeros(shape, dtype=<type 'float'>)
zeros(n, dtype=float) = an array of all zeros of the given length or shape.
source code
Variables [hide private]
  absolute = <numpy.core.ma.masked_unary_operation instance at 0...
  add = <numpy.core.ma.masked_binary_operation instance at 0x859...
  arccos = <numpy.core.ma.masked_unary_operation instance at 0x8...
  arccosh = <numpy.core.ma.masked_unary_operation instance at 0x...
  arcsin = <numpy.core.ma.masked_unary_operation instance at 0x8...
  arcsinh = <numpy.core.ma.masked_unary_operation instance at 0x...
  arctan = <numpy.core.ma.masked_unary_operation instance at 0x8...
  arctan2 = <numpy.core.ma.masked_binary_operation instance at 0...
  arctanh = <numpy.core.ma.masked_unary_operation instance at 0x...
  around = <numpy.core.ma.masked_unary_operation instance at 0x8...
  bitwise_and = <numpy.core.ma.masked_binary_operation instance ...
  bitwise_or = <numpy.core.ma.masked_binary_operation instance a...
  bitwise_xor = <numpy.core.ma.masked_binary_operation instance ...
  ceil = <numpy.core.ma.masked_unary_operation instance at 0x859...
  conjugate = <numpy.core.ma.masked_unary_operation instance at ...
  cos = <numpy.core.ma.masked_unary_operation instance at 0x859e...
  cosh = <numpy.core.ma.masked_unary_operation instance at 0x859...
  default_character_fill_value = '-'
  default_complex_fill_value = (1e+20+0j)
  default_integer_fill_value = 999999
  default_object_fill_value = '?'
  default_real_fill_value = 1e+20
  divide = <numpy.core.ma.domained_binary_operation instance at ...
  divide_tolerance = 1e-35
  equal = <numpy.core.ma.masked_binary_operation instance at 0x8...
  exp = <numpy.core.ma.masked_unary_operation instance at 0x859e...
  fabs = <numpy.core.ma.masked_unary_operation instance at 0x859...
  floor = <numpy.core.ma.masked_unary_operation instance at 0x85...
  floor_divide = <numpy.core.ma.domained_binary_operation instan...
  fmod = <numpy.core.ma.domained_binary_operation instance at 0x...
  greater = <numpy.core.ma.masked_binary_operation instance at 0...
  greater_equal = <numpy.core.ma.masked_binary_operation instanc...
  hypot = <numpy.core.ma.masked_binary_operation instance at 0x8...
  inf = inf
  less = <numpy.core.ma.masked_binary_operation instance at 0x85...
  less_equal = <numpy.core.ma.masked_binary_operation instance a...
  log = <numpy.core.ma.masked_unary_operation instance at 0x859e...
  log10 = <numpy.core.ma.masked_unary_operation instance at 0x85...
  logical_and = <numpy.core.ma.masked_binary_operation instance ...
  logical_not = <numpy.core.ma.masked_unary_operation instance a...
  logical_or = <numpy.core.ma.masked_binary_operation instance a...
  logical_xor = <numpy.core.ma.masked_binary_operation instance ...
  masked = array(dat...
  masked_print_option = --
  maximum = <numpy.core.ma._maximum_operation instance at 0x85a4...
  minimum = <numpy.core.ma._minimum_operation instance at 0x85a4...
  multiply = <numpy.core.ma.masked_binary_operation instance at ...
  negative = <numpy.core.ma.masked_unary_operation instance at 0...
  newaxis = None
  nomask = False
  not_equal = <numpy.core.ma.masked_binary_operation instance at...
  remainder = <numpy.core.ma.domained_binary_operation instance ...
  sin = <numpy.core.ma.masked_unary_operation instance at 0x859e...
  sinh = <numpy.core.ma.masked_unary_operation instance at 0x859...
  sqrt = <numpy.core.ma.masked_unary_operation instance at 0x859...
  subtract = <numpy.core.ma.masked_binary_operation instance at ...
  tan = <numpy.core.ma.masked_unary_operation instance at 0x859e...
  tanh = <numpy.core.ma.masked_unary_operation instance at 0x859...
  true_divide = <numpy.core.ma.domained_binary_operation instanc...
  typecodes = {'All': '?bhilqpBHILQPfdgFDGSUVO', 'AllFloat': 'fd...
  ufunc_domain = {<function round_ at 0x857f3e4>: None, <ufunc '...
  ufunc_fills = {<function round_ at 0x857f3e4>: (0), <ufunc 'lo...
Function Details [hide private]

allclose(a, b, fill_value=1, rtol=1e-05, atol=1e-08)

source code 
Returns true if all components of a and b are equal subject to given tolerances. If fill_value is 1, masked values considered equal. If fill_value is 0, masked values considered unequal. The relative error rtol should be positive and << 1.0 The absolute error atol comes into play for those elements of b that are very small or zero; it says how small a must be also.

argmax(x, axis=-1, out=None, fill_value=None)

source code 
Treating masked values as if they have the value fill_value, return sort indices for maximum along given axis. if fill_value is None, use -get_fill_value(x) if it exists. Returns a numpy array if x has more than one dimension. Otherwise, returns a scalar index.

argmin(x, axis=-1, out=None, fill_value=None)

source code 
Treating masked values as if they have the value fill_value, return indices for minimum values along given axis. if fill_value is None, use get_fill_value(x). Returns a numpy array if x has more than one dimension. Otherwise, returns a scalar index.

argsort(x, axis=-1, out=None, fill_value=None)

source code 
Treating masked values as if they have the value fill_value, return sort indices for sorting along given axis. if fill_value is None, use get_fill_value(x) Returns a numpy array.

average(a, axis=None, weights=None)

source code 

Computes average along indicated axis. If axis is None, average over the entire array Inputs can be integer or floating types; result is of type float.

If weights are given, result is sum(a*weights,axis=0)/(sum(weights,axis=0)*1.0) weights must have a's shape or be the 1-d with length the size of a in the given axis.

If returned, return a tuple: the result and the sum of the weights or count of values. Results will have the same shape.

masked values in the weights will be set to 0.0

compress(condition, x, dimension=-1, out=None)

source code 
Select those parts of x for which condition is true. Masked values in condition are considered false.

dot(a, b)

source code 
dot(a,b) returns matrix-multiplication between a and b. The product-sum is over the last dimension of a and the second-to-last dimension of b. Masked values are replaced by zeros. See also innerproduct.

filled(a, value=None)

source code 

a as a contiguous numeric array with any masked areas replaced by value if value is None or the special element "masked", get_fill_value(a) is used instead.

If a is already a contiguous numeric array, a itself is returned.

filled(a) can be used to be sure that the result is numeric when passing an object a to other software ignorant of MA, in particular to numeric itself.

fromstring(s, t)

source code 
Construct a masked array from a string. Result will have no mask.

getmask(a)

source code 
Mask of values in a; could be nomask. Returns nomask if a is not a masked array. To get an array for sure use getmaskarray.

getmaskarray(a)

source code 
Mask of values in a; an array of zeros if mask is nomask or not a masked array, and is a byte-sized integer. Do not try to add up entries, for example.

inner(a, b)

source code 
inner(a,b) returns the dot product of two arrays, which has shape a.shape[:-1] + b.shape[:-1] with elements computed by summing the product of the elements from the last dimensions of a and b. Masked elements are replace by zeros.

innerproduct(a, b)

source code 
inner(a,b) returns the dot product of two arrays, which has shape a.shape[:-1] + b.shape[:-1] with elements computed by summing the product of the elements from the last dimensions of a and b. Masked elements are replace by zeros.

make_mask(m, copy=0, flag=0)

source code 
return m as a mask, creating a copy if necessary or requested. Can accept any sequence of integers or nomask. Does not check that contents must be 0s and 1s. if flag, return nomask if m contains no true elements.

mask_or(m1, m2)

source code 
Logical or of the mask candidates m1 and m2, treating nomask as false. Result may equal m1 or m2 if the other is nomask.

masked_values(data, value, rtol=1.e-5, atol=1.e-8)

source code 
Create a masked array; mask is nomask if possible. If copy==0, and otherwise possible, result may share data values with original array. Let d = filled(data, value). Returns d masked where abs(data-value)<= atol + rtol * abs(value) if d is of a floating point type. Otherwise returns masked_object(d, value, copy)

masked_where(condition, x, copy=1)

source code 
Return x as an array masked where condition is true. Also masked where x or condition masked.

put(a, indices, values, mode='raise')

source code 

sets storage-indexed locations to corresponding values.

Values and indices are filled if necessary.

resize(a, new_shape)

source code 
resize(a, new_shape) returns a new array with the specified shape. The original array's total size can be any size.

sort(x, axis=-1, fill_value=None)

source code 

If x does not have a mask, return a masked array formed from the result of numeric.sort(x, axis). Otherwise, fill x with fill_value. Sort it. Set a mask where the result is equal to fill_value. Note that this may have unintended consequences if the data contains the fill value at a non-masked site.

If fill_value is not given the default fill value for x's type will be used.

where(condition, x, y)

source code 
where(condition, x, y) is x where condition is nonzero, y otherwise. condition must be convertible to an integer array. Answer is always the shape of condition. The type depends on x and y. It is integer if both x and y are the value masked.

Variables Details [hide private]

absolute

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859ea0c>

add

Value:
<numpy.core.ma.masked_binary_operation instance at 0x859ec6c>

arccos

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e6ac>

arccosh

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e80c>

arcsin

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e62c>

arcsinh

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e78c>

arctan

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e72c>

arctan2

Value:
<numpy.core.ma.masked_binary_operation instance at 0x859efac>

arctanh

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e86c>

around

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859eb2c>

bitwise_and

Value:
<numpy.core.ma.masked_binary_operation instance at 0x85a426c>

bitwise_or

Value:
<numpy.core.ma.masked_binary_operation instance at 0x85a42ac>

bitwise_xor

Value:
<numpy.core.ma.masked_binary_operation instance at 0x85a42ec>

ceil

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859ebcc>

conjugate

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e4ac>

cos

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e54c>

cosh

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e94c>

divide

Value:
<numpy.core.ma.domained_binary_operation instance at 0x859ed4c>

equal

Value:
<numpy.core.ma.masked_binary_operation instance at 0x859efcc>

exp

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e44c>

fabs

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859ea6c>

floor

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859eb6c>

floor_divide

Value:
<numpy.core.ma.domained_binary_operation instance at 0x859ee2c>

fmod

Value:
<numpy.core.ma.domained_binary_operation instance at 0x859eeec>

greater

Value:
<numpy.core.ma.masked_binary_operation instance at 0x85a414c>

greater_equal

Value:
<numpy.core.ma.masked_binary_operation instance at 0x85a40cc>

hypot

Value:
<numpy.core.ma.masked_binary_operation instance at 0x859ef4c>

less

Value:
<numpy.core.ma.masked_binary_operation instance at 0x85a410c>

less_equal

Value:
<numpy.core.ma.masked_binary_operation instance at 0x85a408c>

log

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e36c>

log10

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e3ec>

logical_and

Value:
<numpy.core.ma.masked_binary_operation instance at 0x85a418c>

logical_not

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859ec2c>

logical_or

Value:
<numpy.core.ma.masked_binary_operation instance at 0x85a41ec>

logical_xor

Value:
<numpy.core.ma.masked_binary_operation instance at 0x85a422c>

masked

Value:
array(data =
 999999,
      mask =
 True,
      fill_value=999999)

maximum

Value:
<numpy.core.ma._maximum_operation instance at 0x85a482c>

minimum

Value:
<numpy.core.ma._minimum_operation instance at 0x85a47cc>

multiply

Value:
<numpy.core.ma.masked_binary_operation instance at 0x859ed0c>

negative

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859eacc>

not_equal

Value:
<numpy.core.ma.masked_binary_operation instance at 0x85a404c>

remainder

Value:
<numpy.core.ma.domained_binary_operation instance at 0x859ee8c>

sin

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e4ec>

sinh

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e8ec>

sqrt

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e2ec>

subtract

Value:
<numpy.core.ma.masked_binary_operation instance at 0x859eccc>

tan

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e5cc>

tanh

Value:
<numpy.core.ma.masked_unary_operation instance at 0x859e9ac>

true_divide

Value:
<numpy.core.ma.domained_binary_operation instance at 0x859edcc>

typecodes

Value:
{'All': '?bhilqpBHILQPfdgFDGSUVO',
 'AllFloat': 'fdgFDG',
 'AllInteger': 'bBhHiIlLqQpP',
 'Character': 'S1',
 'Complex': 'FDG',
 'Float': 'fdg',
 'Integer': 'bhilqp',
 'UnsignedInteger': 'BHILQP'}

ufunc_domain

Value:
{<function round_ at 0x857f3e4>: None,
 <ufunc 'logical_not'>: None,
 <ufunc 'logical_or'>: None,
 <ufunc 'logical_xor'>: None,
 <ufunc 'greater'>: None,
 <ufunc 'greater_equal'>: None,
 <ufunc 'true_divide'>: <numpy.core.ma.domain_safe_divide instance at \
0x859edac>,
...

ufunc_fills

Value:
{<function round_ at 0x857f3e4>: (0),
 <ufunc 'logical_not'>: (0),
 <ufunc 'logical_or'>: (0, 0),
 <ufunc 'logical_xor'>: (0, 0),
 <ufunc 'greater'>: (0, 0),
 <ufunc 'greater_equal'>: (0, 0),
 <ufunc 'true_divide'>: (0, 1),
 <ufunc 'hypot'>: (0, 0),
...