module TopoPyScale.topo_compare
function correct_trend
Function to estimate linear trend correction.
Args:
df (dataframe):
- reference_col (str): name of the reference column, i.e. observation timeseries
- target_col (str): name of the target column, i.e. downscale timeseries
- apply_correction (bool): applying correction to target data
Returns:
dict: metrics of the linear trend estimatedataframe(optional): corrected values
function correct_seasonal
Function to correct for seasonal signal. 1. it groups all days by day_of_year and extract the median difference. 2. it computes the 31 day rolling mean (padded on both sides)
Args:
df(dataframe): index must be a datetime, with daily timestep. other columns are reference and target.reference_col(str): name of the reference column, i.e. observation timeseriestarget_col(str): name of the target column, i.e. downscale timeseries plot (bool):apply_correction(bool): apply correction and return corrected data
Returns: dataframe - correction for each day of year, starting on January 1.
function obs_vs_downscaled
obs_vs_downscaled(
df,
reference_col='obs',
target_col='dow',
trend_correction=True,
seasonal_correction=True,
param={'xlab': 'Downscaled [unit]', 'ylab': 'Observation [unit]', 'xlim': (-20, 20), 'ylim': (-20, 20), 'title': None},
plot='heatmap'
)
Function to compare Observation to Downscaled for one given variable.
Args:
df(dataframe): pandas dataframe containing corresponding Observation and Downscaled valuesreference_col(str): name of the reference column. Observationtarget_col(str): name of the target column. Downscaled timeseriestrend_correction(bool): remove trend by applying a linear regressionseasonal_correction(bool): remove seasonal signal by deriving median per day of the year and computing the rolling mean over 31d on the medianparam(dict): parameter for comparison and plottingplot(str): plot type: heatmap or timeseries
Returns:
dict: metrics of regression and comparisondataframe: dataframe containing the seasonal corrections to applieddataframe: corrected values
Inspired by this study: https://reader.elsevier.com/reader/sd/pii/S0048969722015522?token=106483481240DE6206D83D9C7EC9D4990C2C3DE6F669EDE39DCB54FF7495A31CC57BDCF3370A6CA39D09BE293EACDDBB&originRegion=eu-west-1&originCreation=20220316094240
This file was automatically generated via lazydocs.