diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ca291eaf7344bedbdbe1c5fe61e8eca90c402ce..c48a3018121757035cd8769eabc9cc8b9919aac4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ # 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: diff --git a/CITATION.cff b/CITATION.cff index 82f4de95c84cc08a856d585d309915963ee7e776..e6a6745543971f965d8c9908f095ff4ee7efad1d 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -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 diff --git a/dist/toarstats-0.6.1-py3-none-any.whl b/dist/toarstats-0.6.1-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..3670db4f274447cb2cee9ebe1e7b96c3e4fdfb07 Binary files /dev/null and b/dist/toarstats-0.6.1-py3-none-any.whl differ diff --git a/docs/conf.py b/docs/conf.py index 3a4261baa156d92a649ffc2a36049dee9a7bbb80..5357f0c9379ed2bf76e41d2dde678dd1621ca95b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 diff --git a/setup.cfg b/setup.cfg index b3c54bb77a53248c38656bf4d1f324e3eb985292..845f88b7a8092d4294453d4c585b1cc6528864f9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,8 +1,8 @@ [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 diff --git a/toarstats/metrics/constants.py b/toarstats/metrics/constants.py index ba019589889c7a2da813cf4d9ee3074e42cccd19..b513884a3c7ffd53d3a024af70fc6ecafc486125 100644 --- a/toarstats/metrics/constants.py +++ b/toarstats/metrics/constants.py @@ -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" } diff --git a/toarstats/metrics/interface.py b/toarstats/metrics/interface.py index 8bbccf6973a7b85643e15525d027f2a9d026d347..9cf39d7cd8eb95e20562b8e0eeb993d2085808e3 100644 --- a/toarstats/metrics/interface.py +++ b/toarstats/metrics/interface.py @@ -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 diff --git a/toarstats/metrics/stats_utils.py b/toarstats/metrics/stats_utils.py index c6528cf646fc57fe40026f888760af1e5fbf9047..d745c035a29723922187bf9215b7f491333b6afa 100644 --- a/toarstats/metrics/stats_utils.py +++ b/toarstats/metrics/stats_utils.py @@ -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,