cfdm.NumpyArray.get_subspace¶
-
classmethod
NumpyArray.
get_subspace
(array, indices, copy=True)[source]¶ Return a subspace, defined by indices, of a numpy array.
Only certain type of indices are allowed. See the indices parameter for details.
Indexing is similar to numpy indexing. Given the restrictions on the type of indices allowed - see the indicies parameter - the only difference to numpy indexing is
When two or more dimension’s indices are sequences of integers then these indices work independently along each dimension (similar to the way vector subscripts work in Fortran).
New in version (cfdm): 1.8.7.0
- Parameters
- array:
numpy.ndarray
The array to be subspaced.
- indices:
The indices that define the subspace.
Must be either
Ellipsis
or a sequence that contains an index for each dimension. In the latter case, each dimension’s index must either be aslice
object or a sequence of two or more integers.- Parameter example:
indices=Ellipsis
- Parameter example:
indices=[[5, 7, 8]]
- Parameter example:
indices=[slice(4, 7)]
- Parameter example:
indices=[slice(None), [5, 7, 8]]
- Parameter example:
indices=[[2, 5, 6], slice(15, 4, -2), [8, 7, 5]]
- copy:
bool
If
False
then the returned subspace may (or may not) be independent of the input array. By default the returned subspace is independent of the input array.
- array:
- Returns