Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
toarstats
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
toar-public
toarstats
Commits
e0d7bd85
Commit
e0d7bd85
authored
2 years ago
by
Niklas Selke
Browse files
Options
Downloads
Patches
Plain Diff
Added the boilerplate code for the deseasonalization of data.
parent
5fa0cb3a
No related branches found
No related tags found
2 merge requests
!5
Modified the test for the 'value_count' statistic. Now all available sampling...
,
!3
Niklas issue009 feat calculate quantile regression
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
toarstats/trends/interface.py
+5
-3
5 additions, 3 deletions
toarstats/trends/interface.py
toarstats/trends/utils.py
+16
-0
16 additions, 0 deletions
toarstats/trends/utils.py
with
21 additions
and
3 deletions
toarstats/trends/interface.py
+
5
−
3
View file @
e0d7bd85
...
@@ -6,6 +6,7 @@ calculate_trend - calculate the trend using the requested method
...
@@ -6,6 +6,7 @@ calculate_trend - calculate the trend using the requested method
from
toarstats.trends.ols
import
ols
from
toarstats.trends.ols
import
ols
from
toarstats.trends.quant_reg
import
quant_reg
from
toarstats.trends.quant_reg
import
quant_reg
from
toarstats.trends.utils
import
deseasonalize
def
calculate_trend
(
method
,
data
,
formula
=
"
value ~ datetime
"
,
quantiles
=
None
):
def
calculate_trend
(
method
,
data
,
formula
=
"
value ~ datetime
"
,
quantiles
=
None
):
...
@@ -30,14 +31,15 @@ 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
:return: The result of the fit or a list of fit results if
``method=
"
quant
"
`` and multiple quantiles are given
``method=
"
quant
"
`` and multiple quantiles are given
"""
"""
deseasonalized_data
=
deseasonalize
(
data
)
if
method
==
"
OLS
"
:
if
method
==
"
OLS
"
:
fit
=
ols
(
data
,
formula
)
fit
=
ols
(
deseasonalized_
data
,
formula
)
elif
method
==
"
quant
"
:
elif
method
==
"
quant
"
:
try
:
try
:
fit
=
[
quant_reg
(
data
,
formula
,
quantile
)
fit
=
[
quant_reg
(
deseasonalized_
data
,
formula
,
quantile
)
for
quantile
in
quantiles
]
for
quantile
in
quantiles
]
except
TypeError
:
except
TypeError
:
fit
=
quant_reg
(
data
,
formula
,
quantiles
)
fit
=
quant_reg
(
deseasonalized_
data
,
formula
,
quantiles
)
else
:
else
:
raise
ValueError
(
f
"
{
method
}
is not recognized, must be
'
OLS
'
or
"
raise
ValueError
(
f
"
{
method
}
is not recognized, must be
'
OLS
'
or
"
"
'
quant
'"
)
"
'
quant
'"
)
...
...
This diff is collapsed.
Click to expand it.
toarstats/trends/utils.py
0 → 100644
+
16
−
0
View file @
e0d7bd85
"""
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment