Curve fitting#
- class eocrops.tasks.curve_fitting.CurveFitting(range_doy=(1, 365), q=0.5)[source]#
Bases:
object
Methods
fit_whitakker
(ts_mean, degree_smoothing[, ...])Fit whitakker smoothing given a ndarray (1,T,D)
get_doy_period
(eopatch)Get day of the year acquisition dates from eopatch.timestamp
get_time_series_profile
(eopatch, feature[, ...])Get aggregated time series at the object level, i.e. aggregate all pixels not masked.
replace_values
(eopatch, ts_mean, doy_o, ...)Given an interpolated time series using a curve fitting method, replace interpolated values with the nearest observed one iif the image had less than a given cloud coverage
resample_ts
(doy, ts_mean_[, resampling, ...])Apply resampling over fixed period before applying whitakker smoothing
whittaker_zonal
(eopatch, feature[, ...])Apply whitakker smoothing over time series
- get_time_series_profile(eopatch, feature, feature_mask='MASK', threshold=None, resampling=None)[source]#
Get aggregated time series at the object level, i.e. aggregate all pixels not masked
- Parameters:
- eopatchEOPatch
EOPatch saved
- featurestr
Name of the feature
- feature_maskstr
Name of the boolean mask for pixels outside field boundaries
- Returns:
- Aggregated 1-d time series (np.array)
- get_doy_period(eopatch)[source]#
Get day of the year acquisition dates from eopatch.timestamp
- Parameters:
- eopatchEOPatch
eopatch to read
- Returns:
- np.arrayday of the years, np.arrayindex of image within the season (range_doy)
- replace_values(eopatch, ts_mean, doy_o, ts_fitted, doy_r, resampling, cloud_coverage=0.05)[source]#
Given an interpolated time series using a curve fitting method, replace interpolated values with the nearest observed one iif the image had less than a given cloud coverage
- Parameters:
- eopatchEOPatch
- ts_mean :np.array)the original observed time series at the field-level
- doy_onp.array)
days of the year from the observed scene
- ts_fittednp.array
fitted time series using a cure fitting method
- doy_rnp.array
resampled day of the year
- resamplingint
period length to resample time series (e.g. 8 for 8-day period starting on the 1st January)
- cloud_coveragefloat
maximum percentage of cloud given an image (e.g. we keep only values if <5% cloudy)
- Returns:
- Fitted time series mixing interpolated and observed values
- resample_ts(doy, ts_mean_, resampling=8, min_threshold=None, max_threshold=None)[source]#
Apply resampling over fixed period before applying whitakker smoothing
- fit_whitakker(ts_mean, degree_smoothing, weighted=False, min_threshold=0)[source]#
Fit whitakker smoothing given a ndarray (1,T,D)
- whittaker_zonal(eopatch, feature, feature_mask='MASK', degree_smoothing=1, min_threshold=0, max_threshold=None, weighted=False, resampling=8)[source]#
Apply whitakker smoothing over time series
- Parameters:
- eopatchEOPatch
eopatch to apply the smoothing method
- featurestr
Feature to apply the smoothing (e.g. NDVI)
- feature_maskstr
Feature that refers to the pixel masking outside the field polygon
- degree_smoothingfloat
Degree of smoothing (0.5 works great)
- min_thresholdfloat
Minimum threshold of the time series. If it is below, we mask as np.nan to avoid outlier values
- max_thresholdfloat
Minimum threshold of the time sereis. If it is above, we mask as np.nan to avoid outlier values
- weightedbool
Weight the smoother w.r.t. the maximimum value to better fit the enveloppe over high value data
- resamplingint
Resample over fixed periods from the 1st of January
- Returns:
- np.arrayday of the year, np.arrayaggregated time series
- class eocrops.tasks.curve_fitting.AsymmetricGaussian(**kwargs)[source]#
Bases:
CurveFitting
Methods
execute
(eopatch, feature[, feature_mask, ...])Execute A-G curve fitting function
fit_whitakker
(ts_mean, degree_smoothing[, ...])Fit whitakker smoothing given a ndarray (1,T,D)
get_doy_period
(eopatch)Get day of the year acquisition dates from eopatch.timestamp
get_fitted_values
(eopatch, feature[, ...])Apply Asymmetric function to do curve fitting from aggregated time series.
get_time_series_profile
(eopatch, feature[, ...])Get aggregated time series at the object level, i.e. aggregate all pixels not masked.
replace_values
(eopatch, ts_mean, doy_o, ...)Given an interpolated time series using a curve fitting method, replace interpolated values with the nearest observed one iif the image had less than a given cloud coverage
resample_ts
(doy, ts_mean_[, resampling, ...])Apply resampling over fixed period before applying whitakker smoothing
whittaker_zonal
(eopatch, feature[, ...])Apply whitakker smoothing over time series
- get_fitted_values(eopatch, feature, feature_mask='MASK', resampling=0, threshold=0)[source]#
Apply Asymmetric function to do curve fitting from aggregated time series. It aims to reconstruct, smooth and extract phenological parameters from time series
- Parameters:
- eopatchEOPatch
- featurestr
name of the feature to process
- feature_maskstr
name of the polygon mask
- functionnp.function
function to aggregate pixels at object level
- resamplingnp.array
dates from reconstructed time series, np.array : aggregated time series)
- Returns:
- np.arraydoy, np.arrayfitted values
- class eocrops.tasks.curve_fitting.DoublyLogistic(**kwargs)[source]#
Bases:
CurveFitting
Methods
execute
(eopatch, feature[, feature_mask, ...])Execute the smoothing at the field level
fit_whitakker
(ts_mean, degree_smoothing[, ...])Fit whitakker smoothing given a ndarray (1,T,D)
get_doy_period
(eopatch)Get day of the year acquisition dates from eopatch.timestamp
get_fitted_values
(eopatch, feature[, ...])Apply Doubly Logistic function to do curve fitting from aggregated time series.
get_time_series_profile
(eopatch, feature[, ...])Get aggregated time series at the object level, i.e. aggregate all pixels not masked.
replace_values
(eopatch, ts_mean, doy_o, ...)Given an interpolated time series using a curve fitting method, replace interpolated values with the nearest observed one iif the image had less than a given cloud coverage
resample_ts
(doy, ts_mean_[, resampling, ...])Apply resampling over fixed period before applying whitakker smoothing
whittaker_zonal
(eopatch, feature[, ...])Apply whitakker smoothing over time series
- get_fitted_values(eopatch, feature, feature_mask='MASK', resampling=0, threshold=0.2)[source]#
Apply Doubly Logistic function to do curve fitting from aggregated time series. It aims to reconstruct, smooth and extract phenological parameters from time series
- Parameters:
- eopatchEOPatch
- featurestr
name of the feature to process
- feature_maskstr
name of the polygon mask
- functionnp.function
function to aggregate pixels at object level
- resamplingnp.array
dates from reconstructed time series, np.array : aggregated time series)
- Returns:
- np.arraydoy, np.arrayfitted values
- class eocrops.tasks.curve_fitting.FourierDiscrete(omega=1.5, **kwargs)[source]#
Bases:
CurveFitting
Methods
execute
(eopatch, feature[, feature_mask, ...])Execute FFT
fit_whitakker
(ts_mean, degree_smoothing[, ...])Fit whitakker smoothing given a ndarray (1,T,D)
get_doy_period
(eopatch)Get day of the year acquisition dates from eopatch.timestamp
get_fitted_values
(eopatch, feature[, ...])Apply Fourier function to do curve fitting from aggregated time series.
get_time_series_profile
(eopatch, feature[, ...])Get aggregated time series at the object level, i.e. aggregate all pixels not masked.
replace_values
(eopatch, ts_mean, doy_o, ...)Given an interpolated time series using a curve fitting method, replace interpolated values with the nearest observed one iif the image had less than a given cloud coverage
resample_ts
(doy, ts_mean_[, resampling, ...])Apply resampling over fixed period before applying whitakker smoothing
whittaker_zonal
(eopatch, feature[, ...])Apply whitakker smoothing over time series
- get_fitted_values(eopatch, feature, feature_mask='MASK', resampling=0, fft=True, threshold=0.2)[source]#
Apply Fourier function to do curve fitting from aggregated time series. It aims to reconstruct, smooth and extract phenological parameters from time series
- Parameters:
- eopatchEOPatch
- featurestr
name of the feature to process
- feature_maskstr
name of the polygon mask
- functionnp.function
function to aggregate pixels at object level
- resamplingnp.array
dates from reconstructed time series, np.array : aggregated time series)
- Returns:
- np.arraydoy, np.arrayfitted values