Skip to content
Snippets Groups Projects
Commit c994a8e5 authored by Sabine Schröder's avatar Sabine Schröder
Browse files

Merge branch 'max_version_0.6.1' into 'master'

reference_series creation allows daterange argument, updated toarstats to 0.6.1

See merge request !13
parents 4bd14add 1992fa9c
No related branches found
No related tags found
1 merge request!13reference_series creation allows daterange argument, updated toarstats to 0.6.1
# Changelog
All notable changes to this project will be documented in this file.
## v0.6.1 - 2024-07-15 - bugfixes
### general:
* updated sampling daterange to exact dates
### technical:
* bugfix for reference_series creation by adding optional daterange argument
* updated deprecated constants
## v0.6.0 - 2023-07-13 - adding custom sampling
### general:
......
......@@ -17,6 +17,11 @@ authors:
family-names: Schultz
given-names: Martin
affiliation: Forschungszentrum Jülich
- email: m.lensing@fz-juelich.de
orcid: https://orcid.org/0009-0004-2443-8792
family-names: Lensing
given-names: Max
affiliation: Forschungszentrum Jülich
contact:
- email: m.schultz@fz-juelich.de
orcid: https://orcid.org/0000-0003-3455-774X
......
File added
......@@ -8,8 +8,8 @@
project = 'toarstats'
copyright = '2021, Forschungszentrum Jülich GmbH'
author = 'Niklas Selke'
release = '0.6.0'
author = 'Niklas Selke, Martin Schultz, Max Lensing'
release = '0.6.1'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
......
[metadata]
name = toarstats
version = 0.6.0
author = Niklas Selke
author_email = n.selke@fz-juelich.de
version = 0.6.1
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
long_description = file: README.md
long_description_content_type = text/markdown
......
......@@ -154,9 +154,9 @@ ALLOWED_CROPS_VALUES = [
RSTAGS = {
"daily": "D",
"monthly": "MS",
"seasonal": "AS",
"summer": "AS",
"xsummer": "AS",
"annual": "AS",
"custom": "100AS"
"seasonal": "YS",
"summer": "YS",
"xsummer": "YS",
"annual": "YS",
"custom": "100YS"
}
......@@ -16,7 +16,8 @@ from toarstats.metrics.stats_utils import (
def calculate_statistics(
sampling=None, statistics=None, data=None, metadata=None, seasons=None,
crops=None, min_data_capture=None, datetimes=None, values=None,
station_lat=None, station_lon=None, station_climatic_zone=None
station_lat=None, station_lon=None, station_climatic_zone=None,
daterange=None
):
"""Calculate the requested statistics.
......@@ -126,7 +127,7 @@ def calculate_statistics(
else DEFAULT_CROPS, input_parameters.required.seasons,
input_parameters.required.crops
)
ref = create_reference_series(input_parameters.data.index)
ref = create_reference_series(input_parameters.data.index, daterange)
resample_rule = ("seasonal" if input_parameters.sampling == "vegseason"
else input_parameters.sampling)
min_data_capture_value = (input_parameters.min_data_capture
......
......@@ -118,20 +118,28 @@ def calc_data_capture(ser, ref, sampling, how, mincount=0, minfrac=None,
return fcov.reindex(ser_tmp.index)
def create_reference_series(index):
def create_reference_series(index, daterange=None):
"""Create a reference series.
:param index: the given index
:param daterange: start- and end-date separated by comma
if set, the reference series creates a series from start to end-date
:return: A series with a date range spanning from the beginning of
the earliest given year to the ending of the latest given
year and filled with zeros
"""
min_date = index.min()
max_date = index.max()
start_date = f"{min_date.year}-01-01 00:{min_date.minute}"
end_date = f"{max_date.year}-12-31 23:{max_date.minute}"
reference_index = pd.date_range(start=start_date, end=end_date, freq="H")
if daterange:
start_date = daterange.split(",")[0]
end_date = daterange.split(",")[1]
else:
min_date = index.min()
max_date = index.max()
start_date = f"{min_date.year}-01-01 00:{min_date.minute}"
end_date = f"{max_date.year}-12-31 23:{max_date.minute}"
reference_index = pd.date_range(start=start_date, end=end_date, freq="h")
return pd.Series(0, reference_index)
......@@ -494,6 +502,8 @@ def stat_processor_1(label, ser, ref, mtype, seasons, func=resample,
:return: A list of dictionaries containing the processed data
"""
res = prepare_data(ser, ref, mtype, seasons, label)
if minfrac == 0:
minfrac = None
for r in res:
r["ser"] = func(r["ser"], r["ref"], RSTAGS[mtype], how,
mincount=mincount, minfrac=minfrac,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment