s2spy.preprocess
Preprocessor for s2spy workflow.
Module Contents
Classes
Preprocessor for s2s data. |
Functions
|
Calculate the slope and intercept between two arrays using scipy's linregress. |
|
Calculate the linear trend over time. |
|
Subtract a previously calclulated linear trend from (new) data. |
|
Calculate the trend, with a certain method. Only linear is implemented. |
|
Subtract the previously calculated trend from (new) data. Only linear is implemented. |
|
Calculate the climatology of timeseries data. |
|
|
|
Check the input data for compatiblity with the preprocessor. |
|
|
|
Check if the temporal resolution of input is the same as given timescale. |
- s2spy.preprocess._linregress(x: numpy.ndarray, y: numpy.ndarray) tuple[float, float] [source]
Calculate the slope and intercept between two arrays using scipy’s linregress.
Used to make linregress more ufunc-friendly.
- Parameters:
x – First array.
y – Second array.
- Returns:
slope, intercept
- s2spy.preprocess._trend_linear(data: xarray.DataArray | xarray.Dataset) dict [source]
Calculate the linear trend over time.
- Parameters:
data – The input data of which you want to know the trend.
- Returns:
Dictionary containing the linear trend information (slope and intercept)
- s2spy.preprocess._subtract_linear_trend(data: xarray.DataArray | xarray.Dataset, trend: dict)[source]
Subtract a previously calclulated linear trend from (new) data.
- s2spy.preprocess._get_trend(data: xarray.DataArray | xarray.Dataset, method: str)[source]
Calculate the trend, with a certain method. Only linear is implemented.
- s2spy.preprocess._subtract_trend(data: xarray.DataArray | xarray.Dataset, method: str, trend: dict)[source]
Subtract the previously calculated trend from (new) data. Only linear is implemented.
- s2spy.preprocess._get_climatology(data: xarray.Dataset | xarray.DataArray, timescale: Literal[monthly, weekly, daily])[source]
Calculate the climatology of timeseries data.
- s2spy.preprocess._subtract_climatology(data: xarray.Dataset | xarray.DataArray, timescale: Literal[monthly, weekly, daily], climatology: xarray.Dataset | xarray.DataArray)[source]
- s2spy.preprocess._check_input_data(data: xarray.DataArray | xarray.Dataset)[source]
Check the input data for compatiblity with the preprocessor.
- Parameters:
data – Data to validate.
- Raises:
ValueError – If the input data is of the wrong type.
ValueError – If the input data does not have a ‘time’ dimension.
- s2spy.preprocess._check_temporal_resolution(timescale: Literal[monthly, weekly, daily]) Literal[monthly, weekly, daily] [source]
- s2spy.preprocess._check_data_resolution_match(data: xarray.DataArray | xarray.Dataset, timescale: Literal[monthly, weekly, daily])[source]
Check if the temporal resolution of input is the same as given timescale.
- class s2spy.preprocess.Preprocessor(rolling_window_size: int | None, timescale: Literal[monthly, weekly, daily], rolling_min_periods: int = 1, subtract_climatology: bool = True, detrend: str | None = 'linear')[source]
Preprocessor for s2s data.
- property climatology: xarray.DataArray | xarray.Dataset[source]
Return the stored climatology data.
- fit(data: xarray.DataArray | xarray.Dataset) None [source]
Fit this Preprocessor to input data.
- Parameters:
data – Input data for fitting.
- transform(data: xarray.DataArray | xarray.Dataset) xarray.DataArray | xarray.Dataset [source]
Apply the preprocessing steps to the input data.
- Parameters:
data – Input data to perform preprocessing.
- Returns:
Preprocessed data.
- fit_transform(data: xarray.DataArray | xarray.Dataset) xarray.DataArray | xarray.Dataset [source]
Fit this Preprocessor to input data, and then apply the steps to the data.
- Parameters:
data – Input data for fit and transform.
- Returns:
Preprocessed data.