MaskedNDArray#
 class astropy.utils.masked.MaskedNDArray(*args, mask=None, **kwargs)[source]#

Masked version of ndarray.
Except for the ability to pass in a
mask
, parameters are as fornumpy.ndarray
.Get data class instance from arguments and then set mask.
Attributes Summary
A 1D iterator over the Masked array.
Container for meta information like name, description, format.
The shape of the data and the mask.
The unmasked values.
Methods Summary
all
([axis, out, keepdims, where])Returns True if all elements evaluate to True.
any
([axis, out, keepdims, where])Returns True if any of the elements of
a
evaluate to True.argmax
([axis, out, keepdims])Return indices of the maximum values along the given axis.
argmin
([axis, out, keepdims])Return indices of the minimum values along the given axis.
argpartition
(kth[, axis, kind, order])Returns the indices that would partition this array.
argsort
([axis, kind, order])Returns the indices that would sort an array.
choose
(choices[, out, mode])Use an index array to construct a new array from a set of choices.
clip
([min, max, out])Return an array whose values are limited to
[min, max]
.compress
(condition[, axis, out])Return selected slices of this array along given axis.
cumprod
([axis, dtype, out])Return the cumulative product of the elements along the given axis.
cumsum
([axis, dtype, out])Return the cumulative sum of the elements along the given axis.
from_unmasked
(data[, mask, copy])Create an instance from unmasked data and a mask.
max
([axis, out, keepdims, initial, where])Return the maximum along a given axis.
mean
([axis, dtype, out, keepdims, where])Returns the average of the array elements along given axis.
min
([axis, out, keepdims, initial, where])Return the minimum along a given axis.
nonzero
()Return the indices of the elements that are nonzero.
partition
(kth[, axis, kind, order])Rearranges the elements in the array in such a way that the value of the element in kth position is in the position it would be in a sorted array.
ptp
([axis, out, keepdims])Peak to peak (maximum  minimum) value along a given axis.
repeat
(repeats[, axis])Repeat elements of an array.
sort
([axis, kind, order])Sort an array inplace.
std
([axis, dtype, out, ddof, keepdims, where])Returns the standard deviation of the array elements along given axis.
trace
([offset, axis1, axis2, dtype, out])Return the sum along diagonals of the array.
var
([axis, dtype, out, ddof, keepdims, where])Returns the variance of the array elements, along given axis.
view
([dtype, type])New view of the masked array.
Attributes Documentation
 flat#
A 1D iterator over the Masked array.
This returns a
MaskedIterator
instance, which behaves the same as theflatiter
instance returned byflat
, and is similar to Python’s builtin iterator, except that it also allows assignment.
 info#
Container for meta information like name, description, format.
 shape#
The shape of the data and the mask.
Usually used to get the current shape of an array, but may also be used to reshape the array inplace by assigning a tuple of array dimensions to it. As with
numpy.reshape
, one of the new shape dimensions can be 1, in which case its value is inferred from the size of the array and the remaining dimensions. Raises:
AttributeError
If a copy is required, of either the data or the mask.
 unmasked#
Methods Documentation
 all(axis=None, out=None, keepdims=False, *, where=True)[source]#
Returns True if all elements evaluate to True.
Refer to
numpy.all
for full documentation.See also
numpy.all
equivalent function
 any(axis=None, out=None, keepdims=False, *, where=True)[source]#
Returns True if any of the elements of
a
evaluate to True.Refer to
numpy.any
for full documentation.See also
numpy.any
equivalent function
 argmax(axis=None, out=None, *, keepdims=False)[source]#
Return indices of the maximum values along the given axis.
Refer to
numpy.argmax
for full documentation.See also
numpy.argmax
equivalent function
 argmin(axis=None, out=None, *, keepdims=False)[source]#
Return indices of the minimum values along the given axis.
Refer to
numpy.argmin
for detailed documentation.See also
numpy.argmin
equivalent function
 argpartition(kth, axis=1, kind='introselect', order=None)[source]#
Returns the indices that would partition this array.
Refer to
numpy.argpartition
for full documentation.New in version 1.8.0.
See also
numpy.argpartition
equivalent function
 argsort(axis=1, kind=None, order=None)[source]#
Returns the indices that would sort an array.
Perform an indirect sort along the given axis on both the array and the mask, with masked items being sorted to the end.
 Parameters:
 axis
int
orNone
, optional Axis along which to sort. The default is 1 (the last axis). If None, the flattened array is used.
 kind
str
orNone
, ignored. The kind of sort. Present only to allow subclasses to work.
 order
