eolearn.features.feature_manipulation

Module for basic feature manipulations, i.e. removing a feature from EOPatch, or removing a slice (time-frame) from the time-dependent features.

class eolearn.features.feature_manipulation.SimpleFilterTask(*args, **kwargs)[source]

Bases: eolearn.core.eotask.EOTask

Transforms an eopatch of shape [n, w, h, d] into [m, w, h, d] for m <= n. It removes all slices which don’t conform to the filter_func.

A filter_func is a callable which takes an numpy array and returns a bool.

Parameters
  • feature ((FeatureType, str)) – Feature in the EOPatch , e.g. feature=(FeatureType.DATA, ‘bands’)

  • filter_func (object) – A callable that takes a numpy evaluates to bool.

  • filter_features (dict(FeatureType: set(str))) – A collection of features which will be filtered

execute(eopatch)[source]
Parameters

eopatch (EOPatch) – Input EOPatch.

Returns

Transformed eo patch

Return type

EOPatch

class eolearn.features.feature_manipulation.FilterTimeSeriesTask(*args, **kwargs)[source]

Bases: eolearn.features.feature_manipulation.SimpleFilterTask

Removes all frames in the time-series with dates outside the user specified time interval.

Parameters
  • start_date (datetime.datetime) – Start date. All frames within the time-series taken after this date will be kept.

  • end_date (datetime.datetime) – End date. All frames within the time-series taken before this date will be kept.

  • filter_features (dict(FeatureType: set(str))) – A collection of features which will be filtered

class eolearn.features.feature_manipulation.ValueFilloutTask(*args, **kwargs)[source]

Bases: eolearn.core.eotask.EOTask

Overwrites occurrences of a desired value with their neighbor values in either forward, backward direction or both, along an axis.

Possible fillout operations are ‘f’ (forward), ‘b’ (backward) or both, ‘fb’ or ‘bf’:

‘f’: nan, nan, nan, 8, 5, nan, 1, 0, nan, nan -> nan, nan, nan, 8, 5, 5, 1, 0, 0, 0

‘b’: nan, nan, nan, 8, 5, nan, 1, 0, nan, nan -> 8, 8, 8, 8, 5, 1, 1, 0, nan, nan

‘fb’: nan, nan, nan, 8, 5, nan, 1, 0, nan, nan -> 8, 8, 8, 8, 5, 5, 1, 0, 0, 0

‘bf’: nan, nan, nan, 8, 5, nan, 1, 0, nan, nan -> 8, 8, 8, 8, 5, 1, 1, 0, 0, 0

Parameters
  • feature (an object supported by the FeatureParser) – A feature that must be value-filled.

  • operations (str) – Fill directions, which should be one of [‘f’, ‘b’, ‘fb’, ‘bf’].

  • value (any numpy dtype) – Which value to fill by it’s neighbors.

  • axis (int) – An axis along which to fill values.

static fill(data, value=nan, operation='f')[source]

Fills occurrences of a desired value in a 2d array with their neighbors in either forward or backward direction.

Parameters
  • data (numpy.ndarray) – A 2d numpy array.

  • value (any numpy dtype) – Which value to fill by it’s neighbors.

  • operation (str) – Fill directions, which should be either ‘f’ or ‘b’.

Returns

Value-filled numpy array.

Return type

numpy.ndarray

execute(eopatch)[source]
Parameters

eopatch (EOPatch) – Source EOPatch from which to read the feature data.

Returns

An eopatch with the value-filled feature.

Return type

EOPatch

class eolearn.features.feature_manipulation.FilterTimeSeries(*args, **kwargs)[source]

Bases: eolearn.features.feature_manipulation.FilterTimeSeriesTask

A deprecated version of FilterTimeSeriesTask

Parameters
  • start_date (datetime.datetime) – Start date. All frames within the time-series taken after this date will be kept.

  • end_date (datetime.datetime) – End date. All frames within the time-series taken before this date will be kept.

  • filter_features (dict(FeatureType: set(str))) – A collection of features which will be filtered