From 173c47d998d91bbe5ef521275029f1c5aba2c88c Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 4 Dec 2024 14:46:20 -0500 Subject: [PATCH 01/10] add pvlib clearsky filter test in analysis chain --- rdtools/test/analysis_chains_test.py | 96 ++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 5 deletions(-) diff --git a/rdtools/test/analysis_chains_test.py b/rdtools/test/analysis_chains_test.py index efe78df4..e4e48a68 100644 --- a/rdtools/test/analysis_chains_test.py +++ b/rdtools/test/analysis_chains_test.py @@ -87,6 +87,59 @@ def sensor_analysis_aggregated_no_filter(sensor_parameters): return rd_analysis +@pytest.fixture +def clearsky_example_data(basic_parameters): + # Import the example data + file_url = ( + "https://datahub.duramat.org/dataset/" + "a49bb656-7b36-437a-8089-1870a40c2a7d/" + "resource/d2c3fcf4-4f5f-47ad-8743-fc29" + "f1356835/download/pvdaq_system_4_2010" + "-2016_subset_soil_signal.csv" + ) + cache_file = "PVDAQ_system_4_2010-2016_subset_soilsignal.pickle" + + try: + df = pd.read_pickle(cache_file) + except FileNotFoundError: + df = pd.read_csv(file_url, index_col=0, parse_dates=True) + df.to_pickle(cache_file) + + # Specify the Metadata + meta = { + "latitude": 39.7406, + "longitude": -105.1774, + "timezone": "Etc/GMT+7", + "gamma_pdc": -0.005, + "azimuth": 180, + "tilt": 40, + "power_dc_rated": 1000.0, + "temp_model_params": "open_rack_glass_polymer", + } + + # Set the timezone + df.index = df.index.tz_localize(meta["timezone"]) + + # Select two years of data + df_crop = df[df.index < (df.index[0] + pd.Timedelta(days=2 * 365 + 1))] + + basic_parameters["pv"] = df_crop["ac_power"] + basic_parameters["poa_global"] = df_crop["poa_irradiance"] + basic_parameters["temperature_ambient"] = df_crop["ambient_temp"] + basic_parameters["interp_freq"] = "1min" + + # Set the pvlib location + loc = pvlib.location.Location(meta["latitude"], meta["longitude"], tz=meta["timezone"]) + + cs_input = dict( + pvlib_location=loc, + pv_tilt=meta["tilt"], + pv_azimuth=meta["azimuth"], + solar_position_method="ephemeris", # just to improve test execution speed + ) + return basic_parameters, cs_input + + def test_interpolation(basic_parameters, degradation_trend): power = degradation_trend @@ -436,9 +489,7 @@ def test_no_gamma_pdc(sensor_parameters): @pytest.fixture -def clearsky_parameters( - basic_parameters, sensor_parameters, cs_input, degradation_trend -): +def clearsky_parameters(basic_parameters, sensor_parameters, cs_input, degradation_trend): # clear-sky weather data. Uses TrendAnalysis's internal clear-sky # functions to generate the data. rd_analysis = TrendAnalysis(**sensor_parameters) @@ -461,6 +512,16 @@ def clearsky_analysis(cs_input, clearsky_parameters): return rd_analysis +@pytest.fixture +def clearsky_pvlib_analysis(clearsky_example_data): + clearsky_parameters_example, cs_input_example = clearsky_example_data + rd_analysis = TrendAnalysis(**clearsky_parameters_example) + rd_analysis.set_clearsky(**cs_input_example) + rd_analysis.filter_params["clearsky_filter"] = {"model": "pvlib"} + rd_analysis.clearsky_analysis(analyses=["yoy_degradation"]) + return rd_analysis + + @pytest.fixture def clearsky_optional(cs_input, clearsky_analysis): # optional parameters to exercise other branches @@ -486,15 +547,33 @@ def sensor_clearsky_analysis(cs_input, clearsky_parameters): return rd_analysis +@pytest.fixture +def sensor_clearsky_pvlib_analysis(clearsky_example_data): + clearsky_parameters_example, cs_input_example = clearsky_example_data + rd_analysis = TrendAnalysis(**clearsky_parameters_example) + rd_analysis.set_clearsky(**cs_input_example) + rd_analysis.filter_params = {} # disable all index-based filters + rd_analysis.filter_params["sensor_clearsky_filter"] = {"model": "pvlib"} + rd_analysis.sensor_analysis(analyses=["yoy_degradation"]) + return rd_analysis + + def test_clearsky_analysis(clearsky_analysis): yoy_results = clearsky_analysis.results["clearsky"]["yoy_degradation"] ci = yoy_results["rd_confidence_interval"] rd = yoy_results["p50_rd"] - print(ci) assert pytest.approx(rd, abs=1e-2) == -5.15 assert pytest.approx(ci, abs=1e-2) == [-5.17, -5.13] +def test_clearsky_pvlib_analysis(clearsky_pvlib_analysis): + yoy_results = clearsky_pvlib_analysis.results["clearsky"]["yoy_degradation"] + ci = yoy_results["rd_confidence_interval"] + rd = yoy_results["p50_rd"] + assert pytest.approx(rd, abs=1e-2) == -1.589 + assert pytest.approx(ci, abs=1e-2) == [-2.417, -0.861] + + def test_clearsky_analysis_filter_components(clearsky_analysis): columns = clearsky_analysis.clearsky_filter_components_aggregated.columns assert {'two_way_window_filter'} == set(columns) @@ -523,11 +602,18 @@ def test_sensor_clearsky_analysis(sensor_clearsky_analysis): yoy_results = sensor_clearsky_analysis.results["sensor"]["yoy_degradation"] ci = yoy_results["rd_confidence_interval"] rd = yoy_results["p50_rd"] - print(ci) assert -5.18 == pytest.approx(rd, abs=1e-2) assert [-5.18, -5.18] == pytest.approx(ci, abs=1e-2) +def test_sensor_clearsky_pvlib_analysis(sensor_clearsky_pvlib_analysis): + yoy_results = sensor_clearsky_pvlib_analysis.results["sensor"]["yoy_degradation"] + ci = yoy_results["rd_confidence_interval"] + rd = yoy_results["p50_rd"] + assert -1.478 == pytest.approx(rd, abs=1e-2) + assert [-1.926, -0.649] == pytest.approx(ci, abs=1e-2) + + @pytest.fixture def clearsky_analysis_exp_power(clearsky_parameters, clearsky_optional): power_expected = normalization.pvwatts_dc_power( From 9f664c74a76ff2f88b0c622c74a66394b5dcf629 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 4 Dec 2024 14:49:33 -0500 Subject: [PATCH 02/10] 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..966ba44e 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 --------- @@ -36,6 +36,7 @@ Tests ----- * Testing matrix was updated to include python = [3.9, 3.10, 3.11, 3.12] (:pull:`428`) * nbval sanitization rules were added for date and time stamp (:pull:`428`) +* add tests for pvlib clearsky fiter in analysis chain (:pull:`441`) Documentation ------------- From 7f1d3c04262e37f10a832c78446a56cc15c19124 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 4 Dec 2024 14:51:06 -0500 Subject: [PATCH 03/10] update default window length in pvlib_clearsky_filter docstring --- rdtools/filtering.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdtools/filtering.py b/rdtools/filtering.py index e3255b36..6a065bae 100644 --- a/rdtools/filtering.py +++ b/rdtools/filtering.py @@ -187,7 +187,7 @@ def pvlib_clearsky_filter( Plane of array irradiance based on measurments poa_global_clearsky : pandas.Series Plane of array irradiance based on a clear sky model - window_length : int, default 10 + window_length : int, default 90 Length of sliding time window in minutes. Must be greater than 2 periods. mean_diff : float, default 75 From 68d3fc45f4fab38496117fa237b8d4f78b6ab556 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 4 Dec 2024 15:20:42 -0500 Subject: [PATCH 04/10] fix ci interval --- rdtools/test/analysis_chains_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdtools/test/analysis_chains_test.py b/rdtools/test/analysis_chains_test.py index e4e48a68..f6da93bb 100644 --- a/rdtools/test/analysis_chains_test.py +++ b/rdtools/test/analysis_chains_test.py @@ -611,7 +611,7 @@ def test_sensor_clearsky_pvlib_analysis(sensor_clearsky_pvlib_analysis): ci = yoy_results["rd_confidence_interval"] rd = yoy_results["p50_rd"] assert -1.478 == pytest.approx(rd, abs=1e-2) - assert [-1.926, -0.649] == pytest.approx(ci, abs=1e-2) + assert [-2.495, -0.649] == pytest.approx(ci, abs=1e-2) @pytest.fixture From 604195135b043098b56b86bccdd4b2e44efa7dd3 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 18 Dec 2024 09:26:20 -0500 Subject: [PATCH 05/10] 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 3b7e8e630a10074df07e72f29eca099649daee58 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 18 Dec 2024 09:37:14 -0500 Subject: [PATCH 06/10] 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 1158026b508a3359bd0b587943df8c0a19155531 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 18 Dec 2024 09:49:00 -0500 Subject: [PATCH 07/10] move changes to pending changelog 4 --- docs/sphinx/source/changelog/pending.rst | 1 + 1 file changed, 1 insertion(+) 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`) From 1a2fb62007706253f3b9448477aad1f56bdeeb65 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 18 Dec 2024 10:12:40 -0500 Subject: [PATCH 08/10] move changes to pending changelog 5 --- docs/sphinx/source/changelog/pending.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/sphinx/source/changelog/pending.rst b/docs/sphinx/source/changelog/pending.rst index 06e34d3f..c999c1f1 100644 --- a/docs/sphinx/source/changelog/pending.rst +++ b/docs/sphinx/source/changelog/pending.rst @@ -13,3 +13,8 @@ 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`) + +Requirements +------------ +* Updated tornado==6.4.2 in ``notebook_requirements.txt`` (:pull:`438`) + From 54d85a5cde13b45696eddfca56602af9a4317301 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 18 Dec 2024 10:15:23 -0500 Subject: [PATCH 09/10] move changes to pending changelog 6 --- docs/sphinx/source/changelog/pending.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sphinx/source/changelog/pending.rst b/docs/sphinx/source/changelog/pending.rst index c999c1f1..12766af0 100644 --- a/docs/sphinx/source/changelog/pending.rst +++ b/docs/sphinx/source/changelog/pending.rst @@ -12,6 +12,7 @@ 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`) +* Add warning to clearsky workflow when power_expected is passed by user (:pull:`439`) Requirements From 27a888b3b7159814962b924780ca7134c8c1a0ed Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 18 Dec 2024 10:18:29 -0500 Subject: [PATCH 10/10] move changes to pending changelog 7 --- docs/sphinx/source/changelog/pending.rst | 5 +++++ docs/sphinx/source/changelog/v3.0.0-beta.0.rst | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/changelog/pending.rst b/docs/sphinx/source/changelog/pending.rst index 12766af0..8497d34e 100644 --- a/docs/sphinx/source/changelog/pending.rst +++ b/docs/sphinx/source/changelog/pending.rst @@ -19,3 +19,8 @@ Requirements ------------ * Updated tornado==6.4.2 in ``notebook_requirements.txt`` (:pull:`438`) + +Tests +----- +* Add tests for pvlib clearsky fiter in analysis chain (:pull:`441`) + 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 966ba44e..f8000382 100644 --- a/docs/sphinx/source/changelog/v3.0.0-beta.0.rst +++ b/docs/sphinx/source/changelog/v3.0.0-beta.0.rst @@ -36,7 +36,6 @@ Tests ----- * Testing matrix was updated to include python = [3.9, 3.10, 3.11, 3.12] (:pull:`428`) * nbval sanitization rules were added for date and time stamp (:pull:`428`) -* add tests for pvlib clearsky fiter in analysis chain (:pull:`441`) Documentation -------------