148 """Get a slice of the underlying array
150 If only a single band is specified,
151 return the single band object sliced
154 if not isinstance(args, tuple):
162 if not isinstance(bandIndex, slice)
and len(bandIndex) == 1:
164 return self.
singles[bandIndex[0]][indices[1:]]
165 elif len(indices) == 2:
166 return self.
singles[bandIndex[0]][indices[1]]
168 return self.
singles[bandIndex[0]]
170 return self.
_slice(bands=bands, bandIndex=bandIndex, indices=indices[1:])
185 """Convert a list of band names to an index or a slice
189 bandIndex: iterable or `object`
190 Index to specify a band or list of bands,
191 usually a string or enum.
192 For example `bandIndex` can be
193 `"R"` or `["R", "G", "B"]` or `[Band.R, Band.G, Band.B]`,
194 if `Band` is an enum.
199 Names of the bands in the slice
200 bandIndex: `slice` or `list` of `int`
201 Index of each band in `bandNames` in
204 if isinstance(bandIndex, slice):
205 if bandIndex.start
is not None:
206 start = self.
bands.index(bandIndex.start)
209 if bandIndex.stop
is not None:
210 stop = self.
bands.index(bandIndex.stop)
213 bandIndices = slice(start, stop, bandIndex.step)
214 bandNames = self.
bands[bandIndices]
216 if isinstance(bandIndex, str):
217 bandNames = [bandIndex]
218 bandIndices = [self.
bands.index(bandIndex)]
222 bandNames = [f
for f
in bandIndex]
224 bandNames = [bandIndex]
225 bandIndices = [self.
bands.index(f)
for f
in bandNames]
226 return tuple(bandNames), bandIndices