paidiverpy.sampling_layer#

__init__.py for resample_layer module.

Submodules#

Classes#

SamplingLayer

Process the images in the resample layer.

Package Contents#

class paidiverpy.sampling_layer.SamplingLayer(parameters: dict[str, Any], config_params: dict[str, Any] | paidiverpy.config.config_params.ConfigParams | None = None, config_file_path: str | None = None, config: paidiverpy.config.configuration.Configuration | None = None, metadata: paidiverpy.metadata_parser.MetadataParser | None = None, images: paidiverpy.images_layer.ImagesLayer | None = None, paidiverpy: paidiverpy.Paidiverpy | None = None, step_name: str | None = None, client: dask.distributed.Client | None = None, config_index: int | None = None, logger: logging.Logger | None = None, raise_error: bool = False, verbose: int = 2)[source]#

Bases: paidiverpy.Paidiverpy

Process the images in the resample layer.

Parameters:
  • parameters (dict) – The parameters for the step.

  • config_params (dict | ConfigParams, optional) – The configuration parameters. It can contain the following keys / attributes: - input_path (str): The path to the input files. - output_path (str): The path to the output files. - metadata_path (str): The path to the metadata file. - metadata_type (str): The type of the metadata file. - track_changes (bool): Whether to track changes. - n_jobs (int): The number of n_jobs.

  • config_file_path (str) – The path to the configuration file.

  • config (Configuration) – The configuration object.

  • metadata (MetadataParser) – The metadata object.

  • images (ImagesLayer) – The images object.

  • paidiverpy (Paidiverpy) – The paidiverpy object.

  • step_name (str) – The name of the step.

  • client (Client) – The Dask client.

  • config_index (int) – The index of the configuration.

  • logger (logging.Logger) – The logger object.

  • raise_error (bool) – Whether to raise an error.

  • verbose (int) – verbose level (0 = none, 1 = errors/warnings, 2 = info).

run(add_new_step: bool = True) None | pandas.DataFrame[source]#

Run the resample layer steps on the images based on the configuration.

Parameters:

add_new_step (bool, optional) – Whether to add a new step. Defaults to True.

Raises:

ValueError – The mode is not defined in the configuration file.

Returns:

The result of the resample layer step.

Return type:

None | pd.DataFrame

static compute_mean(img: numpy.ndarray[Any, Any], height: int, width: int, bits: int) numpy.ndarray[Any, Any][source]#

Compute the mean of the image bands.

Parameters:
  • img (np.ndarray) – The input image array.

  • height (int) – The height of the image.

  • width (int) – The width of the image.

  • bits (int) – The bit depth of the image.

Returns:

The computed mean values for each band.

Return type:

np.ndarray