cfdm.Bounds.__getitem__¶
-
Bounds.
__getitem__
(indices)[source]¶ Return a subspace defined by indices.
f.__getitem__(indices) <==> f[indices]
Indexing follows rules that are very similar to the numpy indexing rules, the only differences being:
An integer index i takes the i-th element but does not reduce the rank by one.
When two or more dimensions’ indices are sequences of integers then these indices work independently along each dimension (similar to the way vector subscripts work in Fortran). This is the same behaviour as indexing on a Variable object of the netCDF4 package.
New in version (cfdm): 1.7.0
- Returns
The subspace.
Examples
>>> f.shape (1, 10, 9) >>> f[:, :, 1].shape (1, 10, 1) >>> f[:, 0].shape (1, 1, 9) >>> f[..., 6:3:-1, 3:6].shape (1, 3, 3) >>> f[0, [2, 9], [4, 8]].shape (1, 2, 2) >>> f[0, :, -2].shape (1, 10, 1)