cfdm.NetCDF4Array.__getitem__¶
-
NetCDF4Array.
__getitem__
(index)[source]¶ Returns a subspace of the data as a new
NetCDF4Array
.x.__getitem__(indices) <==> x[indices]
Subspaces created by indexing are lazy and are not applied until the
NetCDF4Array
object is converted to anumpy
array, by which time all lazily-defined subspaces will have been converted to a single combined index which defines only the actual elements that need to be retrieved from the original data.The combined index is orthogonal, meaning that the index for each dimension is to be applied independently, regardless of how that index was defined. For instance, the indices
[[0, 1], [1, 3], 0]
and[:2, 1::2, 0]
will give identical results.For example, if the original data has shape
(12, 145, 192)
and consecutive subspaces of[::2, [1, 3, 4], 96:]
and[[0, 5], [True, False, True], 0]
are applied, then only the elements defined by the combined index``[[0, 10], [1, 4], 96]`` will be retrieved from the data when__array__
is called.New in version (cfdm): 1.11.2.0
See also
index
,original_shape
,__array__
,__getitem__
- Returns
NetCDF4Array
The subspaced data.