eogrow.tasks.common

Common tasks shared between pipelines.

class eogrow.tasks.common.ClassFilterTask(*args, **kwargs)[source]

Bases: EOTask

Run class specific morphological operation.

Perform a morphological operation on a given feature mask

Parameters:
  • feature (Feature) – Feature to be modified

  • labels (list[int]) – List of labels to be considered for morphological operation

  • morph_operation (MorphologicalOperations) – Type of morphological operation ot perform

  • struct_elem (np.ndarray | None) – Structured element to be used. Taken from ml_tools.MorphologicalStructFactory

execute(eopatch)[source]

Override to specify action performed by task.

Parameters:

eopatch (EOPatch) –

Return type:

EOPatch

class eogrow.tasks.common.LinearFunctionTask(*args, **kwargs)[source]

Bases: MapFeatureTask

Applies a linear function to the values of input features.

Each value in the feature is modified as x -> x * slope + intercept. The dtype of the result can be customized.

Parameters:
  • input_features (FeaturesSpecification) – Feature or features on which the function is used.

  • output_features (FeaturesSpecification | None) – Feature or features for saving the result. If not provided the input_features are overwritten.

  • slope (float) – Slope of the function i.e. the multiplication factor.

  • intercept (float) – Intercept of the function i.e. the value added.

  • dtype (str | type | np.dtype | None) – Numpy dtype of the output feature. If not provided the dtype is determined by Numpy, so it is recommended to set manually.

map_method(feature, slope, intercept)[source]

A method where feature is multiplied by a slope

Parameters:
  • feature (ndarray) –

  • slope (float) –

  • intercept (float) –

Return type:

ndarray

class eogrow.tasks.common.SkippableSaveTask(*args, **kwargs)[source]

Bases: SaveTask

Same as SaveTask but can be skipped if the eopatch_folder is set to None.

Parameters:
  • path (str) – root path where all EOPatches are saved

  • filesystem (FS | None) – An existing filesystem object. If not given it will be initialized according to the path.

  • config (SHConfig | None) – A configuration object with AWS credentials. By default, is set to None and in this case the default configuration will be taken.

  • features (FeaturesSpecification) – A collection of features types specifying features of which type will be saved. By default, all features will be saved.

  • overwrite_permission (OverwritePermission) – A level of permission for overwriting an existing EOPatch to 9 (highest compression).

  • use_zarr (bool) – Saves numpy-array based features into Zarr files. Requires ZARR extra dependencies.

  • temporal_selection (None | slice | list[int] | Literal['infer']) – Writes all of the data to the chosen temporal indices of preexisting arrays. Can be used for saving data in multiple steps for memory optimization. When set to “infer” it will match the timestamps of the EOPatch to the timestamps of the stored EOPatch to calculate indices.

  • save_timestamps (bool | Literal['auto']) –

  • compress_level (int | None) –

Save_timestamps:

Save the timestamps of the EOPatch. With the “auto” setting timestamps are saved if features=… or if other temporal features are being saved.

execute(eopatch, *, eopatch_folder='', **kwargs)[source]

Saves the EOPatch to disk: folder/eopatch_folder.

Parameters:
  • eopatch (EOPatch) – EOPatch which will be saved

  • eopatch_folder (str | None) – Name of EOPatch folder containing data.

  • temporal_selection – Overrides the temporal_selection parameter of task.

  • kwargs (Any) –

Returns:

The same EOPatch

Return type:

EOPatch