From cc560d0aae85121f1f65bb307b43f5522a481227 Mon Sep 17 00:00:00 2001 From: Damien Irving Date: Thu, 4 Jul 2024 15:03:53 +1000 Subject: [PATCH 1/2] Update from A to YE for time agg --- unseen/fileio.py | 8 ++++---- unseen/time_utils.py | 23 ++++++++++++----------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/unseen/fileio.py b/unseen/fileio.py index 1595092..7e168cb 100644 --- a/unseen/fileio.py +++ b/unseen/fileio.py @@ -103,8 +103,9 @@ def open_dataset( Remove leap days from data rolling_sum_window : int, default None Apply a rolling sum with this window width - time_freq : {'A-DEC', 'M', 'Q-NOV', 'A-NOV', 'A-AUG', 'A-JUN'}, optional + time_freq : str, optional Target temporal frequency for resampling + Options: https://pandas.pydata.org/docs/user_guide/timeseries.html#anchored-offsets time_agg : {'mean', 'sum', 'min', 'max'}, optional Temporal aggregation method time_agg_dates : bool, default False @@ -119,7 +120,7 @@ def open_dataset( Shift time values after resampling so months match initial date time_agg_min_tsteps : int, optional Minimum number of timesteps for temporal aggregation - input_freq : {'A', 'Q', 'M', 'D'}, optional + input_freq : {'Y', 'Q', 'M', 'D'}, optional Input time frequency for resampling (estimated if not provided) time_dim: str, default 'time' Name of the time dimension in infiles @@ -610,7 +611,6 @@ def _parse_command_line(): parser.add_argument( "--time_freq", type=str, - choices=("A-DEC", "M", "Q-NOV", "A-NOV", "A-AUG", "A-JUN"), default=None, help="Target frequency for temporal aggregation", ) @@ -656,7 +656,7 @@ def _parse_command_line(): parser.add_argument( "--input_freq", type=str, - choices=("M", "D", "Q", "A"), + choices=("M", "D", "Q", "Y"), default=None, help="Time frequency of input data", ) diff --git a/unseen/time_utils.py b/unseen/time_utils.py index b393067..6f4bad3 100644 --- a/unseen/time_utils.py +++ b/unseen/time_utils.py @@ -70,14 +70,15 @@ def temporal_aggregation( Parameters ---------- ds : xarray Dataset - target_freq : {'A-DEC', 'Q-NOV', 'M', 'A-NOV', 'A-AUG', 'A-JUN'} + target_freq : str Target frequency for the resampling + Options: https://pandas.pydata.org/docs/user_guide/timeseries.html#anchored-offsets agg_method : {'mean', 'min', 'max', 'sum'} Aggregation method variables : list Variables in the dataset - input_freq : {'D', 'M', 'Q', 'A'} - Temporal frequency of input data (daily, monthly or annual) + input_freq : {'D', 'M', 'Q', 'Y'} + Temporal frequency of input data (daily, monthly, quarterly or yearly) season : {'DJF', 'MAM', 'JJA', 'SON'}, optional Select a single season after Q-NOV resampling reset_times : bool, default False @@ -96,16 +97,16 @@ def temporal_aggregation( Notes ----- - A-DEC = annual, with date label being last day of year - M = monthly, with date label being last day of month - Q-NOV = DJF, MAM, JJA, SON, with date label being last day of season - A-NOV = annual Dec-Nov, date label being last day of the year - A-AUG = annual Sep-Aug, date label being last day of the year - A-JUN = annual Jul-Jun, date label being last day of the year + Example target_freq includes: + YE-DEC = annual, with date label being last day of year + M = monthly, with date label being last day of month + Q-NOV = DJF, MAM, JJA, SON, with date label being last day of season + YE-NOV = annual Dec-Nov, date label being last day of the year + YE-AUG = annual Sep-Aug, date label being last day of the year + YE-JUN = annual Jul-Jun, date label being last day of the year """ - assert target_freq in ["A-DEC", "M", "Q-NOV", "A-NOV", "A-AUG", "A-JUN"] - assert input_freq in ["D", "M", "Q", "A"] + assert input_freq in ["D", "M", "Q", "Y"] if time_dim not in ds.dims: ds = array_handling.reindex_forecast(ds) From 29d232756a2407edbfa80f80c7af43b9f66bc6d1 Mon Sep 17 00:00:00 2001 From: Damien Irving Date: Thu, 4 Jul 2024 15:25:51 +1000 Subject: [PATCH 2/2] Update codecov --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 13305fb..827caa0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,7 +34,7 @@ jobs: shell: bash -l {0} run: python -m pytest unseen - - name: Upload code coverage - uses: codecov/codecov-action@v1 + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 with: - file: ./coverage.xml + token: ${{ secrets.CODECOV_TOKEN }}