160 """Get a slice of the underlying array
162 If only a single band is specified,
163 return the single band object sliced
166 if not isinstance(args, tuple):
174 if not isinstance(bandIndex, slice)
and len(bandIndex) == 1:
176 return self.
singles[bandIndex[0]][indices[1:]]
177 elif len(indices) == 2:
178 return self.
singles[bandIndex[0]][indices[1]]
180 return self.
singles[bandIndex[0]]
182 return self.
_slice(bands=bands, bandIndex=bandIndex, indices=indices[1:])
197 """Convert a list of band names to an index or a slice
201 bandIndex: iterable or `object`
202 Index to specify a band or list of bands,
203 usually a string or enum.
204 For example `bandIndex` can be
205 `"R"` or `["R", "G", "B"]` or `[Band.R, Band.G, Band.B]`,
206 if `Band` is an enum.
211 Names of the bands in the slice
212 bandIndex: `slice` or `list` of `int`
213 Index of each band in `bandNames` in
216 if isinstance(bandIndex, slice):
217 if bandIndex.start
is not None:
218 start = self.
bands.index(bandIndex.start)
221 if bandIndex.stop
is not None:
222 stop = self.
bands.index(bandIndex.stop)
225 bandIndices = slice(start, stop, bandIndex.step)
226 bandNames = self.
bands[bandIndices]
228 if isinstance(bandIndex, str):
229 bandNames = [bandIndex]
230 bandIndices = [self.
bands.index(bandIndex)]
234 bandNames = [f
for f
in bandIndex]
236 bandNames = [bandIndex]
237 bandIndices = [self.
bands.index(f)
for f
in bandNames]
238 return tuple(bandNames), bandIndices