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 1-D 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
aevaluate 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 non-zero.
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 in-place.
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 1-D iterator over the Masked array.
This returns a
MaskedIteratorinstance, which behaves the same as theflatiterinstance returned byflat, and is similar to Python’s built-in 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 in-place 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:
AttributeErrorIf 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.allfor full documentation.See also
numpy.allequivalent function
- any(axis=None, out=None, keepdims=False, *, where=True)[source]#
Returns True if any of the elements of
aevaluate to True.Refer to
numpy.anyfor full documentation.See also
numpy.anyequivalent function
- argmax(axis=None, out=None, *, keepdims=False)[source]#
Return indices of the maximum values along the given axis.
Refer to
numpy.argmaxfor full documentation.See also
numpy.argmaxequivalent function
- argmin(axis=None, out=None, *, keepdims=False)[source]#
Return indices of the minimum values along the given axis.
Refer to
numpy.argminfor detailed documentation.See also
numpy.argminequivalent function
- argpartition(kth, axis=-1, kind='introselect', order=None)[source]#
Returns the indices that would partition this array.
Refer to
numpy.argpartitionfor full documentation.New in version 1.8.0.
See also
numpy.argpartitionequivalent 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
intorNone, optional Axis along which to sort. The default is -1 (the last axis). If None, the flattened array is used.
- kind
strorNone, ignored. The kind of sort. Present only to allow subclasses to work.
- order
strorlistof 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.choosefor full documentation.See also
numpy.chooseequivalent 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 inminandmaxare 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.compressfor full documentation.See also
numpy.compressequivalent function
- cumprod(axis=None, dtype=None, out=None)[source]#
Return the cumulative product of the elements along the given axis.
Refer to
numpy.cumprodfor full documentation.See also
numpy.cumprodequivalent function
- cumsum(axis=None, dtype=None, out=None)[source]#
Return the cumulative sum of the elements along the given axis.
Refer to
numpy.cumsumfor full documentation.See also
numpy.cumsumequivalent 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.amaxfor full documentation.See also
numpy.amaxequivalent 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.meanfor full documentation.See also
numpy.meanequivalent function
- min(axis=None, out=None, keepdims=False, initial=<no value>, where=True)[source]#
Return the minimum along a given axis.
Refer to
numpy.aminfor full documentation.See also
numpy.aminequivalent function
- nonzero()[source]#
Return the indices of the elements that are non-zero.
Refer to
numpy.nonzerofor full documentation.See also
numpy.nonzeroequivalent 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
intor 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
strorlistofstr, optional When
ais 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.partitionReturn a partitioned copy of an array.
argpartitionIndirect partition.
sortFull sort.
Notes
See
np.partitionfor 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.ptpfor full documentation.See also
numpy.ptpequivalent function
- repeat(repeats, axis=None)[source]#
Repeat elements of an array.
Refer to
numpy.repeatfor full documentation.See also
numpy.repeatequivalent function
- sort(axis=-1, kind=None, order=None)[source]#
Sort an array in-place. Refer to
numpy.sortfor 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.stdfor full documentation.See also
numpy.stdequivalent function
- trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)[source]#
Return the sum along diagonals of the array.
Refer to
numpy.tracefor full documentation.See also
numpy.traceequivalent 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.varfor full documentation.See also
numpy.varequivalent function
- view(dtype=None, type=None)[source]#
New view of the masked array.
Like
numpy.ndarray.view, but always returning a masked array subclass.