Skip to content
Snippets Groups Projects
Commit e0d7bd85 authored by Niklas Selke's avatar Niklas Selke
Browse files

Added the boilerplate code for the deseasonalization of data.

parent 5fa0cb3a
Branches
Tags
2 merge requests!5Modified the test for the 'value_count' statistic. Now all available sampling...,!3Niklas issue009 feat calculate quantile regression
......@@ -6,6 +6,7 @@ calculate_trend - calculate the trend using the requested method
from toarstats.trends.ols import ols
from toarstats.trends.quant_reg import quant_reg
from toarstats.trends.utils import deseasonalize
def calculate_trend(method, data, formula="value ~ datetime", quantiles=None):
......@@ -30,14 +31,15 @@ def calculate_trend(method, data, formula="value ~ datetime", quantiles=None):
:return: The result of the fit or a list of fit results if
``method="quant"`` and multiple quantiles are given
"""
deseasonalized_data = deseasonalize(data)
if method == "OLS":
fit = ols(data, formula)
fit = ols(deseasonalized_data, formula)
elif method == "quant":
try:
fit = [quant_reg(data, formula, quantile)
fit = [quant_reg(deseasonalized_data, formula, quantile)
for quantile in quantiles]
except TypeError:
fit = quant_reg(data, formula, quantiles)
fit = quant_reg(deseasonalized_data, formula, quantiles)
else:
raise ValueError(f"{method} is not recognized, must be 'OLS' or"
" 'quant'")
......
"""This module contains helper functions for the trends subpackage.
This module contains the following function:
deseasonalize - calculate the trend using the requested method
"""
def deseasonalize(data):
"""Deseasonalize the data.
:param data: data containing a list of date time values and
associated parameter values
:return: The deseasonalized data
"""
return data
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment