patcher
darts_utils.patcher
¶
Patch a dataset into smaller patches.
Patch
dataclass
¶
Patch(
i: int,
patch_idx_y: int,
patch_idx_x: int,
y: slice,
x: slice,
data: xarray.Dataset | xarray.DataArray,
)
Class representing a patch of a dataset.
PatchedDataset
¶
Class representing a dataset that has been patched into smaller patches.
Example
Via getter/setter:
tile: xr.Dataset
patches = PatchedDataset(tile, patch_size, overlap)
print(len(patches))
grey = (patches["blue"] + patches["green"] + patches["red"]) / 3 # grey is a numpy array
patches[None] = grey # Replace the data in the patches with the gray data
new_tile = patches.combine_patches()
new_tile # This is now a DataArray containing the gray data
Via loop:
Initialize the PatchedDataset.
Parameters:
-
ds
(xarray.Dataset | xarray.DataArray
) –The dataset to patch.
-
patch_size
(int
) –The size of the patches.
-
overlap
(int
) –The size of the overlap between patches.
Source code in darts-utils/src/darts_utils/patcher.py
soft_margin
instance-attribute
¶
soft_margin = margin_ramp.reshape(
1, darts_utils.patcher.PatchedDataset(patch_size)
) * margin_ramp.reshape(
darts_utils.patcher.PatchedDataset(patch_size), 1
)
__getitem__
¶
Source code in darts-utils/src/darts_utils/patcher.py
__iter__
¶
__iter__() -> collections.abc.Iterator[
darts_utils.patcher.Patch
]
__setitem__
¶
Source code in darts-utils/src/darts_utils/patcher.py
combine_patches
¶
Combine patches into a single dataarray.
Returns: