diff --git a/CHANGELOG.md b/CHANGELOG.md index ab6462617c2768e30da8393db88d356469386356..e69505b3e33e129983eac76a36da4d6500db446b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog All notable changes to this project will be documented in this file. +## v0.6.5 - 2025-01-17 - added osdma8 statistic + ## v0.6.4 - 2024-09-16 - bugfix reference-series ### general: diff --git a/dist/toarstats-0.6.5-py3-none-any.whl b/dist/toarstats-0.6.5-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..f2baad0015d70e502792b5c4701aa06fbe6ea32d Binary files /dev/null and b/dist/toarstats-0.6.5-py3-none-any.whl differ diff --git a/setup.cfg b/setup.cfg index a1b7ee0a33cfd9cbdcdc081bffea9e1972ce8dca..006fc53eb5893c264c3ac94d1c7fed55ed4f9635 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = toarstats -version = 0.6.4 +version = 0.6.5 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 diff --git a/toarstats/metrics/constants.py b/toarstats/metrics/constants.py index b513884a3c7ffd53d3a024af70fc6ecafc486125..6afc59788ca247fab2db84f3981bf9495676baa3 100644 --- a/toarstats/metrics/constants.py +++ b/toarstats/metrics/constants.py @@ -53,6 +53,7 @@ STATISTICS_LIST = [ "nvgt100", "nvgt120", "nvgtall", + "osdma8", "p05", "p10", "p25", diff --git a/toarstats/metrics/ozone_metrics.py b/toarstats/metrics/ozone_metrics.py index 6bdcec77449d6d1ad4a2de0c880b5c43f8f4c92e..08a7e1d04bb3ffad029186b8a6f334f1626d8e8d 100644 --- a/toarstats/metrics/ozone_metrics.py +++ b/toarstats/metrics/ozone_metrics.py @@ -775,3 +775,40 @@ def nvgtall(ser, ref, mtype, metadata, seasons, min_data_capture): res for func in (nvgt050, nvgt060, nvgt080, nvgt090, nvgt100, nvgt120) for res in func(ser, ref, mtype, metadata, seasons, min_data_capture) ] + + +@register("osdma8") +def osdma8(ser, ref, mtype, metadata, seasons, min_data_capture): + """ Calculate osdma8 statistic + + :param ser: a series containing the values + :param ref: reference series + :param mtype: aggregation type + :param metadata: metadata needed for some statistics + :param seasons: season names + :param min_data_capture: a fractional coverage value + + :return: A list of dictionaries containing the processed data + """ + monthly_means = stat_processor_1("mean", ser, ref, "monthly", seasons, mincount=10) + + tmp = monthly_means[0]["ser"] + reference_index = pd.date_range( + start=ref.index.min().strftime("%Y-%m-%d"), + end=ref.index.max().strftime("%Y-%m-%d"), + freq="MS" + ) + tmp = tmp.reindex(reference_index) + rolling_mean = tmp.rolling(window=6).mean() + # rolling mean should be indexed by start month + rolling_mean = rolling_mean.shift(-5) + rolling_mean = rolling_mean[rolling_mean.index.month <= 10] + + rolling_mean_grouped = rolling_mean.groupby(rolling_mean.index.year) + + res = rolling_mean_grouped.agg(["max"]) + res.index = pd.to_datetime(res.index, format="%Y") + + res = res["max"] + res = res.iloc[:-1] + return [{"name": "osdma8", "ser": res, "ref": ref}]