diff --git a/CHANGELOG.md b/CHANGELOG.md index ac30aa2daa071ca4c817132294bb514d34e49ab1..1ca291eaf7344bedbdbe1c5fe61e8eca90c402ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ # Changelog All notable changes to this project will be documented in this file. +## v0.6.0 - 2023-07-13 - adding custom sampling + +### general: +* added new custom sampling + +### new features: +* arbitrary intervals can now be aggregated (#11) + ## v0.5.0 - 2023-06-06 - moving block bootstrap ### general: @@ -15,8 +23,8 @@ All notable changes to this project will be documented in this file. ## v0.4.0 - 2023-02-21 - renaming of metrics ### general: -* renaming some metrics -* renaming data_capture argument to min_data_capture +* renamed some metrics +* renamed data_capture argument to min_data_capture ### technical: * all metrics now match their respective result key (#2) diff --git a/README.md b/README.md index 77991cffff4e3217fff991f441881203d6bd2bce..815fd7477b756cb82cd0d59864f1b287f87bc8e2 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ calculate_statistics( :param sampling: temporal aggregation, one of ``daily``, ``monthly``, ``seasonal``, ``vegseason``, - ``summer``, ``xsummer``, or ``annual``; + ``summer``, ``xsummer``, ``annual``, or ``custom``; ``summer`` will pick the 6-months summer season in the hemisphere where the station is located; ``xsummer`` does the same for a 7-months summer @@ -57,7 +57,9 @@ calculate_statistics( ``vegseason`` requires also the ``crops`` argument and will then determine the appropriate growing seasons based on the ``climatic_zone`` metadata and - crop type + crop type; + ``custom`` will create one aggregate value over the + entire time series :param statistics: a single statistic or metric or a list of statistics and metrics to call, these must be defined in ``stats.py`` or ``ozone_metrics.py`` diff --git a/dist/toarstats-0.6.0-py3-none-any.whl b/dist/toarstats-0.6.0-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..2a44f132ffc756e84282021eeb21af7c03d13587 Binary files /dev/null and b/dist/toarstats-0.6.0-py3-none-any.whl differ diff --git a/docs/conf.py b/docs/conf.py index bf5410a18825bf81d0094318d582ed94b5e7395f..3a4261baa156d92a649ffc2a36049dee9a7bbb80 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,7 +9,7 @@ project = 'toarstats' copyright = '2021, Forschungszentrum Jülich GmbH' author = 'Niklas Selke' -release = '0.5.0' +release = '0.6.0' # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/requirements.txt b/requirements.txt index 230944e66338b4839640688ead8beef2134e9a2c..7dc2b9201a7fd1614a49004b1948e5952f17e4fb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy==1.24.3 -pandas==2.0.2 -scipy==1.10.1 +numpy==1.25.1 +pandas==2.0.3 +scipy==1.11.1 statsmodels==0.14.0 diff --git a/setup.cfg b/setup.cfg index a2ced23c78fef13f2cdd3a22ae032552aa8ae5dd..b3c54bb77a53248c38656bf4d1f324e3eb985292 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = toarstats -version = 0.5.0 +version = 0.6.0 author = Niklas Selke author_email = n.selke@fz-juelich.de description = Collection of statistics for the TOAR community diff --git a/tests/test_metrics/test_interface.py b/tests/test_metrics/test_interface.py index ad1dc6375c1b7088516ca68af82bfb65422ab40f..1bf22d7cee9676314d0ba1b4456fa3f15eb421fc 100644 --- a/tests/test_metrics/test_interface.py +++ b/tests/test_metrics/test_interface.py @@ -74,7 +74,7 @@ def test_calculate_statistics_run_all_statistics_with_all_samplings( elif statistic == "percentiles1": expected_num_columns *= 3 elif statistic == "percentiles2": - if sampling in {"daily", "monthly", "seasonal", "vegseason"}: + if sampling not in {"summer", "xsummer", "annual"}: expected_num_columns *= 7 else: expected_num_columns *= 9 diff --git a/toarstats/metrics/constants.py b/toarstats/metrics/constants.py index af2d0aa4e6017db08afb9c0657fa8360348e7d1d..ba019589889c7a2da813cf4d9ee3074e42cccd19 100644 --- a/toarstats/metrics/constants.py +++ b/toarstats/metrics/constants.py @@ -16,7 +16,8 @@ ALLOWED_SAMPLING_VALUES = [ "vegseason", "summer", "xsummer", - "annual" + "annual", + "custom" ] STATISTICS_LIST = [ @@ -156,5 +157,6 @@ RSTAGS = { "seasonal": "AS", "summer": "AS", "xsummer": "AS", - "annual": "AS" + "annual": "AS", + "custom": "100AS" } diff --git a/toarstats/metrics/interface.py b/toarstats/metrics/interface.py index bba7fb5e5233d48c45ce08ad3ac3b01108dc9b05..8bbccf6973a7b85643e15525d027f2a9d026d347 100644 --- a/toarstats/metrics/interface.py +++ b/toarstats/metrics/interface.py @@ -26,7 +26,7 @@ def calculate_statistics( :param sampling: temporal aggregation, one of ``daily``, ``monthly``, ``seasonal``, ``vegseason``, - ``summer``, ``xsummer``, or ``annual``; + ``summer``, ``xsummer``, ``annual``, or ``custom``; ``summer`` will pick the 6-months summer season in the hemisphere where the station is located; ``xsummer`` does the same for a 7-months summer @@ -34,7 +34,9 @@ def calculate_statistics( ``vegseason`` requires also the ``crops`` argument and will then determine the appropriate growing seasons based on the ``climatic_zone`` metadata and - crop type + crop type; + ``custom`` will create one aggregate value over the + entire time series :param statistics: a single statistic or metric or a list of statistics and metrics to call, these must be defined in ``stats.py`` or ``ozone_metrics.py`` diff --git a/toarstats/metrics/stats.py b/toarstats/metrics/stats.py index b67ba062b493ab2d899218a951fb7e4123ee8037..e7cea61b12eded303b0dda2d953747e9a3de212d 100644 --- a/toarstats/metrics/stats.py +++ b/toarstats/metrics/stats.py @@ -484,7 +484,7 @@ def diurnal_cycle(ser, ref, mtype, metadata, seasons, min_data_capture): # data record. nyears = ser.index.year.unique().size vmax = {"daily": 1, "monthly": 29, "seasonal": 91, "summer": 182, - "xsummer": 212, "annual": 365} + "xsummer": 212, "annual": 365, "custom": 365} dcap = int(min_data_capture * vmax[mtype] * nyears) for r in res: grouped = r["ser"].groupby(r["ser"].index.hour)