API reference
This page provides an auto-generated summary of Xbatcher’s API.
Core
- class xbatcher.BatchGenerator(ds, input_dims, input_overlap={}, batch_dims={}, concat_input_dims=False, preload_batch=True)[source]
Create generator for iterating through xarray datarrays / datasets in batches.
- Parameters
- ds
xarray.Dataset
orxarray.DataArray
The data to iterate over
- input_dimsdict
A dictionary specifying the size of the inputs in each dimension, e.g.
{'lat': 30, 'lon': 30}
These are the dimensions the ML library will see. All other dimensions will be stacked into one dimension calledbatch
.- input_overlapdict, optional
A dictionary specifying the overlap along each dimension e.g.
{'lat': 3, 'lon': 3}
- batch_dimsdict, optional
A dictionary specifying the size of the batch along each dimension e.g.
{'time': 10}
. These will always be interated over.- concat_input_dimsbool, optional
If
True
, the dimension chunks specified ininput_dims
will be concatenated and stacked into the batch dimension. IfFalse
, they will be iterated over.- preload_batchbool, optional
If
True
, each batch will be loaded into memory before reshaping / processing, triggering any dask arrays to be computed.
- ds
- Yields
- ds_slice
xarray.Dataset
orxarray.DataArray
Slices of the array matching the given batch size specification.
- ds_slice
Dataset.batch and DataArray.batch
|
Return a BatchGenerator via the batch accessor |
|
Return a BatchGenerator via the batch accessor |