From 8492b1dfd698c4741cb6f5a3227774979bfe1f63 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Fri, 14 Dec 2018 10:10:16 -0700 Subject: [PATCH 01/12] Add PVSystem pvsyst_celltemp methods --- docs/sphinx/source/whatsnew/v0.6.1.rst | 1 + pvlib/pvsystem.py | 16 ++++++++++++++++ pvlib/test/test_pvsystem.py | 17 +++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.6.1.rst b/docs/sphinx/source/whatsnew/v0.6.1.rst index 616be156e1..3235a4e800 100644 --- a/docs/sphinx/source/whatsnew/v0.6.1.rst +++ b/docs/sphinx/source/whatsnew/v0.6.1.rst @@ -58,6 +58,7 @@ Enhancements * Add option for :py:func:`pvlib.irradiance.disc` to use relative airmass by supplying `pressure=None`. (:issue:`449`) * Created :py:func:`pvlib.pvsystem.pvsyst_celltemp` to implement PVsyst's cell temperature model. (:issue:`552`) +* Add `PVSystem` class method :py:func:`~pvlib.pvsystem.PVSystem.pvsyst_celltemp` (:issue:`633`) Bug fixes diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 6215c1a73d..634ef4189c 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -511,6 +511,22 @@ def sapm_effective_irradiance(self, poa_direct, poa_diffuse, poa_direct, poa_diffuse, airmass_absolute, aoi, self.module_parameters, reference_irradiance=reference_irradiance) + def pvsyst_celltemp(self, poa_global, wind_speed, temp_air, eta_m=0.1, + alpha_absorption=0.9): + """Uses :py:func:`pvsyst_celltemp` to calculate module temperatures + based on ``self.racking_model`` and the input parameters. + + Parameters + ---------- + See pvsystem.pvsyst_celltemp for details + + Returns + ------- + See pvsystem.pvsyst_celltemp for details + """ + return pvsyst_celltemp(poa_global, wind_speed, temp_air, eta_m, + alpha_absorption, temp_model=self.racking_model) + def first_solar_spectral_loss(self, pw, airmass_absolute): """ diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py index bff3277a54..9e5ee7a62b 100644 --- a/pvlib/test/test_pvsystem.py +++ b/pvlib/test/test_pvsystem.py @@ -1118,6 +1118,23 @@ def test_pvsyst_celltemp_with_index(): assert_series_equal(expected, pvtemps) +def test_PVSystem_pvsyst_celltemp(mocker): + racking_model = 'insulated' + system = pvsystem.PVSystem(racking_model=racking_model) + mocker.spy(pvsystem, 'pvsyst_celltemp') + irrads = 1000 + temps = 25 + alpha_absorption = 0.9 + winds = 1 + eta_m = 0.1 + out = system.pvsyst_celltemp(irrads, winds, temps) + pvsystem.pvsyst_celltemp.assert_called_once_with(irrads, winds, temps, + eta_m, alpha_absorption, + temp_model=racking_model) + assert isinstance(out, float) + assert out == 79.0 + + def test_adrinverter(sam_data): inverters = sam_data['adrinverter'] testinv = 'Ablerex_Electronics_Co___Ltd___' \ From c238c48311a3e74c244e5267637f7a312df666a7 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 9 Jan 2019 13:36:07 -0700 Subject: [PATCH 02/12] fix _delta_kt_prime_dirint end values (#638) * fix _delta_kt_prime_dirint end values * syntax, test fixes: * syntax and test fixes * more test fixes * more test fixes * and more test fixes * and still more test fixes * add comments, update whatsnew * delete space --- docs/sphinx/source/whatsnew/v0.6.1.rst | 2 ++ pvlib/irradiance.py | 14 ++++++++++---- pvlib/test/test_irradiance.py | 18 +++++++++--------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.6.1.rst b/docs/sphinx/source/whatsnew/v0.6.1.rst index ec8cc5ba41..3c1dda4b85 100644 --- a/docs/sphinx/source/whatsnew/v0.6.1.rst +++ b/docs/sphinx/source/whatsnew/v0.6.1.rst @@ -73,6 +73,8 @@ Bug fixes * Fix documentation errors when using IPython >= 7.0. * Fix error in :func:`pvlib.modelchain.ModelChain.infer_spectral_model` (:issue:`619`) * Fix error in ``pvlib.spa`` when using Python 3.7 on some platforms. +* Fix error in :func:`pvlib.irradiance._delta_kt_prime_dirint` (:issue:`637`). The error affects + the first and last values of DNI calculated by the function :func:`pvlib.irradiance.dirint` Testing diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 4855187ea4..84193d3cd6 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -1558,14 +1558,20 @@ def _dirint_from_dni_ktprime(dni, kt_prime, solar_zenith, use_delta_kt_prime, def _delta_kt_prime_dirint(kt_prime, use_delta_kt_prime, times): """ - Calculate delta kt prime (Perez eqn 2), or return a default value + Calculate delta_kt_prime (Perez eqn 2 and eqn 3), or return a default value for use with :py:func:`_dirint_bins`. """ if use_delta_kt_prime: # Perez eqn 2 - delta_kt_prime = 0.5*((kt_prime - kt_prime.shift(1)).abs().add( - (kt_prime - kt_prime.shift(-1)).abs(), - fill_value=0)) + kt_next = kt_prime.shift(-1) + kt_previous = kt_prime.shift(1) + # replace nan with values that implement Perez Eq 3 for first and last + # positions. Use kt_previous and kt_next to handle series of length 1 + kt_next.iloc[-1] = kt_previous.iloc[-1] + kt_previous.iloc[0] = kt_next.iloc[0] + delta_kt_prime = 0.5 * ((kt_prime - kt_next).abs().add( + (kt_prime - kt_previous).abs(), + fill_value=0)) else: # do not change unless also modifying _dirint_bins delta_kt_prime = pd.Series(-1, index=times) diff --git a/pvlib/test/test_irradiance.py b/pvlib/test/test_irradiance.py index cd1c5b168d..883d130d2a 100644 --- a/pvlib/test/test_irradiance.py +++ b/pvlib/test/test_irradiance.py @@ -466,13 +466,13 @@ def test_dirint_value(): pressure = 93193. dirint_data = irradiance.dirint(ghi, zenith, times, pressure=pressure) assert_almost_equal(dirint_data.values, - np.array([ 888. , 683.7]), 1) + np.array([868.8, 699.7]), 1) def test_dirint_nans(): times = pd.DatetimeIndex(start='2014-06-24T12-0700', periods=5, freq='6H') ghi = pd.Series([np.nan, 1038.62, 1038.62, 1038.62, 1038.62], index=times) - zenith = pd.Series([10.567, np.nan, 10.567, 10.567, 10.567,], index=times) + zenith = pd.Series([10.567, np.nan, 10.567, 10.567, 10.567], index=times) pressure = pd.Series([93193., 93193., np.nan, 93193., 93193.], index=times) temp_dew = pd.Series([10, 10, 10, np.nan, 10], index=times) dirint_data = irradiance.dirint(ghi, zenith, times, pressure=pressure, @@ -489,7 +489,7 @@ def test_dirint_tdew(): dirint_data = irradiance.dirint(ghi, zenith, times, pressure=pressure, temp_dew=10) assert_almost_equal(dirint_data.values, - np.array([892.9, 636.5]), 1) + np.array([882.1, 672.6]), 1) def test_dirint_no_delta_kt(): @@ -559,7 +559,7 @@ def test_gti_dirint(): expected = pd.DataFrame(array( [[ 21.05796198, 0. , 21.05796198], [ 288.22574368, 60.59964218, 245.37532576], - [ 930.85454521, 695.8504884 , 276.96897609]]), + [ 931.04078010, 695.94965324, 277.06172442]]), columns=expected_col_order, index=times) assert_frame_equal(output, expected) @@ -583,7 +583,7 @@ def test_gti_dirint(): expected = pd.DataFrame(array( [[ 21.05796198, 0. , 21.05796198], [ 289.81109139, 60.52460392, 247.01373353], - [ 932.22047435, 647.68716072, 323.59362885]]), + [ 932.46756378, 648.05001357, 323.49974813]]), columns=expected_col_order, index=times) assert_frame_equal(output, expected) @@ -595,9 +595,9 @@ def test_gti_dirint(): albedo=albedo) expected = pd.DataFrame(array( - [[ 21.3592591 , 0. , 21.3592591 ], - [ 292.5162373 , 64.42628826, 246.95997198], - [ 941.47847463, 727.07261187, 258.25370648]]), + [[ 21.3592591, 0. , 21.3592591 ], + [ 292.5162373, 64.42628826, 246.95997198], + [ 941.6753031, 727.16311901, 258.36548605]]), columns=expected_col_order, index=times) assert_frame_equal(output, expected) @@ -611,7 +611,7 @@ def test_gti_dirint(): expected = pd.DataFrame(array( [[ 21.05796198, 0. , 21.05796198], [ 292.40468994, 36.79559287, 266.3862767 ], - [ 930.72198876, 712.36063132, 261.32196017]]), + [ 931.79627208, 689.81549269, 283.5817439]]), columns=expected_col_order, index=times) assert_frame_equal(output, expected) From 1f26ceeddeb4d405103185743de3b8656a46bd54 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Fri, 14 Dec 2018 10:10:16 -0700 Subject: [PATCH 03/12] Add PVSystem pvsyst_celltemp methods --- docs/sphinx/source/whatsnew/v0.6.1.rst | 1 + pvlib/pvsystem.py | 16 ++++++++++++++++ pvlib/test/test_pvsystem.py | 17 +++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.6.1.rst b/docs/sphinx/source/whatsnew/v0.6.1.rst index 3c1dda4b85..2984449fce 100644 --- a/docs/sphinx/source/whatsnew/v0.6.1.rst +++ b/docs/sphinx/source/whatsnew/v0.6.1.rst @@ -60,6 +60,7 @@ Enhancements * Add option for :py:func:`pvlib.irradiance.disc` to use relative airmass by supplying `pressure=None`. (:issue:`449`) * Created :py:func:`pvlib.pvsystem.pvsyst_celltemp` to implement PVsyst's cell temperature model. (:issue:`552`) +* Add `PVSystem` class method :py:func:`~pvlib.pvsystem.PVSystem.pvsyst_celltemp` (:issue:`633`) Bug fixes diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 6215c1a73d..634ef4189c 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -511,6 +511,22 @@ def sapm_effective_irradiance(self, poa_direct, poa_diffuse, poa_direct, poa_diffuse, airmass_absolute, aoi, self.module_parameters, reference_irradiance=reference_irradiance) + def pvsyst_celltemp(self, poa_global, wind_speed, temp_air, eta_m=0.1, + alpha_absorption=0.9): + """Uses :py:func:`pvsyst_celltemp` to calculate module temperatures + based on ``self.racking_model`` and the input parameters. + + Parameters + ---------- + See pvsystem.pvsyst_celltemp for details + + Returns + ------- + See pvsystem.pvsyst_celltemp for details + """ + return pvsyst_celltemp(poa_global, wind_speed, temp_air, eta_m, + alpha_absorption, temp_model=self.racking_model) + def first_solar_spectral_loss(self, pw, airmass_absolute): """ diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py index bff3277a54..9e5ee7a62b 100644 --- a/pvlib/test/test_pvsystem.py +++ b/pvlib/test/test_pvsystem.py @@ -1118,6 +1118,23 @@ def test_pvsyst_celltemp_with_index(): assert_series_equal(expected, pvtemps) +def test_PVSystem_pvsyst_celltemp(mocker): + racking_model = 'insulated' + system = pvsystem.PVSystem(racking_model=racking_model) + mocker.spy(pvsystem, 'pvsyst_celltemp') + irrads = 1000 + temps = 25 + alpha_absorption = 0.9 + winds = 1 + eta_m = 0.1 + out = system.pvsyst_celltemp(irrads, winds, temps) + pvsystem.pvsyst_celltemp.assert_called_once_with(irrads, winds, temps, + eta_m, alpha_absorption, + temp_model=racking_model) + assert isinstance(out, float) + assert out == 79.0 + + def test_adrinverter(sam_data): inverters = sam_data['adrinverter'] testinv = 'Ablerex_Electronics_Co___Ltd___' \ From a31078a867ff54d0dc054e5154e7f422672ea6c7 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Thu, 10 Jan 2019 10:51:43 -0700 Subject: [PATCH 04/12] create global TEMP_MODELS for sapm and pvsyst --- pvlib/pvsystem.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 634ef4189c..9639a1fea8 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -46,6 +46,16 @@ } +TEMP_MODELS = { + 'sapm': {'open_rack_cell_glassback': [-3.47, -.0594, 3], + 'roof_mount_cell_glassback': [-2.98, -.0471, 1], + 'open_rack_cell_polymerback': [-3.56, -.0750, 3], + 'insulated_back_polymerback': [-2.81, -.0455, 0], + 'open_rack_polymer_thinfilm_steel': [-3.58, -.113, 3], + '22x_concentrator_tracker': [-3.23, -.130, 13]}, + 'pvsyst': {'freestanding': (29.0, 0), 'insulated': (15.0, 0)} +} + # not sure if this belongs in the pvsystem module. # maybe something more like core.py? It may eventually grow to # import a lot more functionality from other modules. @@ -1876,13 +1886,7 @@ def sapm_celltemp(poa_global, wind_speed, temp_air, sapm ''' - temp_models = {'open_rack_cell_glassback': [-3.47, -.0594, 3], - 'roof_mount_cell_glassback': [-2.98, -.0471, 1], - 'open_rack_cell_polymerback': [-3.56, -.0750, 3], - 'insulated_back_polymerback': [-2.81, -.0455, 0], - 'open_rack_polymer_thinfilm_steel': [-3.58, -.113, 3], - '22x_concentrator_tracker': [-3.23, -.130, 13] - } + temp_models = TEMP_MODELS['sapm'] if isinstance(model, str): model = temp_models[model.lower()] @@ -1896,9 +1900,9 @@ def sapm_celltemp(poa_global, wind_speed, temp_air, E0 = 1000. # Reference irradiance - temp_module = pd.Series(poa_global*np.exp(a + b*wind_speed) + temp_air) + temp_module = pd.Series(poa_global * np.exp(a + b * wind_speed) + temp_air) - temp_cell = temp_module + (poa_global / E0)*(deltaT) + temp_cell = temp_module + (poa_global / E0) * (deltaT) return pd.DataFrame({'temp_cell': temp_cell, 'temp_module': temp_module}) @@ -1960,7 +1964,7 @@ def pvsyst_celltemp(poa_global, wind_speed, temp_air, eta_m=0.1, photovoltaic modules." Progress in Photovoltaics 16(4): 307-315. """ - temp_models = {"freestanding": (29.0, 0), "insulated": (15.0, 0)} + temp_models = TEMP_MODELS['sapm'] if isinstance(temp_model, str): natural_convenction_coeff, forced_convection_coeff = temp_models[ From ecdb22859fda4759cc29716f42ba5b09e511c78e Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Thu, 10 Jan 2019 12:10:18 -0700 Subject: [PATCH 05/12] correct model choice in pvsyst_celltemp function --- pvlib/pvsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 9639a1fea8..baf9b3ffc6 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1964,7 +1964,7 @@ def pvsyst_celltemp(poa_global, wind_speed, temp_air, eta_m=0.1, photovoltaic modules." Progress in Photovoltaics 16(4): 307-315. """ - temp_models = TEMP_MODELS['sapm'] + temp_models = TEMP_MODELS['pvsyst'] if isinstance(temp_model, str): natural_convenction_coeff, forced_convection_coeff = temp_models[ From c71cbe11b1b15ef8053aa87612af1aaa3d182112 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Fri, 14 Dec 2018 10:10:16 -0700 Subject: [PATCH 06/12] Add PVSystem pvsyst_celltemp methods --- docs/sphinx/source/whatsnew/v0.6.1.rst | 1 + pvlib/pvsystem.py | 16 ++++++++++++++++ pvlib/test/test_pvsystem.py | 17 +++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.6.1.rst b/docs/sphinx/source/whatsnew/v0.6.1.rst index 3c1dda4b85..2984449fce 100644 --- a/docs/sphinx/source/whatsnew/v0.6.1.rst +++ b/docs/sphinx/source/whatsnew/v0.6.1.rst @@ -60,6 +60,7 @@ Enhancements * Add option for :py:func:`pvlib.irradiance.disc` to use relative airmass by supplying `pressure=None`. (:issue:`449`) * Created :py:func:`pvlib.pvsystem.pvsyst_celltemp` to implement PVsyst's cell temperature model. (:issue:`552`) +* Add `PVSystem` class method :py:func:`~pvlib.pvsystem.PVSystem.pvsyst_celltemp` (:issue:`633`) Bug fixes diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 6215c1a73d..634ef4189c 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -511,6 +511,22 @@ def sapm_effective_irradiance(self, poa_direct, poa_diffuse, poa_direct, poa_diffuse, airmass_absolute, aoi, self.module_parameters, reference_irradiance=reference_irradiance) + def pvsyst_celltemp(self, poa_global, wind_speed, temp_air, eta_m=0.1, + alpha_absorption=0.9): + """Uses :py:func:`pvsyst_celltemp` to calculate module temperatures + based on ``self.racking_model`` and the input parameters. + + Parameters + ---------- + See pvsystem.pvsyst_celltemp for details + + Returns + ------- + See pvsystem.pvsyst_celltemp for details + """ + return pvsyst_celltemp(poa_global, wind_speed, temp_air, eta_m, + alpha_absorption, temp_model=self.racking_model) + def first_solar_spectral_loss(self, pw, airmass_absolute): """ diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py index bff3277a54..9e5ee7a62b 100644 --- a/pvlib/test/test_pvsystem.py +++ b/pvlib/test/test_pvsystem.py @@ -1118,6 +1118,23 @@ def test_pvsyst_celltemp_with_index(): assert_series_equal(expected, pvtemps) +def test_PVSystem_pvsyst_celltemp(mocker): + racking_model = 'insulated' + system = pvsystem.PVSystem(racking_model=racking_model) + mocker.spy(pvsystem, 'pvsyst_celltemp') + irrads = 1000 + temps = 25 + alpha_absorption = 0.9 + winds = 1 + eta_m = 0.1 + out = system.pvsyst_celltemp(irrads, winds, temps) + pvsystem.pvsyst_celltemp.assert_called_once_with(irrads, winds, temps, + eta_m, alpha_absorption, + temp_model=racking_model) + assert isinstance(out, float) + assert out == 79.0 + + def test_adrinverter(sam_data): inverters = sam_data['adrinverter'] testinv = 'Ablerex_Electronics_Co___Ltd___' \ From 763d9425175579ea3a48e604b8a9e24f2115262b Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Thu, 10 Jan 2019 10:51:43 -0700 Subject: [PATCH 07/12] create global TEMP_MODELS for sapm and pvsyst --- pvlib/pvsystem.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 634ef4189c..9639a1fea8 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -46,6 +46,16 @@ } +TEMP_MODELS = { + 'sapm': {'open_rack_cell_glassback': [-3.47, -.0594, 3], + 'roof_mount_cell_glassback': [-2.98, -.0471, 1], + 'open_rack_cell_polymerback': [-3.56, -.0750, 3], + 'insulated_back_polymerback': [-2.81, -.0455, 0], + 'open_rack_polymer_thinfilm_steel': [-3.58, -.113, 3], + '22x_concentrator_tracker': [-3.23, -.130, 13]}, + 'pvsyst': {'freestanding': (29.0, 0), 'insulated': (15.0, 0)} +} + # not sure if this belongs in the pvsystem module. # maybe something more like core.py? It may eventually grow to # import a lot more functionality from other modules. @@ -1876,13 +1886,7 @@ def sapm_celltemp(poa_global, wind_speed, temp_air, sapm ''' - temp_models = {'open_rack_cell_glassback': [-3.47, -.0594, 3], - 'roof_mount_cell_glassback': [-2.98, -.0471, 1], - 'open_rack_cell_polymerback': [-3.56, -.0750, 3], - 'insulated_back_polymerback': [-2.81, -.0455, 0], - 'open_rack_polymer_thinfilm_steel': [-3.58, -.113, 3], - '22x_concentrator_tracker': [-3.23, -.130, 13] - } + temp_models = TEMP_MODELS['sapm'] if isinstance(model, str): model = temp_models[model.lower()] @@ -1896,9 +1900,9 @@ def sapm_celltemp(poa_global, wind_speed, temp_air, E0 = 1000. # Reference irradiance - temp_module = pd.Series(poa_global*np.exp(a + b*wind_speed) + temp_air) + temp_module = pd.Series(poa_global * np.exp(a + b * wind_speed) + temp_air) - temp_cell = temp_module + (poa_global / E0)*(deltaT) + temp_cell = temp_module + (poa_global / E0) * (deltaT) return pd.DataFrame({'temp_cell': temp_cell, 'temp_module': temp_module}) @@ -1960,7 +1964,7 @@ def pvsyst_celltemp(poa_global, wind_speed, temp_air, eta_m=0.1, photovoltaic modules." Progress in Photovoltaics 16(4): 307-315. """ - temp_models = {"freestanding": (29.0, 0), "insulated": (15.0, 0)} + temp_models = TEMP_MODELS['sapm'] if isinstance(temp_model, str): natural_convenction_coeff, forced_convection_coeff = temp_models[ From 9e12ef68000569c7c27d50debfdbbf7f0e374801 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Thu, 10 Jan 2019 12:10:18 -0700 Subject: [PATCH 08/12] correct model choice in pvsyst_celltemp function --- pvlib/pvsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 9639a1fea8..baf9b3ffc6 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1964,7 +1964,7 @@ def pvsyst_celltemp(poa_global, wind_speed, temp_air, eta_m=0.1, photovoltaic modules." Progress in Photovoltaics 16(4): 307-315. """ - temp_models = TEMP_MODELS['sapm'] + temp_models = TEMP_MODELS['pvsyst'] if isinstance(temp_model, str): natural_convenction_coeff, forced_convection_coeff = temp_models[ From a507921752c0f0b273fe69795bdc31bb200571be Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Tue, 15 Jan 2019 12:48:53 -0700 Subject: [PATCH 09/12] convert sapm temp models to tuples --- pvlib/pvsystem.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index baf9b3ffc6..7529088af0 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -47,12 +47,12 @@ TEMP_MODELS = { - 'sapm': {'open_rack_cell_glassback': [-3.47, -.0594, 3], - 'roof_mount_cell_glassback': [-2.98, -.0471, 1], - 'open_rack_cell_polymerback': [-3.56, -.0750, 3], - 'insulated_back_polymerback': [-2.81, -.0455, 0], - 'open_rack_polymer_thinfilm_steel': [-3.58, -.113, 3], - '22x_concentrator_tracker': [-3.23, -.130, 13]}, + 'sapm': {'open_rack_cell_glassback': (-3.47, -.0594, 3), + 'roof_mount_cell_glassback': (-2.98, -.0471, 1), + 'open_rack_cell_polymerback': (-3.56, -.0750, 3), + 'insulated_back_polymerback': (-2.81, -.0455, 0), + 'open_rack_polymer_thinfilm_steel': (-3.58, -.113, 3), + '22x_concentrator_tracker': (-3.23, -.130, 13)}, 'pvsyst': {'freestanding': (29.0, 0), 'insulated': (15.0, 0)} } From e8fc4894d624e2c8a6ee64d1a081e36bc8209089 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 16 Jan 2019 10:58:04 -0700 Subject: [PATCH 10/12] implement _build_kwargs into pvsyst_celltemp --- pvlib/pvsystem.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 7529088af0..d7b6636fde 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -521,8 +521,7 @@ def sapm_effective_irradiance(self, poa_direct, poa_diffuse, poa_direct, poa_diffuse, airmass_absolute, aoi, self.module_parameters, reference_irradiance=reference_irradiance) - def pvsyst_celltemp(self, poa_global, wind_speed, temp_air, eta_m=0.1, - alpha_absorption=0.9): + def pvsyst_celltemp(self, poa_global, wind_speed, temp_air): """Uses :py:func:`pvsyst_celltemp` to calculate module temperatures based on ``self.racking_model`` and the input parameters. @@ -534,8 +533,9 @@ def pvsyst_celltemp(self, poa_global, wind_speed, temp_air, eta_m=0.1, ------- See pvsystem.pvsyst_celltemp for details """ - return pvsyst_celltemp(poa_global, wind_speed, temp_air, eta_m, - alpha_absorption, temp_model=self.racking_model) + kwargs = _build_kwargs(['eta_m', 'alpha_absorption'], self.module_parameters) + return pvsyst_celltemp(poa_global, wind_speed, temp_air, + temp_model=self.racking_model, **kwargs) def first_solar_spectral_loss(self, pw, airmass_absolute): From c778a630864ceeb437b86783c9e25d556f2dcab3 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 16 Jan 2019 11:46:45 -0700 Subject: [PATCH 11/12] amend with non-default parameters and new api --- pvlib/test/test_pvsystem.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py index 9e5ee7a62b..4a1ef529f7 100644 --- a/pvlib/test/test_pvsystem.py +++ b/pvlib/test/test_pvsystem.py @@ -1120,19 +1120,22 @@ def test_pvsyst_celltemp_with_index(): def test_PVSystem_pvsyst_celltemp(mocker): racking_model = 'insulated' - system = pvsystem.PVSystem(racking_model=racking_model) + alpha_absorption = 0.85 + eta_m = 0.17 + module_parameters = {} + module_parameters['alpha_absorption'] = alpha_absorption + module_parameters['eta_m'] = eta_m + system = pvsystem.PVSystem(racking_model=racking_model, + module_parameters=module_parameters) mocker.spy(pvsystem, 'pvsyst_celltemp') - irrads = 1000 - temps = 25 - alpha_absorption = 0.9 - winds = 1 - eta_m = 0.1 - out = system.pvsyst_celltemp(irrads, winds, temps) - pvsystem.pvsyst_celltemp.assert_called_once_with(irrads, winds, temps, - eta_m, alpha_absorption, - temp_model=racking_model) + irrad = 800 + temp = 45 + wind = 0.5 + out = system.pvsyst_celltemp(irrad, wind, temp) + pvsystem.pvsyst_celltemp.assert_called_once_with( + irrad, wind, temp, eta_m, alpha_absorption, racking_model) assert isinstance(out, float) - assert out == 79.0 + assert out < 90 and out > 70 def test_adrinverter(sam_data): From 96d5be9cad768fea8a7bd42dfe19fda82a53822a Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 16 Jan 2019 14:33:17 -0700 Subject: [PATCH 12/12] Stickler-ci polish --- pvlib/pvsystem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index d7b6636fde..0dfdb073bc 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -533,7 +533,8 @@ def pvsyst_celltemp(self, poa_global, wind_speed, temp_air): ------- See pvsystem.pvsyst_celltemp for details """ - kwargs = _build_kwargs(['eta_m', 'alpha_absorption'], self.module_parameters) + kwargs = _build_kwargs(['eta_m', 'alpha_absorption'], + self.module_parameters) return pvsyst_celltemp(poa_global, wind_speed, temp_air, temp_model=self.racking_model, **kwargs)