From 4b33f8dd049d5418433df800fc8c0b5bc81fb99c Mon Sep 17 00:00:00 2001 From: Tony Lorenzo Date: Fri, 5 Feb 2021 11:27:38 -0700 Subject: [PATCH 1/2] Make sure times are assigned with ModelChain.run_from_poa --- pvlib/modelchain.py | 2 +- pvlib/tests/test_modelchain.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/modelchain.py b/pvlib/modelchain.py index dbca739942..ee7114e1fd 100644 --- a/pvlib/modelchain.py +++ b/pvlib/modelchain.py @@ -1488,7 +1488,7 @@ def prepare_inputs_from_poa(self, data): data = _to_tuple(data) self._check_multiple_input(data) self._assign_weather(data) - + self._assign_times() self._verify_df(data, required=['poa_global', 'poa_direct', 'poa_diffuse']) self._assign_total_irrad(data) diff --git a/pvlib/tests/test_modelchain.py b/pvlib/tests/test_modelchain.py index 3b48ddf803..1e627b541b 100644 --- a/pvlib/tests/test_modelchain.py +++ b/pvlib/tests/test_modelchain.py @@ -774,6 +774,7 @@ def test_prepare_inputs_from_poa(sapm_dc_snl_ac_system, location, assert_frame_equal(mc.weather, weather_expected) # total_irrad attribute assert_frame_equal(mc.results.total_irrad, total_irrad) + assert not pd.isnull(mc.results.solar_position.index[0]) @pytest.mark.parametrize("input_type", [tuple, list]) From e420dc4aaa649ba36033122b00f1f3bcf33d507c Mon Sep 17 00:00:00 2001 From: Tony Lorenzo Date: Fri, 5 Feb 2021 12:44:33 -0700 Subject: [PATCH 2/2] move _assign_times to _assign_weather --- pvlib/modelchain.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/modelchain.py b/pvlib/modelchain.py index ee7114e1fd..6a8903be85 100644 --- a/pvlib/modelchain.py +++ b/pvlib/modelchain.py @@ -1324,6 +1324,7 @@ def _build_weather(data): _build_weather(weather) for weather in data ) self._configure_results() + self._assign_times() return self def _assign_total_irrad(self, data): @@ -1392,7 +1393,6 @@ def prepare_inputs(self, weather): self._check_multiple_input(weather, strict=False) self._verify_df(weather, required=['ghi', 'dni', 'dhi']) self._assign_weather(weather) - self._assign_times() self._prep_inputs_solar_pos(weather) self._prep_inputs_airmass() @@ -1488,7 +1488,7 @@ def prepare_inputs_from_poa(self, data): data = _to_tuple(data) self._check_multiple_input(data) self._assign_weather(data) - self._assign_times() + self._verify_df(data, required=['poa_global', 'poa_direct', 'poa_diffuse']) self._assign_total_irrad(data)