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
af3295e1
Commit
af3295e1
authored
7 months ago
by
Max Lensing
Browse files
Options
Downloads
Patches
Plain Diff
bugfix create_reference_series, updated toarstats to 0.6.4
parent
28b69523
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!16
bugfix create_reference_series, updated toarstats to 0.6.4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG.md
+5
-0
5 additions, 0 deletions
CHANGELOG.md
dist/toarstats-0.6.4-py3-none-any.whl
+0
-0
0 additions, 0 deletions
dist/toarstats-0.6.4-py3-none-any.whl
setup.cfg
+1
-1
1 addition, 1 deletion
setup.cfg
toarstats/metrics/stats_utils.py
+23
-20
23 additions, 20 deletions
toarstats/metrics/stats_utils.py
with
29 additions
and
21 deletions
CHANGELOG.md
+
5
−
0
View file @
af3295e1
# Changelog
All notable changes to this project will be documented in this file.
## v0.6.4 - 2024-09-16 - bugfix reference-series
### general:
*
daterange in create_reference_series is now optional, therefore the series is created by dataframe indices
## v0.6.3 - 2024-07-30 - fixed custom-sampling
### general:
...
...
This diff is collapsed.
Click to expand it.
dist/toarstats-0.6.4-py3-none-any.whl
0 → 100644
+
0
−
0
View file @
af3295e1
File added
This diff is collapsed.
Click to expand it.
setup.cfg
+
1
−
1
View file @
af3295e1
[metadata]
name
=
toarstats
version
=
0.6.
3
version
=
0.6.
4
author
=
Niklas Selke, Martin Schultz, Max Lensing
author_email
=
n.selke@fz-juelich.de, m.schultz@fz-juelich.de, m.lensing@fz-juelich.de
description
=
Collection of statistics for the TOAR community
...
...
This diff is collapsed.
Click to expand it.
toarstats/metrics/stats_utils.py
+
23
−
20
View file @
af3295e1
...
...
@@ -121,8 +121,9 @@ def calc_data_capture(ser, ref, sampling, how, mincount=0, minfrac=None,
return
fcov
.
reindex
(
ser_tmp
.
index
)
def
create_reference_series
(
index
,
sampling
,
daterange
):
def
create_reference_series
(
index
,
sampling
,
daterange
=
None
):
"""
Create a reference series by the daterange. Additional extends to the intervals specified by the sampling.
If no daterange is given, the series is based on the indices of the dataframe.
:param index: the given index
...
...
@@ -133,29 +134,31 @@ def create_reference_series(index, sampling, daterange):
if set, the reference series creates a series from start to end-date
:return: A series with a date range based on the specified date range. The date range is extended based on the
:return: A series with a date range based on the specified date range
or indices
. The date range is extended based on the
specified sampling.
"""
min_date
=
index
.
min
()
max_date
=
index
.
max
()
# adjust start and end-date by the minute-offset of the timeseries
start_date
=
pd
.
to_datetime
(
daterange
.
split
(
"
,
"
)[
0
])
start_date
=
start_date
.
replace
(
minute
=
min_date
.
minute
)
end_date
=
pd
.
to_datetime
(
daterange
.
split
(
"
,
"
)[
1
])
end_date
=
end_date
.
replace
(
minute
=
max_date
.
minute
)
if
sampling
in
[
"
annual
"
,
"
seasonal
"
,
"
summer
"
,
"
xsummer
"
]:
start_date
=
start_date
.
replace
(
month
=
1
,
day
=
1
,
hour
=
0
)
end_date
=
end_date
.
replace
(
month
=
12
,
day
=
31
,
hour
=
23
)
elif
sampling
==
"
monthly
"
:
start_date
=
start_date
.
replace
(
day
=
1
,
hour
=
0
)
end_date
=
pd
.
offsets
.
MonthEnd
().
rollforward
(
end_date
)
end_date
=
end_date
.
replace
(
hour
=
23
)
elif
sampling
==
"
daily
"
:
start_date
=
start_date
.
replace
(
hour
=
0
)
end_date
=
end_date
.
replace
(
hour
=
23
)
reference_index
=
pd
.
date_range
(
start
=
start_date
,
end
=
end_date
,
freq
=
"
h
"
)
if
daterange
is
not
None
:
# adjust start and end-date by the minute-offset of the timeseries
start_date
=
pd
.
to_datetime
(
daterange
.
split
(
"
,
"
)[
0
])
start_date
=
start_date
.
replace
(
minute
=
min_date
.
minute
)
end_date
=
pd
.
to_datetime
(
daterange
.
split
(
"
,
"
)[
1
])
end_date
=
end_date
.
replace
(
minute
=
max_date
.
minute
)
if
sampling
in
[
"
annual
"
,
"
seasonal
"
,
"
summer
"
,
"
xsummer
"
]:
start_date
=
start_date
.
replace
(
month
=
1
,
day
=
1
,
hour
=
0
)
end_date
=
end_date
.
replace
(
month
=
12
,
day
=
31
,
hour
=
23
)
elif
sampling
==
"
monthly
"
:
start_date
=
start_date
.
replace
(
day
=
1
,
hour
=
0
)
end_date
=
pd
.
offsets
.
MonthEnd
().
rollforward
(
end_date
)
end_date
=
end_date
.
replace
(
hour
=
23
)
elif
sampling
==
"
daily
"
:
start_date
=
start_date
.
replace
(
hour
=
0
)
end_date
=
end_date
.
replace
(
hour
=
23
)
reference_index
=
pd
.
date_range
(
start
=
start_date
,
end
=
end_date
,
freq
=
"
h
"
)
else
:
reference_index
=
pd
.
date_range
(
start
=
min_date
,
end
=
max_date
,
freq
=
"
h
"
)
return
pd
.
Series
(
0
,
reference_index
)
...
...
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