str
orlist
of str. For an array with fields defined, the fields to compare first, second, etc. A single field can be specified as a string, and not all fields need be specified, but unspecified fields will still be used, in dtype order, to break ties.
 axis
 Returns:
 choose(choices, out=None, mode='raise')[source]#
Use an index array to construct a new array from a set of choices.
Refer to
numpy.choose
for full documentation.See also
numpy.choose
equivalent function
 clip(min=None, max=None, out=None, **kwargs)[source]#
Return an array whose values are limited to
[min, max]
.Like
clip
, but any masked values inmin
andmax
are ignored for clipping. The mask of the input array is propagated.
 compress(condition, axis=None, out=None)[source]#
Return selected slices of this array along given axis.
Refer to
numpy.compress
for full documentation.See also
numpy.compress
equivalent function
 cumprod(axis=None, dtype=None, out=None)[source]#
Return the cumulative product of the elements along the given axis.
Refer to
numpy.cumprod
for full documentation.See also
numpy.cumprod
equivalent function
 cumsum(axis=None, dtype=None, out=None)[source]#
Return the cumulative sum of the elements along the given axis.
Refer to
numpy.cumsum
for full documentation.See also
numpy.cumsum
equivalent function
 classmethod from_unmasked(data, mask=None, copy=False)[source]#
Create an instance from unmasked data and a mask.
 max(axis=None, out=None, keepdims=False, initial=<no value>, where=True)[source]#
Return the maximum along a given axis.
Refer to
numpy.amax
for full documentation.See also
numpy.amax
equivalent function
 mean(axis=None, dtype=None, out=None, keepdims=False, *, where=True)[source]#
Returns the average of the array elements along given axis.
Refer to
numpy.mean
for full documentation.See also
numpy.mean
equivalent function
 min(axis=None, out=None, keepdims=False, initial=<no value>, where=True)[source]#
Return the minimum along a given axis.
Refer to
numpy.amin
for full documentation.See also
numpy.amin
equivalent function
 nonzero()[source]#
Return the indices of the elements that are nonzero.
Refer to
numpy.nonzero
for full documentation.See also
numpy.nonzero
equivalent function
 partition(kth, axis=1, kind='introselect', order=None)[source]#
Rearranges the elements in the array in such a way that the value of the element in kth position is in the position it would be in a sorted array. All elements smaller than the kth element are moved before this element and all equal or greater are moved behind it. The ordering of the elements in the two partitions is undefined.
New in version 1.8.0.
 Parameters:
 kth
int
or sequence ofint
Element index to partition by. The kth element value will be in its final sorted position and all smaller elements will be moved before it and all equal or greater elements behind it. The order of all elements in the partitions is undefined. If provided with a sequence of kth it will partition all elements indexed by kth of them into their sorted position at once.
Deprecated since version 1.22.0: Passing booleans as index is deprecated.
 axis
int
, optional Axis along which to sort. Default is 1, which means sort along the last axis.
 kind{‘introselect’}, optional
Selection algorithm. Default is ‘introselect’.
 order
str
orlist
ofstr
, optional When
a
is an array with fields defined, this argument specifies which fields to compare first, second, etc. A single field can be specified as a string, and not all fields need to be specified, but unspecified fields will still be used, in the order in which they come up in the dtype, to break ties.
 kth
See also
numpy.partition
Return a partitioned copy of an array.
argpartition
Indirect partition.
sort
Full sort.
Notes
See
np.partition
for notes on the different algorithms.Examples
>>> a = np.array([3, 4, 2, 1]) >>> a.partition(3) >>> a array([2, 1, 3, 4])
>>> a.partition((1, 3)) >>> a array([1, 2, 3, 4])
 ptp(axis=None, out=None, keepdims=False)[source]#
Peak to peak (maximum  minimum) value along a given axis.
Refer to
numpy.ptp
for full documentation.See also
numpy.ptp
equivalent function
 repeat(repeats, axis=None)[source]#
Repeat elements of an array.
Refer to
numpy.repeat
for full documentation.See also
numpy.repeat
equivalent function
 sort(axis=1, kind=None, order=None)[source]#
Sort an array inplace. Refer to
numpy.sort
for full documentation.
 std(axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True)[source]#
Returns the standard deviation of the array elements along given axis.
Refer to
numpy.std
for full documentation.See also
numpy.std
equivalent function
 trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)[source]#
Return the sum along diagonals of the array.
Refer to
numpy.trace
for full documentation.See also
numpy.trace
equivalent function
 var(axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True)[source]#
Returns the variance of the array elements, along given axis.
Refer to
numpy.var
for full documentation.See also
numpy.var
equivalent function
 view(dtype=None, type=None)[source]#
New view of the masked array.
Like
numpy.ndarray.view
, but always returning a masked array subclass.