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(feature, filter_func, filter_features=Ellipsis)
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 a numpy array and returns a bool.
filter_features (Any) – A collection of features which will be filtered into a new EOPatch
- class eolearn.features.feature_manipulation.FilterTimeSeriesTask(start_date, end_date, filter_features=Ellipsis)
Removes all frames in the time-series with dates outside the user specified time interval.
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.
- class eolearn.features.feature_manipulation.ValueFilloutTask(feature, operations='fb', value=nan, axis=0)
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
- static fill(data, value=nan, operation='f')
Fills occurrences of a desired value in a 2d array with their neighbors in either forward or backward direction.
data (numpy.ndarray) – A 2d numpy array.
value (any numpy dtype) – Which value to fill by its neighbors.
operation (str) – Fill directions, which should be either ‘f’ or ‘b’.
Value-filled numpy array.
- Return type
- class eolearn.features.feature_manipulation.LinearFunctionTask(input_features, output_features=None, slope=1, intercept=0, dtype=None)
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.
input_features – Feature or features on which the function is used.
output_features – 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.
- class eolearn.features.feature_manipulation.SpatialResizeTask(*, resize_parameters, features=Ellipsis, resize_method=ResizeMethod.LINEAR, resize_library=ResizeLib.PIL)
Resizes the specified spatial features of EOPatch.
features (Any) – The specification of feature for which to perform resizing. Must be supported by the
FeatureParser. Features can be renamed, see FeatureParser documentation.
new_size – New size of the data (height, width)
scale_factors – Factors (f_height, f_width) by which to resize the image
resize_method (eolearn.features.utils.ResizeMethod) – Interpolation method used for resizing.
resize_library (eolearn.features.utils.ResizeLib) – Which Python library to use for resizing. Default is PIL, as it supports all dtypes and features anti-aliasing. For cases where execution speed is crucial one can use CV2.