From ffb6150c47d98ec2e5d2861d762e37a179d9deb5 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 6 Nov 2024 14:50:35 -0500 Subject: [PATCH 01/12] add origin to resample --- rdtools/normalization.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rdtools/normalization.py b/rdtools/normalization.py index b1a2ee36..fe9fd2e3 100644 --- a/rdtools/normalization.py +++ b/rdtools/normalization.py @@ -478,9 +478,9 @@ def _aggregate(time_series, target_frequency, max_timedelta, series_type): ''' # series that has same index as desired output - output_dummy = time_series.resample(target_frequency, - closed='right', - label='right').sum() + output_dummy = time_series.resample( + target_frequency, closed="right", label="right", origin="start" + ).sum() union_index = time_series.index.union(output_dummy.index) time_series = time_series.dropna() @@ -523,9 +523,9 @@ def _aggregate(time_series, target_frequency, max_timedelta, series_type): series_sum = pd.Series(data=series_sum, index=time_series.index[1:]) - aggregated = series_sum.resample(target_frequency, - closed='right', - label='right').sum(min_count=1) + aggregated = series_sum.resample( + target_frequency, closed="right", label="right", origin="start" + ).sum(min_count=1) return aggregated From fd635a04fd42ad53af38eb99b7e93b7c593005f2 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 6 Nov 2024 15:35:08 -0500 Subject: [PATCH 02/12] update changelog --- docs/sphinx/source/changelog/v3.0.0-beta.0.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/changelog/v3.0.0-beta.0.rst b/docs/sphinx/source/changelog/v3.0.0-beta.0.rst index f69ffff4..9f735994 100644 --- a/docs/sphinx/source/changelog/v3.0.0-beta.0.rst +++ b/docs/sphinx/source/changelog/v3.0.0-beta.0.rst @@ -22,7 +22,7 @@ Enhancements * Added codecov.yml configuration file (:pull:`420`) * Availability module no longer considered experimental (:pull:`429`) * Add capability to seed the CircularBlockBootstrap (:pull:`429`) -* Allow sub-daily aggregation in :py:func:`~rdtools.degradation.degradation_year_on_year` (:pull:`390`) +* Allow sub-daily aggregation in :py:func:`~rdtools.degradation.degradation_year_on_year` (:pull:`390`) Bug fixes --------- @@ -31,6 +31,7 @@ Bug fixes * Deploy workflow was replaced with trusted publisher workflow for pypi (:pull:`427`) * Fix pandas 2.0.0 deprications and update syntax changes (:pull:`428`) * Fix numpy 2.0.0 deprications and update syntax changes (:pull:`428`) +* Fix `energy_from_power`` returns incorrect index for shifted hourly data (:issue:`370`, :pull:`437`) Tests ----- From 8affd0d84121cd48091b68eee0e7853ab634eda8 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 20 Nov 2024 11:31:53 -0500 Subject: [PATCH 03/12] fix _aggregate starting timestamp --- rdtools/normalization.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rdtools/normalization.py b/rdtools/normalization.py index fe9fd2e3..d5afacfc 100644 --- a/rdtools/normalization.py +++ b/rdtools/normalization.py @@ -521,13 +521,13 @@ def _aggregate(time_series, target_frequency, max_timedelta, series_type): raise ValueError("series_type must be either 'instantaneous' or 'right_labeled', " "not '{}'".format(series_type)) - series_sum = pd.Series(data=series_sum, index=time_series.index[1:]) + series_sum = pd.Series(data=np.insert(series_sum, 0, np.nan), index=time_series.index) aggregated = series_sum.resample( target_frequency, closed="right", label="right", origin="start" ).sum(min_count=1) - return aggregated + return aggregated[1:] def _interpolate_series(time_series, target_index, max_timedelta=None, From 3295776606714a12136423bd8d0bf7b12dd22829 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 18 Dec 2024 09:26:20 -0500 Subject: [PATCH 04/12] move changes to pending changlog --- docs/sphinx/source/changelog.rst | 1 + docs/sphinx/source/changelog/pending.rst | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 docs/sphinx/source/changelog/pending.rst diff --git a/docs/sphinx/source/changelog.rst b/docs/sphinx/source/changelog.rst index 54085c79..7fef9d35 100644 --- a/docs/sphinx/source/changelog.rst +++ b/docs/sphinx/source/changelog.rst @@ -1,5 +1,6 @@ RdTools Change Log ================== +.. include:: changelog/pending.rst .. include:: changelog/v3.0.0-beta.0.rst .. include:: changelog/v2.2.0-beta.2.rst .. include:: changelog/v2.2.0-beta.1.rst diff --git a/docs/sphinx/source/changelog/pending.rst b/docs/sphinx/source/changelog/pending.rst new file mode 100644 index 00000000..5d45c2e9 --- /dev/null +++ b/docs/sphinx/source/changelog/pending.rst @@ -0,0 +1,8 @@ +************************** +v3.0.0 (December XX, 2024) +************************** + + +Bug fixes +--------- +* Set marker linewidth to zero in `rdtools.plotting.degradation_summary_plots` (:pull:`433`) \ No newline at end of file From dcbf6526bf749c12a7a9b8eaee3bf4a73509f58b Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 18 Dec 2024 09:37:14 -0500 Subject: [PATCH 05/12] move changes to pending changelog 3 --- docs/sphinx/source/changelog/pending.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/changelog/pending.rst b/docs/sphinx/source/changelog/pending.rst index 5d45c2e9..2f32d3a0 100644 --- a/docs/sphinx/source/changelog/pending.rst +++ b/docs/sphinx/source/changelog/pending.rst @@ -2,7 +2,13 @@ v3.0.0 (December XX, 2024) ************************** +Enhancements +------------ +* Add `CITATION.cff` file for citation information (:pull:`434`) +* Added checks to TrendAnalysis for `filter_params` and `filter_params_aggregated`. Raises an error if unkown filter is supplied. (:pull:`436`) + Bug fixes --------- -* Set marker linewidth to zero in `rdtools.plotting.degradation_summary_plots` (:pull:`433`) \ No newline at end of file +* Set marker linewidth to zero in `rdtools.plotting.degradation_summary_plots` (:pull:`433`) + From 2fc733d7dbe5d2a20bcb545ee6e4fdacf46ed951 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 18 Dec 2024 09:49:00 -0500 Subject: [PATCH 06/12] move changes to pending changelog 4 --- docs/sphinx/source/changelog/pending.rst | 1 + docs/sphinx/source/changelog/v3.0.0-beta.0.rst | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/changelog/pending.rst b/docs/sphinx/source/changelog/pending.rst index 2f32d3a0..06e34d3f 100644 --- a/docs/sphinx/source/changelog/pending.rst +++ b/docs/sphinx/source/changelog/pending.rst @@ -11,4 +11,5 @@ Enhancements Bug fixes --------- * Set marker linewidth to zero in `rdtools.plotting.degradation_summary_plots` (:pull:`433`) +* Fix `energy_from_power`` returns incorrect index for shifted hourly data (:issue:`370`, :pull:`437`) diff --git a/docs/sphinx/source/changelog/v3.0.0-beta.0.rst b/docs/sphinx/source/changelog/v3.0.0-beta.0.rst index 9f735994..f8000382 100644 --- a/docs/sphinx/source/changelog/v3.0.0-beta.0.rst +++ b/docs/sphinx/source/changelog/v3.0.0-beta.0.rst @@ -31,7 +31,6 @@ Bug fixes * Deploy workflow was replaced with trusted publisher workflow for pypi (:pull:`427`) * Fix pandas 2.0.0 deprications and update syntax changes (:pull:`428`) * Fix numpy 2.0.0 deprications and update syntax changes (:pull:`428`) -* Fix `energy_from_power`` returns incorrect index for shifted hourly data (:issue:`370`, :pull:`437`) Tests ----- From 58eab97a323a0ff7d55ed5aa408a38649d133d56 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 18 Dec 2024 10:06:35 -0500 Subject: [PATCH 07/12] add test energy from power shifted data --- rdtools/test/analysis_chains_test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rdtools/test/analysis_chains_test.py b/rdtools/test/analysis_chains_test.py index efe78df4..f332b0d8 100644 --- a/rdtools/test/analysis_chains_test.py +++ b/rdtools/test/analysis_chains_test.py @@ -740,3 +740,21 @@ def test_plot_degradation_timeseries(sensor_analysis, clearsky_analysis): assert_isinstance( clearsky_analysis.plot_degradation_timeseries("clearsky"), plt.Figure ) + + +def test_energy_from_power_hourly_data(): + + times = pd.date_range("2019-01-01 00:00:00", periods=3, freq="H") + pv = pd.Series([1.2, 2.8, 2.0], index=times) + + energy = normalization.energy_from_power(pv) + pd.testing.assert_series_equal(energy, pv[1:], check_names=False) + + +def test_energy_from_power_shifted_hourly_data(): + + times = pd.date_range("2019-01-01 00:30:00", periods=3, freq="H") + pv = pd.Series([1.2, 2.8, 2.0], index=times) + + energy = normalization.energy_from_power(pv) + pd.testing.assert_series_equal(energy, pv[1:], check_names=False) From e39e4ab6f60aefe1745f3c88e40922bcc1599ae1 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 18 Dec 2024 16:16:51 -0500 Subject: [PATCH 08/12] make function callable in changelog --- docs/sphinx/source/changelog/pending.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/changelog/pending.rst b/docs/sphinx/source/changelog/pending.rst index 06e34d3f..71fb8a7d 100644 --- a/docs/sphinx/source/changelog/pending.rst +++ b/docs/sphinx/source/changelog/pending.rst @@ -11,5 +11,5 @@ Enhancements Bug fixes --------- * Set marker linewidth to zero in `rdtools.plotting.degradation_summary_plots` (:pull:`433`) -* Fix `energy_from_power`` returns incorrect index for shifted hourly data (:issue:`370`, :pull:`437`) +* Fix :py:func:`~rdtools.normalization.energy_from_power` returns incorrect index for shifted hourly data (:issue:`370`, :pull:`437`) From b376fc8153bc1250201894c73be7d01b022b54f7 Mon Sep 17 00:00:00 2001 From: Michael Deceglie Date: Mon, 30 Dec 2024 09:02:44 -0700 Subject: [PATCH 09/12] fix style error from merge --- rdtools/test/analysis_chains_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rdtools/test/analysis_chains_test.py b/rdtools/test/analysis_chains_test.py index 85abb21b..ff1931f1 100644 --- a/rdtools/test/analysis_chains_test.py +++ b/rdtools/test/analysis_chains_test.py @@ -847,3 +847,4 @@ def test_invalid_filter_params_aggregated( KeyError, match=f"Key '{filter_param_aggregated}' is not a valid filter parameter." ): sensor_analysis.filter_params_aggregated[filter_param_aggregated] = {} + From d6c40ac4bd879985d5e6e7d11f1ca7dc0bfd33fd Mon Sep 17 00:00:00 2001 From: martin-springer Date: Mon, 30 Dec 2024 11:07:03 -0500 Subject: [PATCH 10/12] lower case hourly frequency --- rdtools/test/analysis_chains_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rdtools/test/analysis_chains_test.py b/rdtools/test/analysis_chains_test.py index f332b0d8..28e3f6b4 100644 --- a/rdtools/test/analysis_chains_test.py +++ b/rdtools/test/analysis_chains_test.py @@ -744,7 +744,7 @@ def test_plot_degradation_timeseries(sensor_analysis, clearsky_analysis): def test_energy_from_power_hourly_data(): - times = pd.date_range("2019-01-01 00:00:00", periods=3, freq="H") + times = pd.date_range("2019-01-01 00:00:00", periods=3, freq="h") pv = pd.Series([1.2, 2.8, 2.0], index=times) energy = normalization.energy_from_power(pv) @@ -753,7 +753,7 @@ def test_energy_from_power_hourly_data(): def test_energy_from_power_shifted_hourly_data(): - times = pd.date_range("2019-01-01 00:30:00", periods=3, freq="H") + times = pd.date_range("2019-01-01 00:30:00", periods=3, freq="h") pv = pd.Series([1.2, 2.8, 2.0], index=times) energy = normalization.energy_from_power(pv) From 69042288b6f2e251895de69f538dc75e8e6da5df Mon Sep 17 00:00:00 2001 From: martin-springer Date: Mon, 30 Dec 2024 11:13:32 -0500 Subject: [PATCH 11/12] delete blank line --- rdtools/test/analysis_chains_test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rdtools/test/analysis_chains_test.py b/rdtools/test/analysis_chains_test.py index 2613de5c..7b5b28a8 100644 --- a/rdtools/test/analysis_chains_test.py +++ b/rdtools/test/analysis_chains_test.py @@ -847,4 +847,3 @@ def test_invalid_filter_params_aggregated( KeyError, match=f"Key '{filter_param_aggregated}' is not a valid filter parameter." ): sensor_analysis.filter_params_aggregated[filter_param_aggregated] = {} - From f15210c4df460e773bb6597e9a4e6cef87686ee6 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Mon, 30 Dec 2024 11:19:03 -0500 Subject: [PATCH 12/12] add missing blank line --- rdtools/test/analysis_chains_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rdtools/test/analysis_chains_test.py b/rdtools/test/analysis_chains_test.py index 7b5b28a8..68a89b26 100644 --- a/rdtools/test/analysis_chains_test.py +++ b/rdtools/test/analysis_chains_test.py @@ -760,6 +760,7 @@ def test_energy_from_power_shifted_hourly_data(): energy = normalization.energy_from_power(pv) pd.testing.assert_series_equal(energy, pv[1:], check_names=False) + def test_validated_filter_dict_initialization(): valid_keys = ["key1", "key2"] filter_dict = ValidatedFilterDict(valid_keys, key1="value1", key2="value2")