From f634e39bef5ab3f4655db684d9f9eae2b6475a58 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Thu, 26 Aug 2021 18:47:13 +0200 Subject: [PATCH 001/103] Update atmosphere.py --- pvlib/atmosphere.py | 203 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index ff1ce8d4d5..8db55d96a3 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -683,3 +683,206 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): pvlib.atmosphere.angstrom_aod_at_lambda """ return - np.log(aod1 / aod2) / np.log(lambda1 / lambda2) + +def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, + module_type=None, coefficients=None, + min_aod500=0.05, max_aod500=0.6, + min_pw=0.25, max_pw=4): + + r""" + Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), + aerosol optical depth (AOD) at 500 nm and precipitable water (PW). + + Estimates a spectral mismatch modifier :math:`M` representing the effect on + module short circuit current of variation in the spectral + irradiance, :math:`MM` is estimated from absolute (pressure-adjusted) AM, + :math:`ama`, AOD at 500 nm, :math:`aod500` and PW, :math:`pw`. + + The best fit polynomial for each atmospheric parameter (AM, AOD, PW) and + PV technology under study has been obtained from synthetic spectra generated with + SMARTS [1], considering the following boundary conditions: + + * :math:`1.0 <= ama <= 5.0` + * :math:`0.05 <= aod500 <= 0.6` + * :math:`0.25 \textrm{cm} <= pw <= 4 \textrm{cm}` + * Spectral range is limited to that of CMP11 (280 nm to 2800 nm) + * All other parameters fixed at G173 standard + + Elevation (deg), AOD and PW data were recorded in the city of Jaén, Spain for one year + synchronously with both, broadband and spectroradiometric measurements of 30º tilted + global irradiance logged in 5-min intervals. AM was estimated through elevation data. + + Finally, the spectral mismatch factor was calculated for each of the PV technologies + and a multivariable regression adjustment as a function of AM, AOD and PW was performed + according to [2] and [3]. As such, the polynomial adjustment coefficients + included in [3] were obtained. + + + Parameters + ---------- + airmass_absolute : array-like + absolute (pressure-adjusted) airmass. [unitless] + + aod500 : array-like + atmospheric aerosol optical depth at 500 nm. [unitless] + + pw : array-like + atmospheric precipitable water. [cm] + + min_aod500 : float, default 0.05 + minimum atmospheric aerosol optical depth at 500 nm. Any aod500 value lower than min_aod500 + is set to min_aod500 to avoid model divergence. [unitless] + + max_aod500 : float, default 0.6 + maximum atmospheric aerosol optical depth at 500 nm. Any aod500 value higher than max_aod500 + is set to NaN to avoid model divergence. [unitless] + + min_pw : float, default 0.25 + minimum atmospheric precipitable water. Any pw value lower than min_pw + is set to min_pw to avoid model divergence. [cm] + + max_pw : float, default 4 + maximum atmospheric precipitable water. Any pw value higher than max_pw + is set to NaN to avoid model divergence. [cm] + + module_type : None or string, default None + a string specifying a cell type. Values of 'cdte', 'monosi', 'cigs', + 'multisi','asi' and 'pervovskite'. If provided, + module_type selects default coefficients for the following modules: + + * 'cdte' - anonymous CdTe module. + * 'monosi', - anonymous sc-si module. + * 'multisi', - anonymous mc-si- module. + * 'cigs' - anonymous copper indium gallium selenide module. + * 'asi' - anonymous amorphous silicon module. + * 'perovskite' - anonymous pervoskite module. + + + coefficients : None or array-like, default None + the coefficients employed have been obtained with experimental + data in the city of Jaén, Spain. It is pending to verify if such + coefficients vary in places with extreme climates where AOD and pw values + are frequently high. + + Returns + ------- + modifier: array-like + spectral mismatch factor (unitless) which is can be multiplied + with broadband irradiance reaching a module's cells to estimate + effective irradiance, i.e., the irradiance that is converted to + electrical current. + + References + ---------- + .. [1] Gueymard, Christian. SMARTS2: a simple model of the atmospheric + radiative transfer of sunshine: algorithms and performance + assessment. Cocoa, FL: Florida Solar Energy Center, 1995. + .. [2] Theristis, M., Fernández, E., Almonacid, F., and Pérez-Higueras, Pedro. + "Spectral Corrections Based on Air Mass, Aerosol Optical Depth + and Precipitable Water for CPV Performance Modeling. + " IEEE Journal of Photovoltaics 2016, 6(6), 1598-1604. + https://doi.org/10.1109/jphotov.2016.2606702 + .. [3] Caballero, J.A., Fernández, E., Theristis, M., + Almonacid, F., and Nofuentes, G. + "Spectral Corrections Based on Air Mass, Aerosol Optical Depth + and Precipitable Water for PV Performance Modeling. + " IEEE Journal of Photovoltaics 2018, 8(2), 552-558. + https://doi.org/10.1109/jphotov.2017.2787019 + + """ + + # --- Screen Input Data --- + + # *** ama *** + # Replace Extremely High ama with ama 10 to prevent model divergence + # ama > 10 will only occur very close to sunset + if np.max(airmass_absolute) > 10: + airmass_absolute = np.minimum(airmass_absolute, 10) + + # Warn user about ama data that is exceptionally low + + if np.min(airmass_absolute) < 0.58: + warn('Exceptionally low air mass: ' + + 'model not intended for extra-terrestrial use') + # pvl_absoluteairmass(1,pvl_alt2pres(4340)) = 0.58 Elevation of + # Mina Pirquita, Argentian = 4340 m. Highest elevation city with + # population over 50,000. + + # *** aod500 *** + # Replace aod500 Values below 0.05 with 0.05 to prevent model from + # diverging" + aod500 = np.atleast_1d(aod500) + aod500 = aod500.astype('float64') + if np.min(aod500) < min_aod500: + aod500 = np.maximum(aod500, min_aod500) + warn(f'Exceptionally low aod values replaced with {min_aod500} to ' + 'prevent model divergence') + + # Warn user about aod500 data that is exceptionally high + if np.max(aod500) > max_aod500: + aod500[aod500 > max_aod500] = np.nan + warn('Exceptionally high aod values replaced by np.nan: ' + 'check input data.') + + # *** pw *** + # Replace pw Values below 0.25 cm with 0.25 cm to prevent model from + # diverging" + pw = np.atleast_1d(pw) + pw = pw.astype('float64') + if np.min(pw) < min_pw: + pw = np.maximum(pw, min_pw) + warn(f'Exceptionally low pw values replaced with {min_pw} cm to ' + 'prevent model divergence') + + # Warn user about pw data that is exceptionally high + if np.max(pw) > max_pw: + pw[pw > max_pw] = np.nan + warn('Exceptionally high pw values replaced by np.nan: ' + 'check input data.') + + + + + # Experimental coefficients + + _coefficients = {} + _coefficients['cdte'] = ( + 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0 , 1) + _coefficients['monosi'] = ( + 0.9706, 0.0377, -0.0123, 0.0025, -0.0002, 0.0159, -0.0165, 0, -0.0016, -0.0027, 1, 0) + _coefficients['multisi'] = ( + 0.9836, 0.0254, -0.0085, 0.0016, -0.0001, 0.0094, -0.0132, 0, -0.0002, -0.0011, 1 , 0) + _coefficients['cigs'] = ( + 0.9801, 0.0283, -0.0092, 0.0019, -0.0001, 0.0117, -0.0126, 0, -0.0011, -0.0019, 1 , 0) + _coefficients['asi'] = ( + 1.1060, -0.0848, 0.0302, -0.0076, 0.0006, -0.12838, 0.0986, -0.0254, 0.0156, 0.0146, 1 , 0) + _coefficients['perovskite'] = ( + 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, 0.0583, -0.0159, 0.01251, 0.0109, 1 , 0) + + if module_type is not None and coefficients is None: + coefficients = _coefficients[module_type.lower()] + elif module_type is None and coefficients is not None: + pass + elif module_type is None and coefficients is None: + raise TypeError('No valid input provided, both module_type and ' + + 'coefficients are None') + else: + raise TypeError('Cannot resolve input, must supply only one of ' + + 'module_type and coefficients') + + # Evaluate Spectral Shift + coeff = coefficients + ama = airmass_absolute + aod500_ref=0.84; + pw_ref=1.42; + + modifier = ( + coeff[0] + (ama) *coeff[1] + (ama*ama) * coeff[2] + +(ama*ama*ama) * coeff[3] + (ama*ama*ama*ama) * coeff[4] + + (aod500-aod500_ref) * coeff[5] + ((aod500-aod500_ref) * (ama) * coeff[6]) * coeff[10] + + ((aod500-aod500_ref) * (np.log(ama)) * coeff[6]) * coeff[11] + +(aod500-aod500_ref) + (ama * ama) * coeff[7] + + (pw-pw_ref) * coeff[8] + (pw-pw_ref) * (np.log(ama)) * coeff[9] + ) + + return modifier \ No newline at end of file From b5d7fecad82e83212381f4efda3ccfe457d2bdfb Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Thu, 26 Aug 2021 19:02:11 +0200 Subject: [PATCH 002/103] Update atmosphere.py --- pvlib/atmosphere.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 8db55d96a3..8a1eac3b8e 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -684,6 +684,7 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): """ return - np.log(aod1 / aod2) / np.log(lambda1 / lambda2) + def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, module_type=None, coefficients=None, min_aod500=0.05, max_aod500=0.6, @@ -885,4 +886,4 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, (pw-pw_ref) * coeff[8] + (pw-pw_ref) * (np.log(ama)) * coeff[9] ) - return modifier \ No newline at end of file + return modifier From eb948e0188a0d681c2e01f51bda0bbcd594fe0f0 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 11:14:05 +0200 Subject: [PATCH 003/103] Update atmosphere.py --- pvlib/atmosphere.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 8db55d96a3..eedb590b81 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -684,6 +684,7 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): """ return - np.log(aod1 / aod2) / np.log(lambda1 / lambda2) + def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, module_type=None, coefficients=None, min_aod500=0.05, max_aod500=0.6, From 03920a62f223739787118802786310e54eab1379 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 11:35:42 +0200 Subject: [PATCH 004/103] Update atmosphere.py --- pvlib/atmosphere.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index b9ed5e9fe2..8067d304d1 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -684,11 +684,8 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): """ return - np.log(aod1 / aod2) / np.log(lambda1 / lambda2) -<<<<<<< HEAD -======= ->>>>>>> b5d7fecad82e83212381f4efda3ccfe457d2bdfb def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, module_type=None, coefficients=None, min_aod500=0.05, max_aod500=0.6, @@ -715,7 +712,8 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, Elevation (deg), AOD and PW data were recorded in the city of Jaén, Spain for one year synchronously with both, broadband and spectroradiometric measurements of 30º tilted - global irradiance logged in 5-min intervals. AM was estimated through elevation data. + global irradiance south-facing logged in 5-min intervals. + AM was estimated through elevation data. Finally, the spectral mismatch factor was calculated for each of the PV technologies and a multivariable regression adjustment as a function of AM, AOD and PW was performed From be39d2e18d23c784d932c625acc01dcb0e53abf8 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:03:47 +0200 Subject: [PATCH 005/103] Merge branch 'Spectral-corrections' of https://github.com/Jacc0027/pvlib-python into Spectral-corrections --- pvlib/atmosphere.py | 114 +++++++++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 50 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 8067d304d1..f221c584b8 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -686,23 +686,25 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): -def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, - module_type=None, coefficients=None, - min_aod500=0.05, max_aod500=0.6, - min_pw=0.25, max_pw=4): +def AM_AOD_PW_spectral_correction(airmass_absolute,aod500,pw, +module_type=None,coefficients=None,min_aod500=0.05, +max_aod500=0.6,min_pw=0.25,max_pw=4): r""" - Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), - aerosol optical depth (AOD) at 500 nm and precipitable water (PW). + Spectral mismatch modifier based on absolute (pressure-adjusted) + airmass (AM), aerosol optical depth (AOD) at 500 nm and + precipitable water (PW). - Estimates a spectral mismatch modifier :math:`M` representing the effect on - module short circuit current of variation in the spectral - irradiance, :math:`MM` is estimated from absolute (pressure-adjusted) AM, - :math:`ama`, AOD at 500 nm, :math:`aod500` and PW, :math:`pw`. + Estimates a spectral mismatch modifier :math:`M` representing + the effect on module short circuit current of variation in the + spectral irradiance, :math:`MM` is estimated from absolute + (pressure-adjusted) AM, :math:`ama`, AOD at 500 nm, :math:`aod500` + and PW, :math:`pw`. - The best fit polynomial for each atmospheric parameter (AM, AOD, PW) and - PV technology under study has been obtained from synthetic spectra generated with - SMARTS [1], considering the following boundary conditions: + The best fit polynomial for each atmospheric parameter (AM, AOD, PW) + and PV technology under study has been obtained from synthetic spectra + generated with SMARTS [1], considering the following boundary + conditions: * :math:`1.0 <= ama <= 5.0` * :math:`0.05 <= aod500 <= 0.6` @@ -710,15 +712,17 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, * Spectral range is limited to that of CMP11 (280 nm to 2800 nm) * All other parameters fixed at G173 standard - Elevation (deg), AOD and PW data were recorded in the city of Jaén, Spain for one year - synchronously with both, broadband and spectroradiometric measurements of 30º tilted - global irradiance south-facing logged in 5-min intervals. - AM was estimated through elevation data. + Elevation (deg), AOD and PW data were recorded in the city of Jaén, + Spain for one year synchronously with both, broadband and + spectroradiometric measurements of 30º tilted global irradiance + south-facing logged in 5-min intervals. AM was estimated through + elevation data. - Finally, the spectral mismatch factor was calculated for each of the PV technologies - and a multivariable regression adjustment as a function of AM, AOD and PW was performed - according to [2] and [3]. As such, the polynomial adjustment coefficients - included in [3] were obtained. + Finally, the spectral mismatch factor was calculated for each + of the PV technologies and a multivariable regression adjustment + as a function of AM, AOD and PW was performed according to [2] and [3]. + As such, the polynomial adjustment coefficients included in [3] + were obtained. Parameters @@ -733,12 +737,13 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, atmospheric precipitable water. [cm] min_aod500 : float, default 0.05 - minimum atmospheric aerosol optical depth at 500 nm. Any aod500 value lower than min_aod500 - is set to min_aod500 to avoid model divergence. [unitless] + minimum atmospheric aerosol optical depth at 500 nm. Any aod500 value + lower than min_aod500 is set to min_aod500 to avoid model + divergence. [unitless] max_aod500 : float, default 0.6 - maximum atmospheric aerosol optical depth at 500 nm. Any aod500 value higher than max_aod500 - is set to NaN to avoid model divergence. [unitless] + maximum atmospheric aerosol optical depth at 500 nm. Any aod500 value + higher than max_aod500 is set to NaN to avoid model divergence. [unitless] min_pw : float, default 0.25 minimum atmospheric precipitable water. Any pw value lower than min_pw @@ -764,8 +769,8 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, coefficients : None or array-like, default None the coefficients employed have been obtained with experimental data in the city of Jaén, Spain. It is pending to verify if such - coefficients vary in places with extreme climates where AOD and pw values - are frequently high. + coefficients vary in places with extreme climates where AOD and + pw values are frequently high. Returns ------- @@ -777,18 +782,20 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, References ---------- - .. [1] Gueymard, Christian. SMARTS2: a simple model of the atmospheric - radiative transfer of sunshine: algorithms and performance - assessment. Cocoa, FL: Florida Solar Energy Center, 1995. - .. [2] Theristis, M., Fernández, E., Almonacid, F., and Pérez-Higueras, Pedro. - "Spectral Corrections Based on Air Mass, Aerosol Optical Depth - and Precipitable Water for CPV Performance Modeling. - " IEEE Journal of Photovoltaics 2016, 6(6), 1598-1604. - https://doi.org/10.1109/jphotov.2016.2606702 + .. [1] Gueymard, Christian. SMARTS2: a simple model of the + atmospheric radiative transfer of sunshine: algorithms + and performance assessment. Cocoa, FL: + Florida Solar Energy Center, 1995. + .. [2] Theristis, M., Fernández, E., Almonacid, F., and + Pérez-Higueras, Pedro. "Spectral Corrections Based + on Air Mass, Aerosol Optical Depth and Precipitable + Water for CPV Performance Modeling. + "IEEE Journal of Photovoltaics 2016, 6(6), 1598-1604. + https://doi.org/10.1109/jphotov.2016.2606702 .. [3] Caballero, J.A., Fernández, E., Theristis, M., - Almonacid, F., and Nofuentes, G. - "Spectral Corrections Based on Air Mass, Aerosol Optical Depth - and Precipitable Water for PV Performance Modeling. + Almonacid, F., and Nofuentes, G. "Spectral Corrections Based on + Air Mass, Aerosol Optical Depth and Precipitable Water + for PV Performance Modeling. " IEEE Journal of Photovoltaics 2018, 8(2), 552-558. https://doi.org/10.1109/jphotov.2017.2787019 @@ -818,7 +825,7 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, aod500 = aod500.astype('float64') if np.min(aod500) < min_aod500: aod500 = np.maximum(aod500, min_aod500) - warn(f'Exceptionally low aod values replaced with {min_aod500} to ' + warn(f'Exceptionally low aod values replaced with {min_aod500} to' 'prevent model divergence') # Warn user about aod500 data that is exceptionally high @@ -850,28 +857,34 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, _coefficients = {} _coefficients['cdte'] = ( - 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0 , 1) + 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, + -0.0046, -0.0182, 0, 0.0095, 0.0068, 0 , 1) _coefficients['monosi'] = ( - 0.9706, 0.0377, -0.0123, 0.0025, -0.0002, 0.0159, -0.0165, 0, -0.0016, -0.0027, 1, 0) + 0.9706, 0.0377, -0.0123, 0.0025, -0.0002, 0.0159, + -0.0165, 0, -0.0016, -0.0027, 1, 0) _coefficients['multisi'] = ( - 0.9836, 0.0254, -0.0085, 0.0016, -0.0001, 0.0094, -0.0132, 0, -0.0002, -0.0011, 1 , 0) + 0.9836, 0.0254, -0.0085, 0.0016, -0.0001, 0.0094, + -0.0132, 0, -0.0002, -0.0011, 1 , 0) _coefficients['cigs'] = ( - 0.9801, 0.0283, -0.0092, 0.0019, -0.0001, 0.0117, -0.0126, 0, -0.0011, -0.0019, 1 , 0) + 0.9801, 0.0283, -0.0092, 0.0019, -0.0001, 0.0117, + -0.0126, 0, -0.0011, -0.0019, 1 , 0) _coefficients['asi'] = ( - 1.1060, -0.0848, 0.0302, -0.0076, 0.0006, -0.12838, 0.0986, -0.0254, 0.0156, 0.0146, 1 , 0) + 1.1060, -0.0848, 0.0302, -0.0076, 0.0006, -0.12838, + 0.0986, -0.0254, 0.0156, 0.0146, 1 , 0) _coefficients['perovskite'] = ( - 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, 0.0583, -0.0159, 0.01251, 0.0109, 1 , 0) + 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, + 0.0583, -0.0159, 0.01251, 0.0109, 1 , 0) if module_type is not None and coefficients is None: coefficients = _coefficients[module_type.lower()] elif module_type is None and coefficients is not None: pass elif module_type is None and coefficients is None: - raise TypeError('No valid input provided, both module_type and ' + - 'coefficients are None') + raise TypeError('No valid input provided, both module_type' + + 'and coefficients are None') else: - raise TypeError('Cannot resolve input, must supply only one of ' + - 'module_type and coefficients') + raise TypeError('Cannot resolve input, must supply only one' + + 'of module_type and coefficients') # Evaluate Spectral Shift coeff = coefficients @@ -882,7 +895,8 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, modifier = ( coeff[0] + (ama) *coeff[1] + (ama*ama) * coeff[2] +(ama*ama*ama) * coeff[3] + (ama*ama*ama*ama) * coeff[4] - + (aod500-aod500_ref) * coeff[5] + ((aod500-aod500_ref) * (ama) * coeff[6]) * coeff[10] + + (aod500-aod500_ref) * coeff[5] + + ((aod500-aod500_ref) * (ama) * coeff[6]) * coeff[10] + ((aod500-aod500_ref) * (np.log(ama)) * coeff[6]) * coeff[11] +(aod500-aod500_ref) + (ama * ama) * coeff[7] + (pw-pw_ref) * coeff[8] + (pw-pw_ref) * (np.log(ama)) * coeff[9] From c9fefebf6cb46006a59db018d7f50100b3f984f7 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:05:30 +0200 Subject: [PATCH 006/103] Update atmosphere.py --- pvlib/atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index f221c584b8..f3be5230c9 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -687,8 +687,8 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): def AM_AOD_PW_spectral_correction(airmass_absolute,aod500,pw, -module_type=None,coefficients=None,min_aod500=0.05, -max_aod500=0.6,min_pw=0.25,max_pw=4): + module_type=None,coefficients=None,min_aod500=0.05, + max_aod500=0.6,min_pw=0.25,max_pw=4): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) From 125bc1635fc0bb91dcc8f82425b61ac2d146b60c Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:12:59 +0200 Subject: [PATCH 007/103] Update atmosphere.py --- pvlib/atmosphere.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index f3be5230c9..db9ca52ace 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -685,10 +685,10 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): return - np.log(aod1 / aod2) / np.log(lambda1 / lambda2) - -def AM_AOD_PW_spectral_correction(airmass_absolute,aod500,pw, - module_type=None,coefficients=None,min_aod500=0.05, - max_aod500=0.6,min_pw=0.25,max_pw=4): + +def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, + module_type=None,coefficients=None, + min_aod500=0.05, max_aod500=0.6, min_pw=0.25, max_pw=4): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) From 6a431565c8a7e5a08415d3e5ec2a45c91f364744 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:27:34 +0200 Subject: [PATCH 008/103] Update atmosphere.py --- pvlib/atmosphere.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index db9ca52ace..d2a756673c 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -688,8 +688,9 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, module_type=None,coefficients=None, - min_aod500=0.05, max_aod500=0.6, min_pw=0.25, max_pw=4): - + min_aod500=0.05, max_aod500=0.6, + min_pw=0.25, max_pw=4): + r""" Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), aerosol optical depth (AOD) at 500 nm and From 5b890ab4a035ca8793156f88a95b8a0393a02cea Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:29:01 +0200 Subject: [PATCH 009/103] Update atmosphere.py --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index d2a756673c..8443146286 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -687,7 +687,7 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, - module_type=None,coefficients=None, + module_type=None, coefficients=None, min_aod500=0.05, max_aod500=0.6, min_pw=0.25, max_pw=4): From c602a32f56b28b0ee27c0dcfe381fbcc47a2b318 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:32:55 +0200 Subject: [PATCH 010/103] Update atmosphere.py --- pvlib/atmosphere.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 8443146286..e10fee3877 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -685,11 +685,10 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): return - np.log(aod1 / aod2) / np.log(lambda1 / lambda2) - def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, - module_type=None, coefficients=None, - min_aod500=0.05, max_aod500=0.6, - min_pw=0.25, max_pw=4): + module_type=None, coefficients=None, + min_aod500=0.05, max_aod500=0.6, + min_pw=0.25, max_pw=4): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) From 97d0e65a5f05dd8d804f14f58d323ddb521d6e3f Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:36:39 +0200 Subject: [PATCH 011/103] Update atmosphere.py --- pvlib/atmosphere.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index e10fee3877..9c3a584713 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -685,11 +685,10 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): return - np.log(aod1 / aod2) / np.log(lambda1 / lambda2) -def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, - module_type=None, coefficients=None, - min_aod500=0.05, max_aod500=0.6, - min_pw=0.25, max_pw=4): - +def AM_AOD_PW_spectral_correction (airmass_absolute, aod500, pw, + module_type=None, coefficients=None, + min_aod500=0.05, max_aod500=0.6, + min_pw=0.25, max_pw=4): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), aerosol optical depth (AOD) at 500 nm and From 0e2d8326dbb587899a55a5995294e5b8d03df934 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:38:03 +0200 Subject: [PATCH 012/103] Update atmosphere.py --- pvlib/atmosphere.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 9c3a584713..12348269a2 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -685,10 +685,9 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): return - np.log(aod1 / aod2) / np.log(lambda1 / lambda2) -def AM_AOD_PW_spectral_correction (airmass_absolute, aod500, pw, - module_type=None, coefficients=None, - min_aod500=0.05, max_aod500=0.6, - min_pw=0.25, max_pw=4): +def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, + module_type=None, coefficients=None, min_aod500=0.05, + max_aod500=0.6, min_pw=0.25, max_pw=4): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), aerosol optical depth (AOD) at 500 nm and From 8a473ba25f5ba5ad4df13e6f495cb453d962b390 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:39:38 +0200 Subject: [PATCH 013/103] Update atmosphere.py --- pvlib/atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 12348269a2..d8537b2f07 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -686,8 +686,8 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, - module_type=None, coefficients=None, min_aod500=0.05, - max_aod500=0.6, min_pw=0.25, max_pw=4): +module_type=None, coefficients=None, min_aod500=0.05, +max_aod500=0.6, min_pw=0.25, max_pw=4): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), aerosol optical depth (AOD) at 500 nm and From 397c3e8e25d5460c98afa56fa45c18fa1bb56cce Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:42:16 +0200 Subject: [PATCH 014/103] Update atmosphere.py --- pvlib/atmosphere.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index d8537b2f07..527813949b 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -686,8 +686,9 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, -module_type=None, coefficients=None, min_aod500=0.05, -max_aod500=0.6, min_pw=0.25, max_pw=4): + module_type=None, coefficients=None, + min_aod500=0.05, max_aod500=0.6, + min_pw=0.25, max_pw=4): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), aerosol optical depth (AOD) at 500 nm and From 7382e3619757a97bbd2db6e2e9f1367d8ba3b84e Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:43:28 +0200 Subject: [PATCH 015/103] Update atmosphere.py --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 527813949b..adb4d4223f 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -687,7 +687,7 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, module_type=None, coefficients=None, - min_aod500=0.05, max_aod500=0.6, + min_aod500=0.05, max_aod500=0.6, min_pw=0.25, max_pw=4): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) From ed2d4f6584b98278fc7db7c75161f3334db0768e Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:51:59 +0200 Subject: [PATCH 016/103] Update atmosphere.py --- pvlib/atmosphere.py | 52 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index adb4d4223f..589b0d83f4 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -691,7 +691,7 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, min_pw=0.25, max_pw=4): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) - airmass (AM), aerosol optical depth (AOD) at 500 nm and + airmass (AM), aerosol optical depth (AOD) at 500 nm and precipitable water (PW). Estimates a spectral mismatch modifier :math:`M` representing @@ -712,38 +712,38 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, * All other parameters fixed at G173 standard Elevation (deg), AOD and PW data were recorded in the city of Jaén, - Spain for one year synchronously with both, broadband and + Spain for one year synchronously with both, broadband and spectroradiometric measurements of 30º tilted global irradiance south-facing logged in 5-min intervals. AM was estimated through elevation data. - - Finally, the spectral mismatch factor was calculated for each - of the PV technologies and a multivariable regression adjustment + + Finally, the spectral mismatch factor was calculated for each + of the PV technologies and a multivariable regression adjustment as a function of AM, AOD and PW was performed according to [2] and [3]. - As such, the polynomial adjustment coefficients included in [3] + As such, the polynomial adjustment coefficients included in [3] were obtained. Parameters ---------- airmass_absolute : array-like - absolute (pressure-adjusted) airmass. [unitless] - + absolute (pressure-adjusted) airmass. [unitless] + aod500 : array-like - atmospheric aerosol optical depth at 500 nm. [unitless] - + atmospheric aerosol optical depth at 500 nm. [unitless] + pw : array-like atmospheric precipitable water. [cm] min_aod500 : float, default 0.05 - minimum atmospheric aerosol optical depth at 500 nm. Any aod500 value - lower than min_aod500 is set to min_aod500 to avoid model - divergence. [unitless] - + minimum atmospheric aerosol optical depth at 500 nm. Any aod500 value + lower than min_aod500 is set to min_aod500 to avoid model + divergence. [unitless] + max_aod500 : float, default 0.6 - maximum atmospheric aerosol optical depth at 500 nm. Any aod500 value - higher than max_aod500 is set to NaN to avoid model divergence. [unitless] - + maximum atmospheric aerosol optical depth at 500 nm. Any aod500 value + higher than max_aod500 is set to NaN to avoid model divergence. [unitless] + min_pw : float, default 0.25 minimum atmospheric precipitable water. Any pw value lower than min_pw is set to min_pw to avoid model divergence. [cm] @@ -751,7 +751,7 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, max_pw : float, default 4 maximum atmospheric precipitable water. Any pw value higher than max_pw is set to NaN to avoid model divergence. [cm] - + module_type : None or string, default None a string specifying a cell type. Values of 'cdte', 'monosi', 'cigs', 'multisi','asi' and 'pervovskite'. If provided, @@ -768,7 +768,7 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, coefficients : None or array-like, default None the coefficients employed have been obtained with experimental data in the city of Jaén, Spain. It is pending to verify if such - coefficients vary in places with extreme climates where AOD and + coefficients vary in places with extreme climates where AOD and pw values are frequently high. Returns @@ -781,15 +781,15 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, References ---------- - .. [1] Gueymard, Christian. SMARTS2: a simple model of the + .. [1] Gueymard, Christian. SMARTS2: a simple model of the atmospheric radiative transfer of sunshine: algorithms - and performance assessment. Cocoa, FL: + and performance assessment. Cocoa, FL: Florida Solar Energy Center, 1995. - .. [2] Theristis, M., Fernández, E., Almonacid, F., and - Pérez-Higueras, Pedro. "Spectral Corrections Based + .. [2] Theristis, M., Fernández, E., Almonacid, F., and + Pérez-Higueras, Pedro. "Spectral Corrections Based on Air Mass, Aerosol Optical Depth and Precipitable - Water for CPV Performance Modeling. - "IEEE Journal of Photovoltaics 2016, 6(6), 1598-1604. + Water for CPV Performance Modeling. + "IEEE Journal of Photovoltaics 2016, 6(6), 1598-1604. https://doi.org/10.1109/jphotov.2016.2606702 .. [3] Caballero, J.A., Fernández, E., Theristis, M., Almonacid, F., and Nofuentes, G. "Spectral Corrections Based on @@ -797,7 +797,7 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, for PV Performance Modeling. " IEEE Journal of Photovoltaics 2018, 8(2), 552-558. https://doi.org/10.1109/jphotov.2017.2787019 - + """ # --- Screen Input Data --- From 394c4bc77d76ad9d969cfc89b58515489c1691f2 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:56:05 +0200 Subject: [PATCH 017/103] Update atmosphere.py --- pvlib/atmosphere.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 589b0d83f4..8049047a85 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -734,7 +734,7 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, pw : array-like atmospheric precipitable water. [cm] - + min_aod500 : float, default 0.05 minimum atmospheric aerosol optical depth at 500 nm. Any aod500 value lower than min_aod500 is set to min_aod500 to avoid model @@ -742,7 +742,8 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, max_aod500 : float, default 0.6 maximum atmospheric aerosol optical depth at 500 nm. Any aod500 value - higher than max_aod500 is set to NaN to avoid model divergence. [unitless] + higher than max_aod500 is set to NaN to avoid model + divergence. [unitless] min_pw : float, default 0.25 minimum atmospheric precipitable water. Any pw value lower than min_pw @@ -848,9 +849,6 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, pw[pw > max_pw] = np.nan warn('Exceptionally high pw values replaced by np.nan: ' 'check input data.') - - - # Experimental coefficients From e89248f0e8a5fa7ae87a567cf5b775cd0d0844b0 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 12:59:30 +0200 Subject: [PATCH 018/103] Update atmosphere.py --- pvlib/atmosphere.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 8049047a85..ad9bf20385 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -850,27 +850,21 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, warn('Exceptionally high pw values replaced by np.nan: ' 'check input data.') - # Experimental coefficients + # Experimental coefficients _coefficients = {} _coefficients['cdte'] = ( - 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, - -0.0046, -0.0182, 0, 0.0095, 0.0068, 0 , 1) + 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0 , 1) _coefficients['monosi'] = ( - 0.9706, 0.0377, -0.0123, 0.0025, -0.0002, 0.0159, - -0.0165, 0, -0.0016, -0.0027, 1, 0) + 0.9706, 0.0377, -0.0123, 0.0025, -0.0002, 0.0159, -0.0165, 0, -0.0016, -0.0027, 1, 0) _coefficients['multisi'] = ( - 0.9836, 0.0254, -0.0085, 0.0016, -0.0001, 0.0094, - -0.0132, 0, -0.0002, -0.0011, 1 , 0) + 0.9836, 0.0254, -0.0085, 0.0016, -0.0001, 0.0094, -0.0132, 0, -0.0002, -0.0011, 1 , 0) _coefficients['cigs'] = ( - 0.9801, 0.0283, -0.0092, 0.0019, -0.0001, 0.0117, - -0.0126, 0, -0.0011, -0.0019, 1 , 0) + 0.9801, 0.0283, -0.0092, 0.0019, -0.0001, 0.0117, -0.0126, 0, -0.0011, -0.0019, 1 , 0) _coefficients['asi'] = ( - 1.1060, -0.0848, 0.0302, -0.0076, 0.0006, -0.12838, - 0.0986, -0.0254, 0.0156, 0.0146, 1 , 0) + 1.1060, -0.0848, 0.0302, -0.0076, 0.0006, -0.12838, 0.0986, -0.0254, 0.0156, 0.0146, 1 , 0) _coefficients['perovskite'] = ( - 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, - 0.0583, -0.0159, 0.01251, 0.0109, 1 , 0) + 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, 0.0583, -0.0159, 0.01251, 0.0109, 1 , 0) if module_type is not None and coefficients is None: coefficients = _coefficients[module_type.lower()] From 25b43dfdc3af361334566a9fd2716870cf1c0366 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 13:01:03 +0200 Subject: [PATCH 019/103] Update atmosphere.py --- pvlib/atmosphere.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index ad9bf20385..9b99128a87 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -854,17 +854,17 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, _coefficients = {} _coefficients['cdte'] = ( - 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0 , 1) + 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0, 1) _coefficients['monosi'] = ( 0.9706, 0.0377, -0.0123, 0.0025, -0.0002, 0.0159, -0.0165, 0, -0.0016, -0.0027, 1, 0) _coefficients['multisi'] = ( - 0.9836, 0.0254, -0.0085, 0.0016, -0.0001, 0.0094, -0.0132, 0, -0.0002, -0.0011, 1 , 0) + 0.9836, 0.0254, -0.0085, 0.0016, -0.0001, 0.0094, -0.0132, 0, -0.0002, -0.0011, 1, 0) _coefficients['cigs'] = ( - 0.9801, 0.0283, -0.0092, 0.0019, -0.0001, 0.0117, -0.0126, 0, -0.0011, -0.0019, 1 , 0) + 0.9801, 0.0283, -0.0092, 0.0019, -0.0001, 0.0117, -0.0126, 0, -0.0011, -0.0019, 1, 0) _coefficients['asi'] = ( - 1.1060, -0.0848, 0.0302, -0.0076, 0.0006, -0.12838, 0.0986, -0.0254, 0.0156, 0.0146, 1 , 0) + 1.1060, -0.0848, 0.0302, -0.0076, 0.0006, -0.12838, 0.0986, -0.0254, 0.0156, 0.0146, 1, 0) _coefficients['perovskite'] = ( - 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, 0.0583, -0.0159, 0.01251, 0.0109, 1 , 0) + 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, 0.0583, -0.0159, 0.01251, 0.0109, 1, 0) if module_type is not None and coefficients is None: coefficients = _coefficients[module_type.lower()] From d9f466e9ba470fccdd86a91db5ff5f54c3ebeefb Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 13:12:58 +0200 Subject: [PATCH 020/103] Update atmosphere.py --- pvlib/atmosphere.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 9b99128a87..052e237010 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -854,17 +854,23 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, _coefficients = {} _coefficients['cdte'] = ( - 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0, 1) + 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, + -0.0182, 0, 0.0095, 0.0068, 0, 1) _coefficients['monosi'] = ( - 0.9706, 0.0377, -0.0123, 0.0025, -0.0002, 0.0159, -0.0165, 0, -0.0016, -0.0027, 1, 0) + 0.9706, 0.0377, -0.0123, 0.0025, -0.0002, 0.0159, + -0.0165, 0, -0.0016, -0.0027, 1, 0) _coefficients['multisi'] = ( - 0.9836, 0.0254, -0.0085, 0.0016, -0.0001, 0.0094, -0.0132, 0, -0.0002, -0.0011, 1, 0) + 0.9836, 0.0254, -0.0085, 0.0016, -0.0001, 0.0094, + -0.0132, 0, -0.0002, -0.0011, 1, 0) _coefficients['cigs'] = ( - 0.9801, 0.0283, -0.0092, 0.0019, -0.0001, 0.0117, -0.0126, 0, -0.0011, -0.0019, 1, 0) + 0.9801, 0.0283, -0.0092, 0.0019, -0.0001, 0.0117, + -0.0126, 0, -0.0011, -0.0019, 1, 0) _coefficients['asi'] = ( - 1.1060, -0.0848, 0.0302, -0.0076, 0.0006, -0.12838, 0.0986, -0.0254, 0.0156, 0.0146, 1, 0) + 1.1060, -0.0848, 0.0302, -0.0076, 0.0006, -0.12838, + 0.0986, -0.0254, 0.0156, 0.0146, 1, 0) _coefficients['perovskite'] = ( - 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, 0.0583, -0.0159, 0.01251, 0.0109, 1, 0) + 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, + 0.0583, -0.0159, 0.01251, 0.0109, 1, 0) if module_type is not None and coefficients is None: coefficients = _coefficients[module_type.lower()] From cdc64fc0d4cbdeac68983eb768464ded787dac64 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 13:15:21 +0200 Subject: [PATCH 021/103] Update atmosphere.py --- pvlib/atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 052e237010..c5f8e7df53 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -886,8 +886,8 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, # Evaluate Spectral Shift coeff = coefficients ama = airmass_absolute - aod500_ref=0.84; - pw_ref=1.42; + aod500_ref= 0.84 + pw_ref= 1.42 modifier = ( coeff[0] + (ama) *coeff[1] + (ama*ama) * coeff[2] From 422f49f0f133b201e4419029c6bfc0bf61fa7a33 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 13:17:24 +0200 Subject: [PATCH 022/103] Update atmosphere.py --- pvlib/atmosphere.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index c5f8e7df53..e932888e24 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -886,9 +886,9 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, # Evaluate Spectral Shift coeff = coefficients ama = airmass_absolute - aod500_ref= 0.84 - pw_ref= 1.42 - + aod500_ref=0.84 + pw_ref=1.42 + modifier = ( coeff[0] + (ama) *coeff[1] + (ama*ama) * coeff[2] +(ama*ama*ama) * coeff[3] + (ama*ama*ama*ama) * coeff[4] From 48474a79446d638872f49fdda309e057904f2012 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 13:18:44 +0200 Subject: [PATCH 023/103] Update atmosphere.py --- pvlib/atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index e932888e24..267638a0cb 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -886,8 +886,8 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, # Evaluate Spectral Shift coeff = coefficients ama = airmass_absolute - aod500_ref=0.84 - pw_ref=1.42 + aod500_ref = 0.84 + pw_ref = 1.42 modifier = ( coeff[0] + (ama) *coeff[1] + (ama*ama) * coeff[2] From 6e9b9d84635669d18b590476aaa633472e14f3aa Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 13:20:40 +0200 Subject: [PATCH 024/103] Update atmosphere.py --- pvlib/atmosphere.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 267638a0cb..f638c63f8b 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -890,13 +890,13 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, pw_ref = 1.42 modifier = ( - coeff[0] + (ama) *coeff[1] + (ama*ama) * coeff[2] - +(ama*ama*ama) * coeff[3] + (ama*ama*ama*ama) * coeff[4] - + (aod500-aod500_ref) * coeff[5] + - ((aod500-aod500_ref) * (ama) * coeff[6]) * coeff[10] - + ((aod500-aod500_ref) * (np.log(ama)) * coeff[6]) * coeff[11] - +(aod500-aod500_ref) + (ama * ama) * coeff[7] + - (pw-pw_ref) * coeff[8] + (pw-pw_ref) * (np.log(ama)) * coeff[9] + coeff[0] + (ama) *coeff[1] + (ama * ama) * coeff[2] + +(ama * ama * ama) * coeff[3] + (ama * ama * ama * ama) * coeff[4] + + (aod500 - aod500_ref) * coeff[5] + + ((aod500 - aod500_ref) * (ama) * coeff[6]) * coeff[10] + + ((aod500 - aod500_ref) * (np.log(ama)) * coeff[6]) * coeff[11] + +(aod500 - aod500_ref) + (ama * ama) * coeff[7] + + (pw - pw_ref) * coeff[8] + (pw - pw_ref) * (np.log(ama)) * coeff[9] ) return modifier From 43a188c9265fe3ed9ac508cffb5d4dd16fd7a7e1 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 13:22:11 +0200 Subject: [PATCH 025/103] Update atmosphere.py --- pvlib/atmosphere.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index f638c63f8b..f3ba93853a 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -890,13 +890,13 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, pw_ref = 1.42 modifier = ( - coeff[0] + (ama) *coeff[1] + (ama * ama) * coeff[2] - +(ama * ama * ama) * coeff[3] + (ama * ama * ama * ama) * coeff[4] - + (aod500 - aod500_ref) * coeff[5] + - ((aod500 - aod500_ref) * (ama) * coeff[6]) * coeff[10] + coeff[0] + (ama) * coeff[1] + (ama * ama) * coeff[2] + + (ama * ama * ama) * coeff[3] + (ama * ama * ama * ama) * coeff[4] + + (aod500 - aod500_ref) * coeff[5] + + ((aod500 - aod500_ref) * (ama) * coeff[6]) * coeff[10] + ((aod500 - aod500_ref) * (np.log(ama)) * coeff[6]) * coeff[11] - +(aod500 - aod500_ref) + (ama * ama) * coeff[7] + - (pw - pw_ref) * coeff[8] + (pw - pw_ref) * (np.log(ama)) * coeff[9] + + (aod500 - aod500_ref) + (ama * ama) * coeff[7] + + (pw - pw_ref) * coeff[8] + (pw - pw_ref) * (np.log(ama)) * coeff[9] ) return modifier From 710cdd3e09b8acf5496aef0aea6c8c7af3545d93 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 13:23:55 +0200 Subject: [PATCH 026/103] Update atmosphere.py --- pvlib/atmosphere.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index f3ba93853a..466cc9b876 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -891,12 +891,12 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, modifier = ( coeff[0] + (ama) * coeff[1] + (ama * ama) * coeff[2] - + (ama * ama * ama) * coeff[3] + (ama * ama * ama * ama) * coeff[4] + + (ama * ama * ama) * coeff[3] + (ama * ama * ama * ama) * coeff[4] + (aod500 - aod500_ref) * coeff[5] + ((aod500 - aod500_ref) * (ama) * coeff[6]) * coeff[10] + ((aod500 - aod500_ref) * (np.log(ama)) * coeff[6]) * coeff[11] + (aod500 - aod500_ref) + (ama * ama) * coeff[7] - + (pw - pw_ref) * coeff[8] + (pw - pw_ref) * (np.log(ama)) * coeff[9] - ) + + (pw - pw_ref) * coeff[8] + (pw - pw_ref) * (np.log(ama)) * coeff[9] + ) return modifier From 46519a8456125b4d1124b8c84d73aadaa5782dab Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sat, 25 Sep 2021 13:25:16 +0200 Subject: [PATCH 027/103] Update atmosphere.py --- pvlib/atmosphere.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 466cc9b876..0ac5478427 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -896,7 +896,6 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, + ((aod500 - aod500_ref) * (ama) * coeff[6]) * coeff[10] + ((aod500 - aod500_ref) * (np.log(ama)) * coeff[6]) * coeff[11] + (aod500 - aod500_ref) + (ama * ama) * coeff[7] - + (pw - pw_ref) * coeff[8] + (pw - pw_ref) * (np.log(ama)) * coeff[9] - ) + + (pw - pw_ref) * coeff[8] + (pw - pw_ref) * (np.log(ama)) * coeff[9]) return modifier From 7bc182f045370d24c9adc3aa681eaba64430ec78 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sun, 3 Oct 2021 10:49:15 +0200 Subject: [PATCH 028/103] Update pvlib/atmosphere.py Co-authored-by: Kevin Anderson <57452607+kanderso-nrel@users.noreply.github.com> --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 0ac5478427..e6e5d9eeda 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -763,7 +763,7 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, * 'multisi', - anonymous mc-si- module. * 'cigs' - anonymous copper indium gallium selenide module. * 'asi' - anonymous amorphous silicon module. - * 'perovskite' - anonymous pervoskite module. + * 'perovskite' - anonymous perovskite module. coefficients : None or array-like, default None From 2c36c009a9836b884e18944de7a6e2c85511ddb1 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sun, 3 Oct 2021 11:41:14 +0200 Subject: [PATCH 029/103] relocation of parameter descriptions according to the order of input parameters --- pvlib/atmosphere.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 0ac5478427..75583e6965 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -735,6 +735,24 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, pw : array-like atmospheric precipitable water. [cm] + module_type : None or string, default None + a string specifying a cell type. Values of 'cdte', 'monosi', 'cigs', + 'multisi','asi' and 'pervovskite'. If provided, + module_type selects default coefficients for the following modules: + + * 'cdte' - anonymous CdTe module. + * 'monosi', - anonymous sc-si module. + * 'multisi', - anonymous mc-si- module. + * 'cigs' - anonymous copper indium gallium selenide module. + * 'asi' - anonymous amorphous silicon module. + * 'perovskite' - anonymous pervoskite module. + + coefficients : None or array-like, default None + the coefficients employed have been obtained with experimental + data in the city of Jaén, Spain. It is pending to verify if such + coefficients vary in places with extreme climates where AOD and + pw values are frequently high. + min_aod500 : float, default 0.05 minimum atmospheric aerosol optical depth at 500 nm. Any aod500 value lower than min_aod500 is set to min_aod500 to avoid model @@ -753,24 +771,6 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, maximum atmospheric precipitable water. Any pw value higher than max_pw is set to NaN to avoid model divergence. [cm] - module_type : None or string, default None - a string specifying a cell type. Values of 'cdte', 'monosi', 'cigs', - 'multisi','asi' and 'pervovskite'. If provided, - module_type selects default coefficients for the following modules: - - * 'cdte' - anonymous CdTe module. - * 'monosi', - anonymous sc-si module. - * 'multisi', - anonymous mc-si- module. - * 'cigs' - anonymous copper indium gallium selenide module. - * 'asi' - anonymous amorphous silicon module. - * 'perovskite' - anonymous pervoskite module. - - - coefficients : None or array-like, default None - the coefficients employed have been obtained with experimental - data in the city of Jaén, Spain. It is pending to verify if such - coefficients vary in places with extreme climates where AOD and - pw values are frequently high. Returns ------- From 094d73798ce7abd976be79626d3cb592aa9ae633 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sun, 3 Oct 2021 13:10:00 +0200 Subject: [PATCH 030/103] Update api.rst Adding atmosphere.AM_AOD_PW_spectral correction as requested in https://github.com/pvlib/pvlib-python/pull/1296 --- docs/sphinx/source/api.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sphinx/source/api.rst b/docs/sphinx/source/api.rst index 6d08e742b3..b8af294694 100644 --- a/docs/sphinx/source/api.rst +++ b/docs/sphinx/source/api.rst @@ -126,6 +126,7 @@ Airmass and atmospheric models atmosphere.kasten96_lt atmosphere.angstrom_aod_at_lambda atmosphere.angstrom_alpha + atmosphere.AM_AOD_PW_spectral_correction Irradiance From f79b8abf8ed540be9fdfd8225d5c5af2b29704aa Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Sun, 31 Oct 2021 16:27:07 -0600 Subject: [PATCH 031/103] remove input screening --- pvlib/atmosphere.py | 72 +-------------------------------------------- 1 file changed, 1 insertion(+), 71 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 75583e6965..9e02c9f1b6 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -686,9 +686,7 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, - module_type=None, coefficients=None, - min_aod500=0.05, max_aod500=0.6, - min_pw=0.25, max_pw=4): + module_type=None, coefficients=None): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), aerosol optical depth (AOD) at 500 nm and @@ -753,25 +751,6 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, coefficients vary in places with extreme climates where AOD and pw values are frequently high. - min_aod500 : float, default 0.05 - minimum atmospheric aerosol optical depth at 500 nm. Any aod500 value - lower than min_aod500 is set to min_aod500 to avoid model - divergence. [unitless] - - max_aod500 : float, default 0.6 - maximum atmospheric aerosol optical depth at 500 nm. Any aod500 value - higher than max_aod500 is set to NaN to avoid model - divergence. [unitless] - - min_pw : float, default 0.25 - minimum atmospheric precipitable water. Any pw value lower than min_pw - is set to min_pw to avoid model divergence. [cm] - - max_pw : float, default 4 - maximum atmospheric precipitable water. Any pw value higher than max_pw - is set to NaN to avoid model divergence. [cm] - - Returns ------- modifier: array-like @@ -801,55 +780,6 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, """ - # --- Screen Input Data --- - - # *** ama *** - # Replace Extremely High ama with ama 10 to prevent model divergence - # ama > 10 will only occur very close to sunset - if np.max(airmass_absolute) > 10: - airmass_absolute = np.minimum(airmass_absolute, 10) - - # Warn user about ama data that is exceptionally low - - if np.min(airmass_absolute) < 0.58: - warn('Exceptionally low air mass: ' + - 'model not intended for extra-terrestrial use') - # pvl_absoluteairmass(1,pvl_alt2pres(4340)) = 0.58 Elevation of - # Mina Pirquita, Argentian = 4340 m. Highest elevation city with - # population over 50,000. - - # *** aod500 *** - # Replace aod500 Values below 0.05 with 0.05 to prevent model from - # diverging" - aod500 = np.atleast_1d(aod500) - aod500 = aod500.astype('float64') - if np.min(aod500) < min_aod500: - aod500 = np.maximum(aod500, min_aod500) - warn(f'Exceptionally low aod values replaced with {min_aod500} to' - 'prevent model divergence') - - # Warn user about aod500 data that is exceptionally high - if np.max(aod500) > max_aod500: - aod500[aod500 > max_aod500] = np.nan - warn('Exceptionally high aod values replaced by np.nan: ' - 'check input data.') - - # *** pw *** - # Replace pw Values below 0.25 cm with 0.25 cm to prevent model from - # diverging" - pw = np.atleast_1d(pw) - pw = pw.astype('float64') - if np.min(pw) < min_pw: - pw = np.maximum(pw, min_pw) - warn(f'Exceptionally low pw values replaced with {min_pw} cm to ' - 'prevent model divergence') - - # Warn user about pw data that is exceptionally high - if np.max(pw) > max_pw: - pw[pw > max_pw] = np.nan - warn('Exceptionally high pw values replaced by np.nan: ' - 'check input data.') - # Experimental coefficients _coefficients = {} From 30a62843e5e6db57d642455a00a81cc77501284a Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Sun, 31 Oct 2021 16:29:12 -0600 Subject: [PATCH 032/103] move reference values to be optional parameters --- pvlib/atmosphere.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 9e02c9f1b6..a5069a85d9 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -686,7 +686,8 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, - module_type=None, coefficients=None): + module_type=None, coefficients=None, + aod500_ref=0.84, pw_ref=1.42): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), aerosol optical depth (AOD) at 500 nm and @@ -745,12 +746,18 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, * 'asi' - anonymous amorphous silicon module. * 'perovskite' - anonymous pervoskite module. - coefficients : None or array-like, default None + coefficients : None or array-like, optional the coefficients employed have been obtained with experimental data in the city of Jaén, Spain. It is pending to verify if such coefficients vary in places with extreme climates where AOD and pw values are frequently high. + aod500_ref : numeric, default 0.84 + TODO: description + + pw_ref : numeric, default 1.42 + TODO: description + Returns ------- modifier: array-like @@ -816,8 +823,6 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, # Evaluate Spectral Shift coeff = coefficients ama = airmass_absolute - aod500_ref = 0.84 - pw_ref = 1.42 modifier = ( coeff[0] + (ama) * coeff[1] + (ama * ama) * coeff[2] From 38dd836bd16a397250836718dd38339307095e01 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Sun, 31 Oct 2021 17:27:16 -0600 Subject: [PATCH 033/103] fix implementation issues --- pvlib/atmosphere.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index a5069a85d9..154969c3e9 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -803,7 +803,7 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, 0.9801, 0.0283, -0.0092, 0.0019, -0.0001, 0.0117, -0.0126, 0, -0.0011, -0.0019, 1, 0) _coefficients['asi'] = ( - 1.1060, -0.0848, 0.0302, -0.0076, 0.0006, -0.12838, + 1.1060, -0.0848, 0.0302, -0.0076, 0.0006, -0.1283, 0.0986, -0.0254, 0.0156, 0.0146, 1, 0) _coefficients['perovskite'] = ( 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, @@ -823,14 +823,13 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, # Evaluate Spectral Shift coeff = coefficients ama = airmass_absolute - modifier = ( coeff[0] + (ama) * coeff[1] + (ama * ama) * coeff[2] + (ama * ama * ama) * coeff[3] + (ama * ama * ama * ama) * coeff[4] + (aod500 - aod500_ref) * coeff[5] + ((aod500 - aod500_ref) * (ama) * coeff[6]) * coeff[10] + ((aod500 - aod500_ref) * (np.log(ama)) * coeff[6]) * coeff[11] - + (aod500 - aod500_ref) + (ama * ama) * coeff[7] + + (aod500 - aod500_ref) * (ama * ama) * coeff[7] + (pw - pw_ref) * coeff[8] + (pw - pw_ref) * (np.log(ama)) * coeff[9]) return modifier From 7e0d7dfb8f41a4e5d00a78bcc473d88ff108793a Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Sun, 31 Oct 2021 17:29:19 -0600 Subject: [PATCH 034/103] first cut at tests using file from Jacc0027 --- pvlib/tests/test_atmosphere.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 69bb3215dc..39db50e0bf 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -187,3 +187,36 @@ def test_bird_hulstrom80_aod_bb(): aod380, aod500 = 0.22072480948195175, 0.1614279181106312 bird_hulstrom = atmosphere.bird_hulstrom80_aod_bb(aod380, aod500) assert np.isclose(0.11738229553812768, bird_hulstrom) + + +@pytest.mark.parametrize("module_type,expected", [ + ('asi', np.array([0.9124, 0.9908, 0.9723, 1.0276, 1.0808, 0.9554])), + ('perovskite', np.array([0.9434, 0.994, 0.988, 1.0191, 1.0612, 0.975])), + ('cdte', np.array([0.9832, 1.0005, 1.0073, 1.0122, 1.0431, 0.9987])), + ('multisi', np.array([0.9912, 0.9981, 1.0208, 1.0083, 1.006, 1.0196])), + ('monosi', np.array([0.9940, 0.9989, 1.0269, 1.0076, 1.0001, 1.0268])), + ('cigs', np.array([1.0018, 1.0012, 1.0274, 1.0083, 1.003, 1.0272])), +]) +def test_AM_AOD_PW_spectral_correction(module_type, expected): + ams = np.array([3.0, 1.5, 3.0, 1.5, 1.5, 3.0]) + aods = np.array([1.0, 1.0, 0.02, 0.02, 0.08, 0.08]) + pws = np.array([1.42, 1.42, 1.42, 1.42, 4.0, 1.0]) + out = atmosphere.AM_AOD_PW_spectral_correction(ams, aods, pws, + module_type=module_type, + aod500_ref=0.1, pw_ref=1.4) + assert np.allclose(expected, out, atol=1e-3) + + +def test_AM_AOD_PW_spectral_correction_supplied(): + # use the cdte coeffs + coeffs = ( + 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, + -0.0182, 0, 0.0095, 0.0068, 0, 1) + out = atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, coefficients=coeffs) + expected = 1.005674 + assert_allclose(out, expected, atol=1e-3) + + +def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): + with pytest.raises(TypeError): + atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1) From 38fea4d362ecd28c6844d24d49be71e2b4188eba Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Mon, 1 Nov 2021 11:24:36 +0100 Subject: [PATCH 035/103] CI correction. Line #215 --- pvlib/tests/test_atmosphere.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 39db50e0bf..3850609595 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -212,7 +212,8 @@ def test_AM_AOD_PW_spectral_correction_supplied(): coeffs = ( 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0, 1) - out = atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, coefficients=coeffs) + out = atmosphere.AM_AOD_PW_spectral_correction(1, + 1, 1, coefficients=coeffs) expected = 1.005674 assert_allclose(out, expected, atol=1e-3) From 92bfc55ea8d82bee6e7b976675df9d8b55e30c2c Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Mon, 1 Nov 2021 11:31:55 +0100 Subject: [PATCH 036/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 3850609595..7f73d68997 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -213,7 +213,7 @@ def test_AM_AOD_PW_spectral_correction_supplied(): 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0, 1) out = atmosphere.AM_AOD_PW_spectral_correction(1, - 1, 1, coefficients=coeffs) + 1, 1, coefficients=coeffs) expected = 1.005674 assert_allclose(out, expected, atol=1e-3) From 5463533bf535cbbccda7094b84a1aa4382ebc9b7 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Mon, 1 Nov 2021 13:08:38 +0100 Subject: [PATCH 037/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 7f73d68997..bbedba4ce3 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -213,7 +213,7 @@ def test_AM_AOD_PW_spectral_correction_supplied(): 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0, 1) out = atmosphere.AM_AOD_PW_spectral_correction(1, - 1, 1, coefficients=coeffs) + 1, 1, coefficients=coeffs) expected = 1.005674 assert_allclose(out, expected, atol=1e-3) From c6cd8098ad602241c37e6487a9757bf865685782 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Mon, 1 Nov 2021 13:09:34 +0100 Subject: [PATCH 038/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index bbedba4ce3..7f73d68997 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -213,7 +213,7 @@ def test_AM_AOD_PW_spectral_correction_supplied(): 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0, 1) out = atmosphere.AM_AOD_PW_spectral_correction(1, - 1, 1, coefficients=coeffs) + 1, 1, coefficients=coeffs) expected = 1.005674 assert_allclose(out, expected, atol=1e-3) From 04339ad47a29a88ddeb8043216c3fc6b4c4cfc9b Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 2 Nov 2021 21:12:44 +0100 Subject: [PATCH 039/103] Update atmosphere.py --- pvlib/atmosphere.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 154969c3e9..aa8f11c6f2 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -814,11 +814,11 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, elif module_type is None and coefficients is not None: pass elif module_type is None and coefficients is None: - raise TypeError('No valid input provided, both module_type' - + 'and coefficients are None') + raise TypeError('No valid input provided, both module_type and ' + + 'coefficients are None') else: - raise TypeError('Cannot resolve input, must supply only one' - + 'of module_type and coefficients') + raise TypeError('Cannot resolve input, must supply only one of ' + + 'module_type and coefficients') # Evaluate Spectral Shift coeff = coefficients @@ -832,4 +832,4 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, + (aod500 - aod500_ref) * (ama * ama) * coeff[7] + (pw - pw_ref) * coeff[8] + (pw - pw_ref) * (np.log(ama)) * coeff[9]) - return modifier + return modifier \ No newline at end of file From c487317fc3225c4e24eaf62dcfd40ee30364c5c3 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 2 Nov 2021 21:13:40 +0100 Subject: [PATCH 040/103] Update atmosphere.py --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index aa8f11c6f2..a18b6162f5 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -832,4 +832,4 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, + (aod500 - aod500_ref) * (ama * ama) * coeff[7] + (pw - pw_ref) * coeff[8] + (pw - pw_ref) * (np.log(ama)) * coeff[9]) - return modifier \ No newline at end of file + return modifier From 0744b800717244cf61a276c4be1ae7d06a56ddc8 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 2 Nov 2021 21:38:17 +0100 Subject: [PATCH 041/103] Update atmosphere.py --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index a18b6162f5..ccca9fe21d 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -816,7 +816,7 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, elif module_type is None and coefficients is None: raise TypeError('No valid input provided, both module_type and ' + 'coefficients are None') - else: + elif module_type is not None and coefficients is not None: raise TypeError('Cannot resolve input, must supply only one of ' + 'module_type and coefficients') From 6bc7920637059e01d81e10acccefc35a51c94f96 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 2 Nov 2021 22:31:40 +0100 Subject: [PATCH 042/103] Update atmosphere.py --- pvlib/atmosphere.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index ccca9fe21d..2d0e8a8f4a 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -814,11 +814,11 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, elif module_type is None and coefficients is not None: pass elif module_type is None and coefficients is None: - raise TypeError('No valid input provided, both module_type and ' + - 'coefficients are None') - elif module_type is not None and coefficients is not None: - raise TypeError('Cannot resolve input, must supply only one of ' + - 'module_type and coefficients') + raise TypeError('No valid input provided, both module_type' + + 'and coefficients are None') + else: + raise TypeError('Cannot resolve input, must supply only one' + + 'of module_type and coefficients') # Evaluate Spectral Shift coeff = coefficients From ec20bbc2d1ec84ce511bf30b061879c0c4b04ae5 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 2 Nov 2021 23:09:01 +0100 Subject: [PATCH 043/103] Testing tests --- pvlib/atmosphere.py | 2 +- pvlib/tests/test_atmosphere.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 2d0e8a8f4a..d8d63e5b76 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -687,7 +687,7 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, module_type=None, coefficients=None, - aod500_ref=0.84, pw_ref=1.42): + aod500_ref=0.084, pw_ref=1.42): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), aerosol optical depth (AOD) at 500 nm and diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 7f73d68997..d2d727a1b1 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -220,4 +220,6 @@ def test_AM_AOD_PW_spectral_correction_supplied(): def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): with pytest.raises(TypeError): - atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1) + atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, + module_type=None,coefficients=None, + aod500_ref=0.1, pw_ref=1.4) From 9ebd10e5381374b24b3d7f3169707758f55c9377 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 2 Nov 2021 23:10:28 +0100 Subject: [PATCH 044/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index d2d727a1b1..5f24c1da23 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -221,5 +221,7 @@ def test_AM_AOD_PW_spectral_correction_supplied(): def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): with pytest.raises(TypeError): atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, - module_type=None,coefficients=None, - aod500_ref=0.1, pw_ref=1.4) + module_type=None, + coefficients=None, + aod500_ref=0.1, + pw_ref=1.4) From 43a30e51689749debf8629bf84071bb0ebb40b57 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 2 Nov 2021 23:15:56 +0100 Subject: [PATCH 045/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 5f24c1da23..c82a206455 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -221,7 +221,7 @@ def test_AM_AOD_PW_spectral_correction_supplied(): def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): with pytest.raises(TypeError): atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, - module_type=None, - coefficients=None, + module_type=not None, + coefficients=not None, aod500_ref=0.1, pw_ref=1.4) From 39c542b773883e02e1ea8cbef15ced69a923692d Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 2 Nov 2021 23:18:15 +0100 Subject: [PATCH 046/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index c82a206455..375ff6821f 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -221,7 +221,7 @@ def test_AM_AOD_PW_spectral_correction_supplied(): def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): with pytest.raises(TypeError): atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, - module_type=not None, - coefficients=not None, - aod500_ref=0.1, - pw_ref=1.4) + module_type=not None, + coefficients=not None, + aod500_ref=0.1, + pw_ref=1.4) From 516c0598f4de373b4d74679a9e00d7f4f59bc636 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 2 Nov 2021 23:19:48 +0100 Subject: [PATCH 047/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 375ff6821f..ca9936f74d 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -221,7 +221,7 @@ def test_AM_AOD_PW_spectral_correction_supplied(): def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): with pytest.raises(TypeError): atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, - module_type=not None, - coefficients=not None, - aod500_ref=0.1, - pw_ref=1.4) + module_type=not None, + coefficients=not None, + aod500_ref=0.1, + pw_ref=1.4) From acaf38dc4e7497b8192dbba9fdca59ecf1139350 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 2 Nov 2021 23:25:55 +0100 Subject: [PATCH 048/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index ca9936f74d..7f73d68997 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -220,8 +220,4 @@ def test_AM_AOD_PW_spectral_correction_supplied(): def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): with pytest.raises(TypeError): - atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, - module_type=not None, - coefficients=not None, - aod500_ref=0.1, - pw_ref=1.4) + atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1) From f937bba0738873f4ef7815cd046721baf0a40986 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 2 Nov 2021 23:29:30 +0100 Subject: [PATCH 049/103] Update atmosphere.py --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index d8d63e5b76..6af1f23081 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -687,7 +687,7 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, module_type=None, coefficients=None, - aod500_ref=0.084, pw_ref=1.42): + aod500_ref=0.1, pw_ref=1.4): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), aerosol optical depth (AOD) at 500 nm and From fd7ec4aca4ffbc698a1f18f827445cfbf2293208 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 2 Nov 2021 23:56:35 +0100 Subject: [PATCH 050/103] Test Review --- pvlib/tests/test_atmosphere.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 7f73d68997..b8ea07c1bd 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -190,12 +190,12 @@ def test_bird_hulstrom80_aod_bb(): @pytest.mark.parametrize("module_type,expected", [ - ('asi', np.array([0.9124, 0.9908, 0.9723, 1.0276, 1.0808, 0.9554])), - ('perovskite', np.array([0.9434, 0.994, 0.988, 1.0191, 1.0612, 0.975])), - ('cdte', np.array([0.9832, 1.0005, 1.0073, 1.0122, 1.0431, 0.9987])), - ('multisi', np.array([0.9912, 0.9981, 1.0208, 1.0083, 1.006, 1.0196])), - ('monosi', np.array([0.9940, 0.9989, 1.0269, 1.0076, 1.0001, 1.0268])), - ('cigs', np.array([1.0018, 1.0012, 1.0274, 1.0083, 1.003, 1.0272])), + ('asi', np.array([0.9897, 0.9707, 1.0265, 1.0798, 0.9537])), + ('perovskite', np.array([0.9932, 0.9868, 1.0183, 1.0605, 0.9738])), + ('cdte', np.array([1.0000, 1.0066, 1.0118, 1.0427, 0.9980])), + ('multisi', np.array([0.9979, 1.0203, 1.0081, 1.0058, 1.01915])), + ('monosi', np.array([0.9988, 1.0265, 1.0075, 0.9999, 1.0264])), + ('cigs', np.array([1.0012, 1.0271, 1.0082, 1.0030, 1.0268])), ]) def test_AM_AOD_PW_spectral_correction(module_type, expected): ams = np.array([3.0, 1.5, 3.0, 1.5, 1.5, 3.0]) @@ -214,7 +214,7 @@ def test_AM_AOD_PW_spectral_correction_supplied(): -0.0182, 0, 0.0095, 0.0068, 0, 1) out = atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, coefficients=coeffs) - expected = 1.005674 + expected = 1.0021964 assert_allclose(out, expected, atol=1e-3) From f08b846f182ea81d067b75ac025fe83998a3ad45 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 2 Nov 2021 23:56:40 +0100 Subject: [PATCH 051/103] Update atmosphere.py --- pvlib/atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 6af1f23081..a102cdb49b 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -687,7 +687,7 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, module_type=None, coefficients=None, - aod500_ref=0.1, pw_ref=1.4): + aod500_ref=0.084, pw_ref=1.42): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), aerosol optical depth (AOD) at 500 nm and @@ -752,7 +752,7 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, coefficients vary in places with extreme climates where AOD and pw values are frequently high. - aod500_ref : numeric, default 0.84 + aod500_ref : numeric, default 0.084 TODO: description pw_ref : numeric, default 1.42 From ee614f57128e5279e55f8dfea40b43bde40d7a83 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 00:05:42 +0100 Subject: [PATCH 052/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index b8ea07c1bd..3c9ac70239 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -203,7 +203,7 @@ def test_AM_AOD_PW_spectral_correction(module_type, expected): pws = np.array([1.42, 1.42, 1.42, 1.42, 4.0, 1.0]) out = atmosphere.AM_AOD_PW_spectral_correction(ams, aods, pws, module_type=module_type, - aod500_ref=0.1, pw_ref=1.4) + aod500_ref=0.084, pw_ref=1.42) assert np.allclose(expected, out, atol=1e-3) From 2e02b94411bad22ab581733bb792d8c02c4263f2 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 00:06:36 +0100 Subject: [PATCH 053/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 3c9ac70239..bbd4566bfd 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -203,7 +203,8 @@ def test_AM_AOD_PW_spectral_correction(module_type, expected): pws = np.array([1.42, 1.42, 1.42, 1.42, 4.0, 1.0]) out = atmosphere.AM_AOD_PW_spectral_correction(ams, aods, pws, module_type=module_type, - aod500_ref=0.084, pw_ref=1.42) + aod500_ref=0.084, + pw_ref=1.42) assert np.allclose(expected, out, atol=1e-3) From 4b4e27fe91c7134d95410e5766226268a719a7d2 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 00:15:19 +0100 Subject: [PATCH 054/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index bbd4566bfd..aef63cefa0 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -219,6 +219,6 @@ def test_AM_AOD_PW_spectral_correction_supplied(): assert_allclose(out, expected, atol=1e-3) -def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): +def test_AM_AOD_PW_spectral_correction_ambiguous(): with pytest.raises(TypeError): - atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1) + atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1) From d71455dbec03ab66ed59bc2c9607de4fce78a18d Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 00:16:17 +0100 Subject: [PATCH 055/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index aef63cefa0..bcc0e3de68 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -221,4 +221,4 @@ def test_AM_AOD_PW_spectral_correction_supplied(): def test_AM_AOD_PW_spectral_correction_ambiguous(): with pytest.raises(TypeError): - atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1) + atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1) From e59f7d6eb7c758e91b4862cf10e86689b6068f3d Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 00:25:39 +0100 Subject: [PATCH 056/103] Update atmosphere.py --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index a102cdb49b..ee4f5749a5 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -687,7 +687,7 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, module_type=None, coefficients=None, - aod500_ref=0.084, pw_ref=1.42): + aod500_ref=0.08, pw_ref=1.4): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), aerosol optical depth (AOD) at 500 nm and From 7bf4e52e63d600de72f74c7ba0393f52b71d57d1 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 00:28:31 +0100 Subject: [PATCH 057/103] Update atmosphere.py --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index ee4f5749a5..a102cdb49b 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -687,7 +687,7 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, module_type=None, coefficients=None, - aod500_ref=0.08, pw_ref=1.4): + aod500_ref=0.084, pw_ref=1.42): r""" Spectral mismatch modifier based on absolute (pressure-adjusted) airmass (AM), aerosol optical depth (AOD) at 500 nm and From dc4af99aa48b1dd0dd3d7d6232d44d55f8937548 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 14:32:09 +0100 Subject: [PATCH 058/103] Update atmosphere.py --- pvlib/atmosphere.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index a102cdb49b..191e0edf94 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -820,6 +820,7 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, raise TypeError('Cannot resolve input, must supply only one' + 'of module_type and coefficients') + # Evaluate Spectral Shift coeff = coefficients ama = airmass_absolute From c09c46211cbf266bba43501c1b079e1ba52fefbe Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 14:32:47 +0100 Subject: [PATCH 059/103] Update atmosphere.py --- pvlib/atmosphere.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 191e0edf94..a102cdb49b 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -820,7 +820,6 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, raise TypeError('Cannot resolve input, must supply only one' + 'of module_type and coefficients') - # Evaluate Spectral Shift coeff = coefficients ama = airmass_absolute From 6334d86adb13deedc4507652bd22310a83f595ba Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 14:37:55 +0100 Subject: [PATCH 060/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index bcc0e3de68..bbd4566bfd 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -219,6 +219,6 @@ def test_AM_AOD_PW_spectral_correction_supplied(): assert_allclose(out, expected, atol=1e-3) -def test_AM_AOD_PW_spectral_correction_ambiguous(): +def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): with pytest.raises(TypeError): atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1) From 72f6cf172b00e332cccf7ec8fbb2d4fb0067b2e8 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 14:46:49 +0100 Subject: [PATCH 061/103] Update atmosphere.py --- pvlib/atmosphere.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index a102cdb49b..ebcbcdff69 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -814,11 +814,11 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, elif module_type is None and coefficients is not None: pass elif module_type is None and coefficients is None: - raise TypeError('No valid input provided, both module_type' + - 'and coefficients are None') + raise TypeError('No valid input provided, both module_type' + + 'and coefficients are None') else: - raise TypeError('Cannot resolve input, must supply only one' + - 'of module_type and coefficients') + raise TypeError('Cannot resolve input, must supply only one' + + 'of module_type and coefficients') # Evaluate Spectral Shift coeff = coefficients From b37cbdbc3decd3f3db4029ec664df28140734cb7 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 21:01:31 +0100 Subject: [PATCH 062/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index bbd4566bfd..d3aac7858c 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -190,12 +190,12 @@ def test_bird_hulstrom80_aod_bb(): @pytest.mark.parametrize("module_type,expected", [ - ('asi', np.array([0.9897, 0.9707, 1.0265, 1.0798, 0.9537])), - ('perovskite', np.array([0.9932, 0.9868, 1.0183, 1.0605, 0.9738])), - ('cdte', np.array([1.0000, 1.0066, 1.0118, 1.0427, 0.9980])), - ('multisi', np.array([0.9979, 1.0203, 1.0081, 1.0058, 1.01915])), - ('monosi', np.array([0.9988, 1.0265, 1.0075, 0.9999, 1.0264])), - ('cigs', np.array([1.0012, 1.0271, 1.0082, 1.0030, 1.0268])), + ('asi', np.array([0.9108, 0.9897, 0.9707, 1.0265, 1.0798, 0.9537])), + ('perovskite', np.array([0.9422, 0.9932, 0.9868, 1.0183, 1.0604, 0.9737])), + ('cdte', np.array([0.9824, 1.0000, 1.0065, 1.0117, 1.042, 0.9979])), + ('multisi', np.array([0.9907, 0.9979, 1.0203, 1.0081, 1.0058, 1.019])), + ('monosi', np.array([0.9935, 0.9987, 1.0264, 1.0074, 0.9999, 1.0263])), + ('cigs', np.array([1.0014, 1.0011, 1.0270, 1.0082, 1.0029, 1.026])), ]) def test_AM_AOD_PW_spectral_correction(module_type, expected): ams = np.array([3.0, 1.5, 3.0, 1.5, 1.5, 3.0]) @@ -220,5 +220,6 @@ def test_AM_AOD_PW_spectral_correction_supplied(): def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): + dummy_coeffs = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) with pytest.raises(TypeError): - atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1) + atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, module_type='cdte', coefficients=dummy_coeffs) From ff3f660d10f5909f8a7d5885259cee5f22bd0481 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 21:02:53 +0100 Subject: [PATCH 063/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index d3aac7858c..ab4c36d326 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -222,4 +222,6 @@ def test_AM_AOD_PW_spectral_correction_supplied(): def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): dummy_coeffs = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) with pytest.raises(TypeError): - atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, module_type='cdte', coefficients=dummy_coeffs) + atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, + module_type='cdte', + coefficients=dummy_coeffs) From b4c9dfbe88e32d43f04c67168d0e8ef41a411868 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 21:29:36 +0100 Subject: [PATCH 064/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index ab4c36d326..61a2d767e7 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -225,3 +225,8 @@ def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, module_type='cdte', coefficients=dummy_coeffs) +def test_AM_AOD_PW_spectral_correction_supplied_ambiguous_1(): + with pytest.raises(TypeError): + atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, + module_type=None, + coefficients=None) From f4ab78fd0077a8f4bf15ceed9c5976fb7800dbf7 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 21:30:09 +0100 Subject: [PATCH 065/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 61a2d767e7..5fa44ea2f5 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -225,6 +225,8 @@ def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, module_type='cdte', coefficients=dummy_coeffs) + + def test_AM_AOD_PW_spectral_correction_supplied_ambiguous_1(): with pytest.raises(TypeError): atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, From 55ac6a6617655042045286ac0669976609f95d21 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 3 Nov 2021 21:31:45 +0100 Subject: [PATCH 066/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 5fa44ea2f5..28e8eaff37 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -225,9 +225,9 @@ def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, module_type='cdte', coefficients=dummy_coeffs) - - -def test_AM_AOD_PW_spectral_correction_supplied_ambiguous_1(): + + +def test_AM_AOD_PW_spectral_correction_supplied_ambiguous_1(): with pytest.raises(TypeError): atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, module_type=None, From d2e7f70ab6f326cd536a6ec885b5e3034fa6a2e9 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sun, 14 Nov 2021 22:14:10 +0100 Subject: [PATCH 067/103] Update pvlib/atmosphere.py Co-authored-by: Cliff Hansen --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index ebcbcdff69..c05b3eb59c 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -814,7 +814,7 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, elif module_type is None and coefficients is not None: pass elif module_type is None and coefficients is None: - raise TypeError('No valid input provided, both module_type' + raise ValueError('No valid input provided, both module_type' + 'and coefficients are None') else: raise TypeError('Cannot resolve input, must supply only one' From bc353f2813a3c211f6677a19c348637cf02719ec Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sun, 14 May 2023 20:10:51 +0200 Subject: [PATCH 068/103] Update atmosphere.py Added the requested changes --- pvlib/atmosphere.py | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index c05b3eb59c..03d4c2b010 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -685,7 +685,7 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): return - np.log(aod1 / aod2) / np.log(lambda1 / lambda2) -def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, +def caballero_spectral_correction(airmass_absolute, aod500, pw, module_type=None, coefficients=None, aod500_ref=0.084, pw_ref=1.42): r""" @@ -697,11 +697,11 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, the effect on module short circuit current of variation in the spectral irradiance, :math:`MM` is estimated from absolute (pressure-adjusted) AM, :math:`ama`, AOD at 500 nm, :math:`aod500` - and PW, :math:`pw`. + and PW, :math:`pw` [1]. The best fit polynomial for each atmospheric parameter (AM, AOD, PW) and PV technology under study has been obtained from synthetic spectra - generated with SMARTS [1], considering the following boundary + generated with SMARTS [2], considering the following boundary conditions: * :math:`1.0 <= ama <= 5.0` @@ -718,8 +718,8 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, Finally, the spectral mismatch factor was calculated for each of the PV technologies and a multivariable regression adjustment - as a function of AM, AOD and PW was performed according to [2] and [3]. - As such, the polynomial adjustment coefficients included in [3] + as a function of AM, AOD and PW was performed according to [3] and [1]. + As such, the polynomial adjustment coefficients included in [1] were obtained. @@ -768,23 +768,23 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, References ---------- - .. [1] Gueymard, Christian. SMARTS2: a simple model of the + .. [1] Caballero, J.A., Fernández, E., Theristis, M., + Almonacid, F., and Nofuentes, G. "Spectral Corrections Based on + Air Mass, Aerosol Optical Depth and Precipitable Water + for PV Performance Modeling. + " IEEE Journal of Photovoltaics 2018, 8(2), 552-558. + https://doi.org/10.1109/jphotov.2017.2787019 + .. [2] Gueymard, Christian. SMARTS2: a simple model of the atmospheric radiative transfer of sunshine: algorithms and performance assessment. Cocoa, FL: Florida Solar Energy Center, 1995. - .. [2] Theristis, M., Fernández, E., Almonacid, F., and + .. [3] Theristis, M., Fernández, E., Almonacid, F., and Pérez-Higueras, Pedro. "Spectral Corrections Based on Air Mass, Aerosol Optical Depth and Precipitable Water for CPV Performance Modeling. "IEEE Journal of Photovoltaics 2016, 6(6), 1598-1604. https://doi.org/10.1109/jphotov.2016.2606702 - .. [3] Caballero, J.A., Fernández, E., Theristis, M., - Almonacid, F., and Nofuentes, G. "Spectral Corrections Based on - Air Mass, Aerosol Optical Depth and Precipitable Water - for PV Performance Modeling. - " IEEE Journal of Photovoltaics 2018, 8(2), 552-558. - https://doi.org/10.1109/jphotov.2017.2787019 - + """ # Experimental coefficients @@ -809,17 +809,15 @@ def AM_AOD_PW_spectral_correction(airmass_absolute, aod500, pw, 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, 0.0583, -0.0159, 0.01251, 0.0109, 1, 0) - if module_type is not None and coefficients is None: - coefficients = _coefficients[module_type.lower()] - elif module_type is None and coefficients is not None: - pass - elif module_type is None and coefficients is None: - raise ValueError('No valid input provided, both module_type' + if module_type is None and coefficients is None: + raise TypeError('Invalid input provided, both module_type' + 'and coefficients are None') + elif coefficients is None: + raise TypeError('Cannot resolve input, providing the' + + ' coefficients input is mandatory') else: - raise TypeError('Cannot resolve input, must supply only one' - + 'of module_type and coefficients') - + pass + # Evaluate Spectral Shift coeff = coefficients ama = airmass_absolute From d93b187469fe37ee9322d13e7236336098664390 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sun, 14 May 2023 20:14:43 +0200 Subject: [PATCH 069/103] Update atmosphere.py Fixed 2 blank line errors. --- pvlib/atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 03d4c2b010..de7d132569 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -784,7 +784,7 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, Water for CPV Performance Modeling. "IEEE Journal of Photovoltaics 2016, 6(6), 1598-1604. https://doi.org/10.1109/jphotov.2016.2606702 - + """ # Experimental coefficients @@ -817,7 +817,7 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, + ' coefficients input is mandatory') else: pass - + # Evaluate Spectral Shift coeff = coefficients ama = airmass_absolute From 5165060f115417c532f799b6060f9951d6d1970e Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sun, 14 May 2023 20:16:19 +0200 Subject: [PATCH 070/103] Update test_atmosphere.py Updated test function name to: caballero_spectral_correction --- pvlib/tests/test_atmosphere.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 28e8eaff37..3fa0be0015 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -197,7 +197,7 @@ def test_bird_hulstrom80_aod_bb(): ('monosi', np.array([0.9935, 0.9987, 1.0264, 1.0074, 0.9999, 1.0263])), ('cigs', np.array([1.0014, 1.0011, 1.0270, 1.0082, 1.0029, 1.026])), ]) -def test_AM_AOD_PW_spectral_correction(module_type, expected): +def test_caballero_spectral_correction(module_type, expected): ams = np.array([3.0, 1.5, 3.0, 1.5, 1.5, 3.0]) aods = np.array([1.0, 1.0, 0.02, 0.02, 0.08, 0.08]) pws = np.array([1.42, 1.42, 1.42, 1.42, 4.0, 1.0]) @@ -208,7 +208,7 @@ def test_AM_AOD_PW_spectral_correction(module_type, expected): assert np.allclose(expected, out, atol=1e-3) -def test_AM_AOD_PW_spectral_correction_supplied(): +def test_caballero_spectral_correction_supplied(): # use the cdte coeffs coeffs = ( 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, @@ -219,7 +219,7 @@ def test_AM_AOD_PW_spectral_correction_supplied(): assert_allclose(out, expected, atol=1e-3) -def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): +def test_caballero_spectral_correction_supplied_ambiguous(): dummy_coeffs = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) with pytest.raises(TypeError): atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, @@ -227,7 +227,7 @@ def test_AM_AOD_PW_spectral_correction_supplied_ambiguous(): coefficients=dummy_coeffs) -def test_AM_AOD_PW_spectral_correction_supplied_ambiguous_1(): +def test_caballero_spectral_correction_supplied_ambiguous_1(): with pytest.raises(TypeError): atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, module_type=None, From 5b16ce3335f38e5f2397d247de8431c7b3b0bb26 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sun, 14 May 2023 20:19:52 +0200 Subject: [PATCH 071/103] Update api.rst Updated the atmosphere function name from AM_AOD_PW_spectral_correction to caballero_spectral_correction --- docs/sphinx/source/api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/api.rst b/docs/sphinx/source/api.rst index b8af294694..ced74be74b 100644 --- a/docs/sphinx/source/api.rst +++ b/docs/sphinx/source/api.rst @@ -126,7 +126,7 @@ Airmass and atmospheric models atmosphere.kasten96_lt atmosphere.angstrom_aod_at_lambda atmosphere.angstrom_alpha - atmosphere.AM_AOD_PW_spectral_correction + atmosphere.caballero_spectral_correction Irradiance From eb26a2d92a255c34ab5c7c9ae8be2b4befb1ec2e Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sun, 14 May 2023 20:24:52 +0200 Subject: [PATCH 072/103] Update test_atmosphere.py Updated some functions calls from AM_AOD_PW_spectral_correction to caballero_spectral_correction --- pvlib/tests/test_atmosphere.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 3fa0be0015..6c67ec8425 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -201,7 +201,7 @@ def test_caballero_spectral_correction(module_type, expected): ams = np.array([3.0, 1.5, 3.0, 1.5, 1.5, 3.0]) aods = np.array([1.0, 1.0, 0.02, 0.02, 0.08, 0.08]) pws = np.array([1.42, 1.42, 1.42, 1.42, 4.0, 1.0]) - out = atmosphere.AM_AOD_PW_spectral_correction(ams, aods, pws, + out = atmosphere.caballero_spectral_correction(ams, aods, pws, module_type=module_type, aod500_ref=0.084, pw_ref=1.42) @@ -213,7 +213,7 @@ def test_caballero_spectral_correction_supplied(): coeffs = ( 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0, 1) - out = atmosphere.AM_AOD_PW_spectral_correction(1, + out = atmosphere.caballero_spectral_correction(1, 1, 1, coefficients=coeffs) expected = 1.0021964 assert_allclose(out, expected, atol=1e-3) @@ -222,13 +222,13 @@ def test_caballero_spectral_correction_supplied(): def test_caballero_spectral_correction_supplied_ambiguous(): dummy_coeffs = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) with pytest.raises(TypeError): - atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, + atmosphere.caballero_spectral_correction(1, 1, 1, module_type='cdte', coefficients=dummy_coeffs) def test_caballero_spectral_correction_supplied_ambiguous_1(): with pytest.raises(TypeError): - atmosphere.AM_AOD_PW_spectral_correction(1, 1, 1, + atmosphere.caballero_spectral_correction(1, 1, 1, module_type=None, coefficients=None) From 49574368071b73575f543400030554562dc4eef5 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Sun, 14 May 2023 20:40:47 +0200 Subject: [PATCH 073/103] Update atmosphere.py Updated the logic to show errors. --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index de7d132569..bf10e91433 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -812,7 +812,7 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, if module_type is None and coefficients is None: raise TypeError('Invalid input provided, both module_type' + 'and coefficients are None') - elif coefficients is None: + elif module_type is not None and coefficients is None: raise TypeError('Cannot resolve input, providing the' + ' coefficients input is mandatory') else: From 6e10781a25a1b52d8ec00648797281d92933021c Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 16 May 2023 20:02:29 +0200 Subject: [PATCH 074/103] Update pvlib/atmosphere.py Co-authored-by: Cliff Hansen --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index bf10e91433..6b0fdb488c 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -695,7 +695,7 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, Estimates a spectral mismatch modifier :math:`M` representing the effect on module short circuit current of variation in the - spectral irradiance, :math:`MM` is estimated from absolute + spectral irradiance. :math:`M` is estimated from absolute (pressure-adjusted) AM, :math:`ama`, AOD at 500 nm, :math:`aod500` and PW, :math:`pw` [1]. From 4f23ad67ca04d8e597f8075e61c6b82e818dbd14 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 16 May 2023 20:02:44 +0200 Subject: [PATCH 075/103] Update pvlib/atmosphere.py Co-authored-by: Cliff Hansen --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 6b0fdb488c..fb0c9f549f 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -697,7 +697,7 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, the effect on module short circuit current of variation in the spectral irradiance. :math:`M` is estimated from absolute (pressure-adjusted) AM, :math:`ama`, AOD at 500 nm, :math:`aod500` - and PW, :math:`pw` [1]. + and PW, :math:`pw` [1]_. The best fit polynomial for each atmospheric parameter (AM, AOD, PW) and PV technology under study has been obtained from synthetic spectra From a7b9309008ee1c0cdbb43618cbb5250990c70266 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 16 May 2023 20:02:53 +0200 Subject: [PATCH 076/103] Update pvlib/atmosphere.py Co-authored-by: Cliff Hansen --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index fb0c9f549f..45ffb52662 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -701,7 +701,7 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, The best fit polynomial for each atmospheric parameter (AM, AOD, PW) and PV technology under study has been obtained from synthetic spectra - generated with SMARTS [2], considering the following boundary + generated with SMARTS [2]_, considering the following boundary conditions: * :math:`1.0 <= ama <= 5.0` From a4560cc02dd6b24083e900eba7d31ddf580d21e8 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 16 May 2023 20:03:11 +0200 Subject: [PATCH 077/103] Update pvlib/atmosphere.py Co-authored-by: Cliff Hansen --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 45ffb52662..52c253225f 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -736,7 +736,7 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, module_type : None or string, default None a string specifying a cell type. Values of 'cdte', 'monosi', 'cigs', - 'multisi','asi' and 'pervovskite'. If provided, + 'multisi','asi' and 'perovskite'. If provided, module_type selects default coefficients for the following modules: * 'cdte' - anonymous CdTe module. From f6d33d496e622438b2042237e9392fb840326b8f Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 16 May 2023 20:03:31 +0200 Subject: [PATCH 078/103] Update pvlib/atmosphere.py Co-authored-by: Cliff Hansen --- pvlib/atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 52c253225f..1686fdf57a 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -771,8 +771,8 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, .. [1] Caballero, J.A., Fernández, E., Theristis, M., Almonacid, F., and Nofuentes, G. "Spectral Corrections Based on Air Mass, Aerosol Optical Depth and Precipitable Water - for PV Performance Modeling. - " IEEE Journal of Photovoltaics 2018, 8(2), 552-558. + for PV Performance Modeling." + IEEE Journal of Photovoltaics 2018, 8(2), 552-558. https://doi.org/10.1109/jphotov.2017.2787019 .. [2] Gueymard, Christian. SMARTS2: a simple model of the atmospheric radiative transfer of sunshine: algorithms From 834fd9136586a7fa995b1cdeaaa4be9a21afadcc Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 16 May 2023 20:03:44 +0200 Subject: [PATCH 079/103] Update pvlib/atmosphere.py Co-authored-by: Cliff Hansen --- pvlib/atmosphere.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 1686fdf57a..38741a4a11 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -779,11 +779,11 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, and performance assessment. Cocoa, FL: Florida Solar Energy Center, 1995. .. [3] Theristis, M., Fernández, E., Almonacid, F., and - Pérez-Higueras, Pedro. "Spectral Corrections Based - on Air Mass, Aerosol Optical Depth and Precipitable - Water for CPV Performance Modeling. - "IEEE Journal of Photovoltaics 2016, 6(6), 1598-1604. - https://doi.org/10.1109/jphotov.2016.2606702 + Pérez-Higueras, Pedro. "Spectral Corrections Based + on Air Mass, Aerosol Optical Depth and Precipitable + Water for CPV Performance Modeling." + IEEE Journal of Photovoltaics 2016, 6(6), 1598-1604. + https://doi.org/10.1109/jphotov.2016.2606702 """ From b7d643e57fef64b4c8868851c8ac9a77f4d78027 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 16 May 2023 20:09:24 +0200 Subject: [PATCH 080/103] Update atmosphere.py --- pvlib/atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 38741a4a11..dbb94e203c 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -810,10 +810,10 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, 0.0583, -0.0159, 0.01251, 0.0109, 1, 0) if module_type is None and coefficients is None: - raise TypeError('Invalid input provided, both module_type' + raise ValueError('Invalid input provided, both module_type' + 'and coefficients are None') elif module_type is not None and coefficients is None: - raise TypeError('Cannot resolve input, providing the' + raise ValueError('Cannot resolve input, providing the' + ' coefficients input is mandatory') else: pass From a07c7b6a9c1c0ca099159b8350007b67904497b3 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 16 May 2023 21:12:20 +0200 Subject: [PATCH 081/103] Update atmosphere.py --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index dbb94e203c..a85931804a 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -718,7 +718,7 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, Finally, the spectral mismatch factor was calculated for each of the PV technologies and a multivariable regression adjustment - as a function of AM, AOD and PW was performed according to [3] and [1]. + as a function of AM, AOD and PW was performed according to [3] and [1]_. As such, the polynomial adjustment coefficients included in [1] were obtained. From f9df15bea21bbd77f22960a339d3750cb7244922 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 17 May 2023 20:04:17 +0200 Subject: [PATCH 082/103] Update atmosphere.py Trying to solve #814 and #817 issues. --- pvlib/atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index a85931804a..5bf579ff96 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -811,10 +811,10 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, if module_type is None and coefficients is None: raise ValueError('Invalid input provided, both module_type' - + 'and coefficients are None') + +'and coefficients are None') elif module_type is not None and coefficients is None: raise ValueError('Cannot resolve input, providing the' - + ' coefficients input is mandatory') + +' coefficients input is mandatory') else: pass From e1633bfac7a0331ef4b999bf82d36b31c1baa313 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 17 May 2023 20:18:41 +0200 Subject: [PATCH 083/103] Update atmosphere.py --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 5bf579ff96..bd0ba2b700 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -811,7 +811,7 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, if module_type is None and coefficients is None: raise ValueError('Invalid input provided, both module_type' - +'and coefficients are None') + +' and coefficients are None') elif module_type is not None and coefficients is None: raise ValueError('Cannot resolve input, providing the' +' coefficients input is mandatory') From fea23147a1a22fae994d1ade10f0d9d5e331018f Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 17 May 2023 20:21:49 +0200 Subject: [PATCH 084/103] Update api.rst --- docs/sphinx/source/api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/api.rst b/docs/sphinx/source/api.rst index ced74be74b..c037956858 100644 --- a/docs/sphinx/source/api.rst +++ b/docs/sphinx/source/api.rst @@ -116,6 +116,7 @@ Airmass and atmospheric models :toctree: generated/ location.Location.get_airmass + atmosphere.caballero_spectral_correction atmosphere.get_absolute_airmass atmosphere.get_relative_airmass atmosphere.pres2alt @@ -126,7 +127,6 @@ Airmass and atmospheric models atmosphere.kasten96_lt atmosphere.angstrom_aod_at_lambda atmosphere.angstrom_alpha - atmosphere.caballero_spectral_correction Irradiance From 1be725035f94652719a2742e9f3b23d452714b99 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 17 May 2023 20:29:45 +0200 Subject: [PATCH 085/103] Delete api.rst --- docs/sphinx/source/api.rst | 716 ------------------------------------- 1 file changed, 716 deletions(-) delete mode 100644 docs/sphinx/source/api.rst diff --git a/docs/sphinx/source/api.rst b/docs/sphinx/source/api.rst deleted file mode 100644 index c037956858..0000000000 --- a/docs/sphinx/source/api.rst +++ /dev/null @@ -1,716 +0,0 @@ -.. currentmodule:: pvlib - -############# -API reference -############# - - -Classes -======= - -pvlib-python provides a collection of classes for users that prefer -object-oriented programming. These classes can help users keep track of -data in a more organized way, and can help to simplify the modeling -process. The classes do not add any functionality beyond the procedural -code. Most of the object methods are simple wrappers around the -corresponding procedural code. For examples of using these classes, see -the :ref:`pvsystemdoc` and :ref:`modelchaindoc` pages. - -.. autosummary:: - :toctree: generated/ - - location.Location - pvsystem.PVSystem - pvsystem.Array - pvsystem.FixedMount - pvsystem.SingleAxisTrackerMount - tracking.SingleAxisTracker - modelchain.ModelChain - modelchain.ModelChainResult - -Solar Position -============== - -Functions and methods for calculating solar position. - -The :py:meth:`location.Location.get_solarposition` method and the -:py:func:`solarposition.get_solarposition` function with default -parameters are fast and accurate. We recommend using these functions -unless you know that you need a different function. - -.. autosummary:: - :toctree: generated/ - - location.Location.get_solarposition - solarposition.get_solarposition - solarposition.spa_python - solarposition.ephemeris - solarposition.pyephem - solarposition.spa_c - - -Additional functions for quantities closely related to solar position. - -.. autosummary:: - :toctree: generated/ - - solarposition.calc_time - solarposition.pyephem_earthsun_distance - solarposition.nrel_earthsun_distance - spa.calculate_deltat - - -Functions for calculating sunrise, sunset and transit times. - -.. autosummary:: - :toctree: generated/ - - location.Location.get_sun_rise_set_transit - solarposition.sun_rise_set_transit_ephem - solarposition.sun_rise_set_transit_spa - solarposition.sun_rise_set_transit_geometric - - -The spa module contains the implementation of the built-in NREL SPA -algorithm. - -.. autosummary:: - :toctree: generated/ - - spa - -Correlations and analytical expressions for low precision solar position -calculations. - -.. autosummary:: - :toctree: generated/ - - solarposition.solar_zenith_analytical - solarposition.solar_azimuth_analytical - solarposition.declination_spencer71 - solarposition.declination_cooper69 - solarposition.equation_of_time_spencer71 - solarposition.equation_of_time_pvcdrom - solarposition.hour_angle - - -Clear sky -========= - -.. autosummary:: - :toctree: generated/ - - location.Location.get_clearsky - clearsky.ineichen - clearsky.lookup_linke_turbidity - clearsky.simplified_solis - clearsky.haurwitz - clearsky.detect_clearsky - clearsky.bird - - -Airmass and atmospheric models -============================== - -.. autosummary:: - :toctree: generated/ - - location.Location.get_airmass - atmosphere.caballero_spectral_correction - atmosphere.get_absolute_airmass - atmosphere.get_relative_airmass - atmosphere.pres2alt - atmosphere.alt2pres - atmosphere.gueymard94_pw - atmosphere.first_solar_spectral_correction - atmosphere.bird_hulstrom80_aod_bb - atmosphere.kasten96_lt - atmosphere.angstrom_aod_at_lambda - atmosphere.angstrom_alpha - - -Irradiance -========== - -Methods for irradiance calculations ------------------------------------ - -.. autosummary:: - :toctree: generated/ - - pvsystem.PVSystem.get_irradiance - pvsystem.PVSystem.get_aoi - pvsystem.PVSystem.get_iam - tracking.SingleAxisTracker.get_irradiance - -Decomposing and combining irradiance ------------------------------------- - -.. autosummary:: - :toctree: generated/ - - irradiance.get_extra_radiation - irradiance.aoi - irradiance.aoi_projection - irradiance.poa_horizontal_ratio - irradiance.beam_component - irradiance.poa_components - irradiance.get_ground_diffuse - irradiance.dni - -Transposition models --------------------- - -.. autosummary:: - :toctree: generated/ - - irradiance.get_total_irradiance - irradiance.get_sky_diffuse - irradiance.isotropic - irradiance.perez - irradiance.haydavies - irradiance.klucher - irradiance.reindl - irradiance.king - -.. _dniestmodels: - -DNI estimation models ---------------------- - -.. autosummary:: - :toctree: generated/ - - irradiance.disc - irradiance.dirint - irradiance.dirindex - irradiance.erbs - irradiance.campbell_norman - irradiance.gti_dirint - -Clearness index models ----------------------- - -.. autosummary:: - :toctree: generated/ - - irradiance.clearness_index - irradiance.clearness_index_zenith_independent - irradiance.clearsky_index - - -PV Modeling -=========== - -Classes -------- - -The :py:class:`~pvsystem.PVSystem` class provides many methods that -wrap the functions listed below. See its documentation for details. - -.. autosummary:: - :toctree: generated/ - - pvsystem.PVSystem - -Incident angle modifiers ------------------------- - -.. autosummary:: - :toctree: generated/ - - iam.physical - iam.ashrae - iam.martin_ruiz - iam.martin_ruiz_diffuse - iam.sapm - iam.interp - iam.marion_diffuse - iam.marion_integrate - -PV temperature models ---------------------- - -.. autosummary:: - :toctree: generated/ - - temperature.sapm_cell - temperature.sapm_module - temperature.sapm_cell_from_module - temperature.pvsyst_cell - temperature.faiman - temperature.fuentes - temperature.ross - temperature.noct_sam - pvsystem.PVSystem.get_cell_temperature - -Temperature Model Parameters -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. currentmodule:: pvlib.temperature -.. autodata:: TEMPERATURE_MODEL_PARAMETERS - :annotation: - -.. currentmodule:: pvlib - -Single diode models -------------------- - -Functions relevant for single diode models. - -.. autosummary:: - :toctree: generated/ - - pvsystem.calcparams_cec - pvsystem.calcparams_desoto - pvsystem.calcparams_pvsyst - pvsystem.i_from_v - pvsystem.singlediode - pvsystem.v_from_i - pvsystem.max_power_point - ivtools.sdm.pvsyst_temperature_coeff - -Low-level functions for solving the single diode equation. - -.. autosummary:: - :toctree: generated/ - - singlediode.estimate_voc - singlediode.bishop88 - singlediode.bishop88_i_from_v - singlediode.bishop88_v_from_i - singlediode.bishop88_mpp - -Functions for fitting diode models - -.. autosummary:: - :toctree: generated/ - - ivtools.sde.fit_sandia_simple - ivtools.sdm.fit_cec_sam - ivtools.sdm.fit_desoto - -Inverter models (DC to AC conversion) -------------------------------------- - -.. autosummary:: - :toctree: generated/ - - pvsystem.PVSystem.get_ac - inverter.sandia - inverter.sandia_multi - inverter.adr - inverter.pvwatts - inverter.pvwatts_multi - -Functions for fitting inverter models - -.. autosummary:: - :toctree: generated/ - - inverter.fit_sandia - - -PV System Models ----------------- - -Sandia array performance model (SAPM) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autosummary:: - :toctree: generated/ - - pvsystem.sapm - pvsystem.sapm_effective_irradiance - pvsystem.sapm_spectral_loss - inverter.sandia - temperature.sapm_cell - -Pvsyst model -^^^^^^^^^^^^ - -.. autosummary:: - :toctree: generated/ - - temperature.pvsyst_cell - pvsystem.calcparams_pvsyst - pvsystem.singlediode - ivtools.sdm.pvsyst_temperature_coeff - pvsystem.dc_ohms_from_percent - pvsystem.dc_ohmic_losses - -PVWatts model -^^^^^^^^^^^^^ - -.. autosummary:: - :toctree: generated/ - - pvsystem.pvwatts_dc - inverter.pvwatts - pvsystem.pvwatts_losses - -Estimating PV model parameters ------------------------------- - -Functions for fitting single diode models - -.. autosummary:: - :toctree: generated/ - - ivtools.sdm.fit_cec_sam - ivtools.sdm.fit_desoto - ivtools.sdm.fit_pvsyst_sandia - ivtools.sdm.fit_desoto_sandia - -Functions for fitting the single diode equation - -.. autosummary:: - :toctree: generated/ - - ivtools.sde.fit_sandia_simple - -Utilities for working with IV curve data - -.. autosummary:: - :toctree: generated/ - - ivtools.utils.rectify_iv_curve - -Other ------ - -.. autosummary:: - :toctree: generated/ - - pvsystem.retrieve_sam - pvsystem.scale_voltage_current_power - - -Effects on PV System Output -=========================== - -Loss models ------------ - -.. autosummary:: - :toctree: generated/ - - pvsystem.combine_loss_factors - pvsystem.dc_ohms_from_percent - -Snow ----- - -.. autosummary:: - :toctree: generated/ - - snow.coverage_nrel - snow.fully_covered_nrel - snow.dc_loss_nrel - -Soiling -------- - -.. autosummary:: - :toctree: generated/ - - soiling.hsu - soiling.kimber - -Shading -------- - -.. autosummary:: - :toctree: generated/ - - shading.masking_angle - shading.masking_angle_passias - shading.sky_diffuse_passias - -Spectrum --------- - -.. autosummary:: - :toctree: generated/ - - spectrum.spectrl2 - -Tracking -======== - -SingleAxisTracker ------------------ - -The :py:class:`~tracking.SingleAxisTracker` inherits from -:py:class:`~pvsystem.PVSystem`. - -.. autosummary:: - :toctree: generated/ - - tracking.SingleAxisTracker - tracking.SingleAxisTracker.singleaxis - tracking.SingleAxisTracker.get_irradiance - -Functions ---------- - -.. autosummary:: - :toctree: generated/ - - tracking.singleaxis - tracking.calc_axis_tilt - tracking.calc_cross_axis_tilt - - -.. _iotools: - -IO Tools -======== - -Functions for retrieving, reading, and writing data from a variety -of sources and file formats relevant to solar energy modeling. - -.. autosummary:: - :toctree: generated/ - - iotools.read_tmy2 - iotools.read_tmy3 - iotools.read_epw - iotools.parse_epw - iotools.read_srml - iotools.read_srml_month_from_solardat - iotools.read_surfrad - iotools.read_midc - iotools.read_midc_raw_data_from_nrel - iotools.read_ecmwf_macc - iotools.get_ecmwf_macc - iotools.read_crn - iotools.read_solrad - iotools.get_psm3 - iotools.read_psm3 - iotools.parse_psm3 - iotools.get_pvgis_tmy - iotools.read_pvgis_tmy - iotools.get_pvgis_hourly - iotools.read_pvgis_hourly - iotools.get_bsrn - iotools.read_bsrn - iotools.parse_bsrn - iotools.get_cams - iotools.read_cams - iotools.parse_cams - -A :py:class:`~pvlib.location.Location` object may be created from metadata -in some files. - -.. autosummary:: - :toctree: generated/ - - location.Location.from_tmy - location.Location.from_epw - - -Forecasting -=========== - -Forecast models ---------------- - -.. autosummary:: - :toctree: generated/ - - forecast.GFS - forecast.NAM - forecast.RAP - forecast.HRRR - forecast.HRRR_ESRL - forecast.NDFD - -Getting data ------------- - -.. autosummary:: - :toctree: generated/ - - forecast.ForecastModel.get_data - forecast.ForecastModel.get_processed_data - -Processing data ---------------- - -.. autosummary:: - :toctree: generated/ - - forecast.ForecastModel.process_data - forecast.ForecastModel.rename - forecast.ForecastModel.cloud_cover_to_ghi_linear - forecast.ForecastModel.cloud_cover_to_irradiance_clearsky_scaling - forecast.ForecastModel.cloud_cover_to_transmittance_linear - forecast.ForecastModel.cloud_cover_to_irradiance_campbell_norman - forecast.ForecastModel.cloud_cover_to_irradiance - forecast.ForecastModel.kelvin_to_celsius - forecast.ForecastModel.isobaric_to_ambient_temperature - forecast.ForecastModel.uv_to_speed - forecast.ForecastModel.gust_to_speed - -IO support ----------- - -These are public for now, but use at your own risk. - -.. autosummary:: - :toctree: generated/ - - forecast.ForecastModel.set_dataset - forecast.ForecastModel.set_query_latlon - forecast.ForecastModel.set_location - forecast.ForecastModel.set_time - - -ModelChain -========== - -Creating a ModelChain object. - -.. autosummary:: - :toctree: generated/ - - modelchain.ModelChain - modelchain.ModelChain.with_pvwatts - modelchain.ModelChain.with_sapm - -.. _modelchain_runmodel: - -Running -------- - -A ModelChain can be run from a number of starting points, depending on the -input data available. - -.. autosummary:: - :toctree: generated/ - - modelchain.ModelChain.run_model - modelchain.ModelChain.run_model_from_poa - modelchain.ModelChain.run_model_from_effective_irradiance - -Functions to assist with setting up ModelChains to run - -.. autosummary:: - :toctree: generated/ - - modelchain.ModelChain.complete_irradiance - modelchain.ModelChain.prepare_inputs - modelchain.ModelChain.prepare_inputs_from_poa - -Results -------- - -Output from the running the ModelChain is stored in the -:py:attr:`modelchain.ModelChain.results` attribute. For more -information see :py:class:`modelchain.ModelChainResult`. - -Attributes ----------- - -Simple ModelChain attributes: - -``system, location, clearsky_model, transposition_model, -solar_position_method, airmass_model`` - -Properties ----------- - -ModelChain properties that are aliases for your specific modeling functions. - -.. autosummary:: - :toctree: generated/ - - modelchain.ModelChain.dc_model - modelchain.ModelChain.ac_model - modelchain.ModelChain.aoi_model - modelchain.ModelChain.spectral_model - modelchain.ModelChain.temperature_model - modelchain.ModelChain.dc_ohmic_model - modelchain.ModelChain.losses_model - modelchain.ModelChain.effective_irradiance_model - -Model definitions ------------------ - -ModelChain model definitions. - -.. autosummary:: - :toctree: generated/ - - modelchain.ModelChain.sapm - modelchain.ModelChain.cec - modelchain.ModelChain.desoto - modelchain.ModelChain.pvsyst - modelchain.ModelChain.pvwatts_dc - modelchain.ModelChain.sandia_inverter - modelchain.ModelChain.adr_inverter - modelchain.ModelChain.pvwatts_inverter - modelchain.ModelChain.ashrae_aoi_loss - modelchain.ModelChain.physical_aoi_loss - modelchain.ModelChain.sapm_aoi_loss - modelchain.ModelChain.no_aoi_loss - modelchain.ModelChain.first_solar_spectral_loss - modelchain.ModelChain.sapm_spectral_loss - modelchain.ModelChain.no_spectral_loss - modelchain.ModelChain.sapm_temp - modelchain.ModelChain.pvsyst_temp - modelchain.ModelChain.faiman_temp - modelchain.ModelChain.fuentes_temp - modelchain.ModelChain.dc_ohmic_model - modelchain.ModelChain.no_dc_ohmic_loss - modelchain.ModelChain.pvwatts_losses - modelchain.ModelChain.no_extra_losses - -Inference methods ------------------ - -Methods that automatically determine which models should be used based -on the information in the associated :py:class:`~pvsystem.PVSystem` object. - -.. autosummary:: - :toctree: generated/ - - modelchain.ModelChain.infer_dc_model - modelchain.ModelChain.infer_ac_model - modelchain.ModelChain.infer_aoi_model - modelchain.ModelChain.infer_spectral_model - modelchain.ModelChain.infer_temperature_model - modelchain.ModelChain.infer_losses_model - -Functions ---------- - -Functions for power modeling. - -.. autosummary:: - :toctree: generated/ - - modelchain.basic_chain - modelchain.get_orientation - - -Bifacial -======== - -Methods for calculating back surface irradiance - -.. autosummary:: - :toctree: generated/ - - bifacial.pvfactors_timeseries - - -Scaling -======= - -Methods for manipulating irradiance for temporal or spatial considerations - -.. autosummary:: - :toctree: generated/ - - scaling.wvm From fc37b2d2551e949d81927e267247d5999b85fd76 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Thu, 18 May 2023 20:05:13 +0200 Subject: [PATCH 086/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index dc582b9664..591521917b 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -202,7 +202,7 @@ def test_caballero_spectral_correction(module_type, expected): aods = np.array([1.0, 1.0, 0.02, 0.02, 0.08, 0.08]) pws = np.array([1.42, 1.42, 1.42, 1.42, 4.0, 1.0]) out = atmosphere.caballero_spectral_correction(ams, aods, pws, - module_type=module_type, + module_type=module_type, coefficients=expected, aod500_ref=0.084, pw_ref=1.42) assert np.allclose(expected, out, atol=1e-3) @@ -221,14 +221,14 @@ def test_caballero_spectral_correction_supplied(): def test_caballero_spectral_correction_supplied_ambiguous(): dummy_coeffs = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) - with pytest.raises(TypeError): + with pytest.raises(ValueError): atmosphere.caballero_spectral_correction(1, 1, 1, module_type='cdte', coefficients=dummy_coeffs) def test_caballero_spectral_correction_supplied_ambiguous_1(): - with pytest.raises(TypeError): + with pytest.raises(ValueError): atmosphere.caballero_spectral_correction(1, 1, 1, module_type=None, coefficients=None) From 231129f0da87b6b80dc902057c4f86dcd94ba722 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Thu, 18 May 2023 22:34:33 +0200 Subject: [PATCH 087/103] Update atmosphere.py --- pvlib/atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index dcbfdd2426..6ef5ae8654 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -826,10 +826,10 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, if module_type is None and coefficients is None: raise ValueError('Invalid input provided, both module_type' - +' and coefficients are None') + + ' and coefficients are None') elif module_type is not None and coefficients is None: raise ValueError('Cannot resolve input, providing the' - +' coefficients input is mandatory') + + ' coefficients input is mandatory') else: pass From ce47bf9621fcff3250673ca1471ca916a17a737d Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Thu, 18 May 2023 22:35:22 +0200 Subject: [PATCH 088/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 591521917b..aed4caa108 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -202,7 +202,8 @@ def test_caballero_spectral_correction(module_type, expected): aods = np.array([1.0, 1.0, 0.02, 0.02, 0.08, 0.08]) pws = np.array([1.42, 1.42, 1.42, 1.42, 4.0, 1.0]) out = atmosphere.caballero_spectral_correction(ams, aods, pws, - module_type=module_type, coefficients=expected, + module_type=module_type, + coefficients=expected, aod500_ref=0.084, pw_ref=1.42) assert np.allclose(expected, out, atol=1e-3) From 5acd22c297c7bdd4d3a6592d3fc65526e2648620 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Thu, 18 May 2023 23:14:24 +0200 Subject: [PATCH 089/103] Update atmosphere.py --- pvlib/atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 6ef5ae8654..7b3a439a51 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -826,10 +826,10 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, if module_type is None and coefficients is None: raise ValueError('Invalid input provided, both module_type' - + ' and coefficients are None') + + ' and coefficients are None') elif module_type is not None and coefficients is None: raise ValueError('Cannot resolve input, providing the' - + ' coefficients input is mandatory') + + ' coefficients input is mandatory') else: pass From 91e6726f934c122439e9f0c7e03d8c27be9d0391 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Fri, 19 May 2023 00:25:58 +0200 Subject: [PATCH 090/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 591521917b..03260f330c 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -220,7 +220,7 @@ def test_caballero_spectral_correction_supplied(): def test_caballero_spectral_correction_supplied_ambiguous(): - dummy_coeffs = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) + dummy_coeffs = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) with pytest.raises(ValueError): atmosphere.caballero_spectral_correction(1, 1, 1, module_type='cdte', From 7132f5d85a51904e28836123a036bc0b49b1611c Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Fri, 19 May 2023 00:47:01 +0200 Subject: [PATCH 091/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index dc3e2f1fdc..ce26d3f702 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -221,15 +221,17 @@ def test_caballero_spectral_correction_supplied(): def test_caballero_spectral_correction_supplied_ambiguous(): - dummy_coeffs = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) + dummy_coeffs = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) with pytest.raises(ValueError): atmosphere.caballero_spectral_correction(1, 1, 1, module_type='cdte', - coefficients=dummy_coeffs) + coefficients=dummy_coeffs, + aod500_ref=0.084, pw_ref=1.42) def test_caballero_spectral_correction_supplied_ambiguous_1(): with pytest.raises(ValueError): atmosphere.caballero_spectral_correction(1, 1, 1, module_type=None, - coefficients=None) + coefficients=None, + aod500_ref=0.084, pw_ref=1.42) From ffdd0ba123bab794df7d36873afb0b52825a5daa Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Fri, 19 May 2023 00:59:28 +0200 Subject: [PATCH 092/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index ce26d3f702..6a76ea3e38 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -215,9 +215,11 @@ def test_caballero_spectral_correction_supplied(): 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0, 1) out = atmosphere.caballero_spectral_correction(1, - 1, 1, coefficients=coeffs) - expected = 1.0021964 - assert_allclose(out, expected, atol=1e-3) + 1, 1, module_type='cdte', + coefficients=coeffs, + aod500_ref=0.084, pw_ref=1.42) + Vexpected = 1.0021964 + assert_allclose(out, Vexpected, atol=1e-3) def test_caballero_spectral_correction_supplied_ambiguous(): From af41b570670d9c08e35b70db373bf14603101be6 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Fri, 19 May 2023 01:09:35 +0200 Subject: [PATCH 093/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 6a76ea3e38..76d2603630 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -223,10 +223,10 @@ def test_caballero_spectral_correction_supplied(): def test_caballero_spectral_correction_supplied_ambiguous(): - dummy_coeffs = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + dummy_coeffs = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) with pytest.raises(ValueError): atmosphere.caballero_spectral_correction(1, 1, 1, - module_type='cdte', + module_type=None, coefficients=dummy_coeffs, aod500_ref=0.084, pw_ref=1.42) From 3ad15bb9846a9a5c814316dd596e5f1879f688a4 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Fri, 19 May 2023 01:13:34 +0200 Subject: [PATCH 094/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 76d2603630..1fe450334f 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -232,8 +232,12 @@ def test_caballero_spectral_correction_supplied_ambiguous(): def test_caballero_spectral_correction_supplied_ambiguous_1(): + # use the cdte coeffs + coeffs = ( + 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, + -0.0182, 0, 0.0095, 0.0068, 0, 1) with pytest.raises(ValueError): atmosphere.caballero_spectral_correction(1, 1, 1, module_type=None, - coefficients=None, + coefficients=coeffs, aod500_ref=0.084, pw_ref=1.42) From c314d3c152d2d4b392bc5e8724a30e476cefe124 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Fri, 19 May 2023 01:19:08 +0200 Subject: [PATCH 095/103] Update test_atmosphere.py --- pvlib/tests/test_atmosphere.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index 1fe450334f..ab32bf7076 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -223,21 +223,16 @@ def test_caballero_spectral_correction_supplied(): def test_caballero_spectral_correction_supplied_ambiguous(): - dummy_coeffs = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) with pytest.raises(ValueError): atmosphere.caballero_spectral_correction(1, 1, 1, - module_type=None, - coefficients=dummy_coeffs, + module_type='cdte', + coefficients=None, aod500_ref=0.084, pw_ref=1.42) def test_caballero_spectral_correction_supplied_ambiguous_1(): - # use the cdte coeffs - coeffs = ( - 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, - -0.0182, 0, 0.0095, 0.0068, 0, 1) with pytest.raises(ValueError): atmosphere.caballero_spectral_correction(1, 1, 1, module_type=None, - coefficients=coeffs, + coefficients=None, aod500_ref=0.084, pw_ref=1.42) From b56307bd10070e9c48d104ecd7c7ccf7fe0ace7b Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 19 May 2023 14:29:45 -0400 Subject: [PATCH 096/103] update function logic and get tests working --- pvlib/atmosphere.py | 14 +++++++------- pvlib/tests/test_atmosphere.py | 22 +++++++++++++--------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 7b3a439a51..5ed60b65b5 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -825,16 +825,16 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, 0.0583, -0.0159, 0.01251, 0.0109, 1, 0) if module_type is None and coefficients is None: - raise ValueError('Invalid input provided, both module_type' - + ' and coefficients are None') - elif module_type is not None and coefficients is None: - raise ValueError('Cannot resolve input, providing the' - + ' coefficients input is mandatory') + raise ValueError('Must provide either `module_type` or `coefficients`') + if module_type is not None and coefficients is not None: + raise ValueError('Only one of `module_type` and `coefficients` should ' + 'be provided') + if module_type is not None: + coeff = _coefficients[module_type] else: - pass + coeff = coefficients # Evaluate Spectral Shift - coeff = coefficients ama = airmass_absolute modifier = ( coeff[0] + (ama) * coeff[1] + (ama * ama) * coeff[2] diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index ab32bf7076..fba49aad44 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -203,7 +203,6 @@ def test_caballero_spectral_correction(module_type, expected): pws = np.array([1.42, 1.42, 1.42, 1.42, 4.0, 1.0]) out = atmosphere.caballero_spectral_correction(ams, aods, pws, module_type=module_type, - coefficients=expected, aod500_ref=0.084, pw_ref=1.42) assert np.allclose(expected, out, atol=1e-3) @@ -214,23 +213,28 @@ def test_caballero_spectral_correction_supplied(): coeffs = ( 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0, 1) - out = atmosphere.caballero_spectral_correction(1, - 1, 1, module_type='cdte', + out = atmosphere.caballero_spectral_correction(1, 1, 1, coefficients=coeffs, - aod500_ref=0.084, pw_ref=1.42) - Vexpected = 1.0021964 - assert_allclose(out, Vexpected, atol=1e-3) + aod500_ref=0.084, + pw_ref=1.42) + expected = 1.0021964 + assert_allclose(out, expected, atol=1e-3) -def test_caballero_spectral_correction_supplied_ambiguous(): +def test_caballero_spectral_correction_supplied_redundant(): + # Error when specifying both module_type and coefficients + coeffs = ( + 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, + -0.0182, 0, 0.0095, 0.0068, 0, 1) with pytest.raises(ValueError): atmosphere.caballero_spectral_correction(1, 1, 1, module_type='cdte', - coefficients=None, + coefficients=coeffs, aod500_ref=0.084, pw_ref=1.42) -def test_caballero_spectral_correction_supplied_ambiguous_1(): +def test_caballero_spectral_correction_supplied_ambiguous(): + # Error when specifying neither module_type nor coefficients with pytest.raises(ValueError): atmosphere.caballero_spectral_correction(1, 1, 1, module_type=None, From 8fa44af714d80d50349763bfed7ceb028e52e9f0 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Fri, 19 May 2023 21:14:29 +0200 Subject: [PATCH 097/103] Update atmosphere.py Updated both "TODO" issues. --- pvlib/atmosphere.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 5ed60b65b5..196d56d19f 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -768,10 +768,12 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, pw values are frequently high. aod500_ref : numeric, default 0.084 - TODO: description + atmospheric aerosol optical depth at 500nm value related to the AM1.5G ASTMG-173-03 + reference spectrum. [unitless] pw_ref : numeric, default 1.42 - TODO: description + atmospheric precipitable water value related to the AM1.5G ASTMG-173-03 + reference spectrum. [cm] Returns ------- From cda92be661a7cd5807045c79df89e803c01ccaa1 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Fri, 19 May 2023 21:33:04 +0200 Subject: [PATCH 098/103] Update atmosphere.py --- pvlib/atmosphere.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 196d56d19f..a51843e5a2 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -768,8 +768,8 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, pw values are frequently high. aod500_ref : numeric, default 0.084 - atmospheric aerosol optical depth at 500nm value related to the AM1.5G ASTMG-173-03 - reference spectrum. [unitless] + atmospheric aerosol optical depth at 500nm value related to the + AM1.5G ASTMG-173-03 reference spectrum. [unitless] pw_ref : numeric, default 1.42 atmospheric precipitable water value related to the AM1.5G ASTMG-173-03 From c872a3d26c96650b8665810fcfa831957dbbc7d5 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 23 May 2023 21:21:17 +0200 Subject: [PATCH 099/103] Update v0.9.6.rst Added caballero spectral correction as a new function. --- docs/sphinx/source/whatsnew/v0.9.6.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.6.rst b/docs/sphinx/source/whatsnew/v0.9.6.rst index 7d1271086f..5104ee4c05 100644 --- a/docs/sphinx/source/whatsnew/v0.9.6.rst +++ b/docs/sphinx/source/whatsnew/v0.9.6.rst @@ -11,7 +11,8 @@ Deprecations Enhancements ~~~~~~~~~~~~ - +* `Added a function :py:func:`pvlib.atmosphere.caballero_spectral_correction` to estimate a spectral mismatch modifier based on absolute (pressure-adjusted) + airmass (AM), aerosol optical depth (AOD) at 500 nm and precipitable water (PW). (:pull:`1296`) Bug fixes ~~~~~~~~~ @@ -43,4 +44,5 @@ Contributors * Siddharth Kaul (:ghuser:`k10blogger`) * Kshitiz Gupta (:ghuser:`kshitiz305`) * Stefan de Lange (:ghuser:`langestefan`) +* Jose Antonio Caballero (:ghuser:`Jacc0027`) From 3bb26c4994e2f421f56fb5ea017aaeb613300f98 Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Tue, 23 May 2023 21:26:09 +0200 Subject: [PATCH 100/103] Update airmass_atmospheric.rst Added a new function: atmosphere.caballero_spectral_correction --- docs/sphinx/source/reference/airmass_atmospheric.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sphinx/source/reference/airmass_atmospheric.rst b/docs/sphinx/source/reference/airmass_atmospheric.rst index fbd33a5f28..e5d42aebca 100644 --- a/docs/sphinx/source/reference/airmass_atmospheric.rst +++ b/docs/sphinx/source/reference/airmass_atmospheric.rst @@ -17,3 +17,4 @@ Airmass and atmospheric models atmosphere.kasten96_lt atmosphere.angstrom_aod_at_lambda atmosphere.angstrom_alpha + atmosphere.caballero_spectral_correction From b6a6a08800e47b4e66abe2c4a7c4e0668705a5ff Mon Sep 17 00:00:00 2001 From: Jacc0027 <88579674+Jacc0027@users.noreply.github.com> Date: Wed, 24 May 2023 20:41:25 +0200 Subject: [PATCH 101/103] Update pvlib/atmosphere.py Co-authored-by: Anton Driesse --- pvlib/atmosphere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index a51843e5a2..4b7a4385e1 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -836,7 +836,7 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, else: coeff = coefficients - # Evaluate Spectral Shift + # Evaluate spectral correction factor ama = airmass_absolute modifier = ( coeff[0] + (ama) * coeff[1] + (ama * ama) * coeff[2] From f2292552a73e0fdf60cfdf17f7b76df331bb3f14 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Mon, 12 Jun 2023 09:11:21 -0400 Subject: [PATCH 102/103] rename function and move to pvlib.spectrum following the conventions set out in #1628 --- .../source/reference/airmass_atmospheric.rst | 1 - .../effects_on_pv_system_output/spectrum.rst | 1 + docs/sphinx/source/whatsnew/v0.9.6.rst | 4 +- pvlib/atmosphere.py | 150 ------------------ pvlib/spectrum/__init__.py | 1 + pvlib/spectrum/mismatch.py | 150 ++++++++++++++++++ pvlib/tests/test_atmosphere.py | 53 ------- pvlib/tests/test_spectrum.py | 53 +++++++ 8 files changed, 207 insertions(+), 206 deletions(-) diff --git a/docs/sphinx/source/reference/airmass_atmospheric.rst b/docs/sphinx/source/reference/airmass_atmospheric.rst index e5d42aebca..fbd33a5f28 100644 --- a/docs/sphinx/source/reference/airmass_atmospheric.rst +++ b/docs/sphinx/source/reference/airmass_atmospheric.rst @@ -17,4 +17,3 @@ Airmass and atmospheric models atmosphere.kasten96_lt atmosphere.angstrom_aod_at_lambda atmosphere.angstrom_alpha - atmosphere.caballero_spectral_correction diff --git a/docs/sphinx/source/reference/effects_on_pv_system_output/spectrum.rst b/docs/sphinx/source/reference/effects_on_pv_system_output/spectrum.rst index ed6cdc0b51..8041d8f49b 100644 --- a/docs/sphinx/source/reference/effects_on_pv_system_output/spectrum.rst +++ b/docs/sphinx/source/reference/effects_on_pv_system_output/spectrum.rst @@ -10,5 +10,6 @@ Spectrum spectrum.get_example_spectral_response spectrum.get_am15g spectrum.calc_spectral_mismatch_field + spectrum.spectral_factor_caballero spectrum.spectral_factor_firstsolar spectrum.spectral_factor_sapm diff --git a/docs/sphinx/source/whatsnew/v0.9.6.rst b/docs/sphinx/source/whatsnew/v0.9.6.rst index a625014dc7..e37d5cd9ed 100644 --- a/docs/sphinx/source/whatsnew/v0.9.6.rst +++ b/docs/sphinx/source/whatsnew/v0.9.6.rst @@ -33,8 +33,8 @@ Deprecations Enhancements ~~~~~~~~~~~~ -* `Added a function :py:func:`pvlib.atmosphere.caballero_spectral_correction` to estimate a spectral mismatch modifier based on absolute (pressure-adjusted) - airmass (AM), aerosol optical depth (AOD) at 500 nm and precipitable water (PW). (:pull:`1296`) +* Added a function :py:func:`pvlib.spectrum.spectral_factor_caballero` + to estimate spectral mismatch modifiers from atmospheric conditions. (:pull:`1296`) * Added a new irradiance decomposition model :py:func:`pvlib.irradiance.louche`. (:pull:`1705`) * Add optional encoding parameter to :py:func:`pvlib.iotools.read_tmy3`. (:issue:`1732`, :pull:`1737`) diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 46a3101cd7..08e40b9fc2 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -533,153 +533,3 @@ def angstrom_alpha(aod1, lambda1, aod2, lambda2): pvlib.atmosphere.angstrom_aod_at_lambda """ return - np.log(aod1 / aod2) / np.log(lambda1 / lambda2) - - -def caballero_spectral_correction(airmass_absolute, aod500, pw, - module_type=None, coefficients=None, - aod500_ref=0.084, pw_ref=1.42): - r""" - Spectral mismatch modifier based on absolute (pressure-adjusted) - airmass (AM), aerosol optical depth (AOD) at 500 nm and - precipitable water (PW). - - Estimates a spectral mismatch modifier :math:`M` representing - the effect on module short circuit current of variation in the - spectral irradiance. :math:`M` is estimated from absolute - (pressure-adjusted) AM, :math:`ama`, AOD at 500 nm, :math:`aod500` - and PW, :math:`pw` [1]_. - - The best fit polynomial for each atmospheric parameter (AM, AOD, PW) - and PV technology under study has been obtained from synthetic spectra - generated with SMARTS [2]_, considering the following boundary - conditions: - - * :math:`1.0 <= ama <= 5.0` - * :math:`0.05 <= aod500 <= 0.6` - * :math:`0.25 \textrm{cm} <= pw <= 4 \textrm{cm}` - * Spectral range is limited to that of CMP11 (280 nm to 2800 nm) - * All other parameters fixed at G173 standard - - Elevation (deg), AOD and PW data were recorded in the city of Jaén, - Spain for one year synchronously with both, broadband and - spectroradiometric measurements of 30º tilted global irradiance - south-facing logged in 5-min intervals. AM was estimated through - elevation data. - - Finally, the spectral mismatch factor was calculated for each - of the PV technologies and a multivariable regression adjustment - as a function of AM, AOD and PW was performed according to [3] and [1]_. - As such, the polynomial adjustment coefficients included in [1] - were obtained. - - - Parameters - ---------- - airmass_absolute : array-like - absolute (pressure-adjusted) airmass. [unitless] - - aod500 : array-like - atmospheric aerosol optical depth at 500 nm. [unitless] - - pw : array-like - atmospheric precipitable water. [cm] - - module_type : None or string, default None - a string specifying a cell type. Values of 'cdte', 'monosi', 'cigs', - 'multisi','asi' and 'perovskite'. If provided, - module_type selects default coefficients for the following modules: - - * 'cdte' - anonymous CdTe module. - * 'monosi', - anonymous sc-si module. - * 'multisi', - anonymous mc-si- module. - * 'cigs' - anonymous copper indium gallium selenide module. - * 'asi' - anonymous amorphous silicon module. - * 'perovskite' - anonymous pervoskite module. - - coefficients : None or array-like, optional - the coefficients employed have been obtained with experimental - data in the city of Jaén, Spain. It is pending to verify if such - coefficients vary in places with extreme climates where AOD and - pw values are frequently high. - - aod500_ref : numeric, default 0.084 - atmospheric aerosol optical depth at 500nm value related to the - AM1.5G ASTMG-173-03 reference spectrum. [unitless] - - pw_ref : numeric, default 1.42 - atmospheric precipitable water value related to the AM1.5G ASTMG-173-03 - reference spectrum. [cm] - - Returns - ------- - modifier: array-like - spectral mismatch factor (unitless) which is can be multiplied - with broadband irradiance reaching a module's cells to estimate - effective irradiance, i.e., the irradiance that is converted to - electrical current. - - References - ---------- - .. [1] Caballero, J.A., Fernández, E., Theristis, M., - Almonacid, F., and Nofuentes, G. "Spectral Corrections Based on - Air Mass, Aerosol Optical Depth and Precipitable Water - for PV Performance Modeling." - IEEE Journal of Photovoltaics 2018, 8(2), 552-558. - https://doi.org/10.1109/jphotov.2017.2787019 - .. [2] Gueymard, Christian. SMARTS2: a simple model of the - atmospheric radiative transfer of sunshine: algorithms - and performance assessment. Cocoa, FL: - Florida Solar Energy Center, 1995. - .. [3] Theristis, M., Fernández, E., Almonacid, F., and - Pérez-Higueras, Pedro. "Spectral Corrections Based - on Air Mass, Aerosol Optical Depth and Precipitable - Water for CPV Performance Modeling." - IEEE Journal of Photovoltaics 2016, 6(6), 1598-1604. - https://doi.org/10.1109/jphotov.2016.2606702 - - """ - - # Experimental coefficients - - _coefficients = {} - _coefficients['cdte'] = ( - 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, - -0.0182, 0, 0.0095, 0.0068, 0, 1) - _coefficients['monosi'] = ( - 0.9706, 0.0377, -0.0123, 0.0025, -0.0002, 0.0159, - -0.0165, 0, -0.0016, -0.0027, 1, 0) - _coefficients['multisi'] = ( - 0.9836, 0.0254, -0.0085, 0.0016, -0.0001, 0.0094, - -0.0132, 0, -0.0002, -0.0011, 1, 0) - _coefficients['cigs'] = ( - 0.9801, 0.0283, -0.0092, 0.0019, -0.0001, 0.0117, - -0.0126, 0, -0.0011, -0.0019, 1, 0) - _coefficients['asi'] = ( - 1.1060, -0.0848, 0.0302, -0.0076, 0.0006, -0.1283, - 0.0986, -0.0254, 0.0156, 0.0146, 1, 0) - _coefficients['perovskite'] = ( - 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, - 0.0583, -0.0159, 0.01251, 0.0109, 1, 0) - - if module_type is None and coefficients is None: - raise ValueError('Must provide either `module_type` or `coefficients`') - if module_type is not None and coefficients is not None: - raise ValueError('Only one of `module_type` and `coefficients` should ' - 'be provided') - if module_type is not None: - coeff = _coefficients[module_type] - else: - coeff = coefficients - - # Evaluate spectral correction factor - ama = airmass_absolute - modifier = ( - coeff[0] + (ama) * coeff[1] + (ama * ama) * coeff[2] - + (ama * ama * ama) * coeff[3] + (ama * ama * ama * ama) * coeff[4] - + (aod500 - aod500_ref) * coeff[5] - + ((aod500 - aod500_ref) * (ama) * coeff[6]) * coeff[10] - + ((aod500 - aod500_ref) * (np.log(ama)) * coeff[6]) * coeff[11] - + (aod500 - aod500_ref) * (ama * ama) * coeff[7] - + (pw - pw_ref) * coeff[8] + (pw - pw_ref) * (np.log(ama)) * coeff[9]) - - return modifier diff --git a/pvlib/spectrum/__init__.py b/pvlib/spectrum/__init__.py index 70d3918b49..6c97df978e 100644 --- a/pvlib/spectrum/__init__.py +++ b/pvlib/spectrum/__init__.py @@ -3,6 +3,7 @@ calc_spectral_mismatch_field, get_am15g, get_example_spectral_response, + spectral_factor_caballero, spectral_factor_firstsolar, spectral_factor_sapm, ) diff --git a/pvlib/spectrum/mismatch.py b/pvlib/spectrum/mismatch.py index a7e7cf0851..1e2cea20c6 100644 --- a/pvlib/spectrum/mismatch.py +++ b/pvlib/spectrum/mismatch.py @@ -446,3 +446,153 @@ def spectral_factor_sapm(airmass_absolute, module): spectral_loss = pd.Series(spectral_loss, airmass_absolute.index) return spectral_loss + + +def caballero_spectral_correction(airmass_absolute, aod500, pw, + module_type=None, coefficients=None, + aod500_ref=0.084, pw_ref=1.42): + r""" + Spectral mismatch modifier based on absolute (pressure-adjusted) + airmass (AM), aerosol optical depth (AOD) at 500 nm and + precipitable water (PW). + + Estimates a spectral mismatch modifier :math:`M` representing + the effect on module short circuit current of variation in the + spectral irradiance. :math:`M` is estimated from absolute + (pressure-adjusted) AM, :math:`ama`, AOD at 500 nm, :math:`aod500` + and PW, :math:`pw` [1]_. + + The best fit polynomial for each atmospheric parameter (AM, AOD, PW) + and PV technology under study has been obtained from synthetic spectra + generated with SMARTS [2]_, considering the following boundary + conditions: + + * :math:`1.0 <= ama <= 5.0` + * :math:`0.05 <= aod500 <= 0.6` + * :math:`0.25 \textrm{cm} <= pw <= 4 \textrm{cm}` + * Spectral range is limited to that of CMP11 (280 nm to 2800 nm) + * All other parameters fixed at G173 standard + + Elevation (deg), AOD and PW data were recorded in the city of Jaén, + Spain for one year synchronously with both, broadband and + spectroradiometric measurements of 30º tilted global irradiance + south-facing logged in 5-min intervals. AM was estimated through + elevation data. + + Finally, the spectral mismatch factor was calculated for each + of the PV technologies and a multivariable regression adjustment + as a function of AM, AOD and PW was performed according to [3] and [1]_. + As such, the polynomial adjustment coefficients included in [1] + were obtained. + + + Parameters + ---------- + airmass_absolute : array-like + absolute (pressure-adjusted) airmass. [unitless] + + aod500 : array-like + atmospheric aerosol optical depth at 500 nm. [unitless] + + pw : array-like + atmospheric precipitable water. [cm] + + module_type : None or string, default None + a string specifying a cell type. Values of 'cdte', 'monosi', 'cigs', + 'multisi','asi' and 'perovskite'. If provided, + module_type selects default coefficients for the following modules: + + * 'cdte' - anonymous CdTe module. + * 'monosi', - anonymous sc-si module. + * 'multisi', - anonymous mc-si- module. + * 'cigs' - anonymous copper indium gallium selenide module. + * 'asi' - anonymous amorphous silicon module. + * 'perovskite' - anonymous pervoskite module. + + coefficients : None or array-like, optional + the coefficients employed have been obtained with experimental + data in the city of Jaén, Spain. It is pending to verify if such + coefficients vary in places with extreme climates where AOD and + pw values are frequently high. + + aod500_ref : numeric, default 0.084 + atmospheric aerosol optical depth at 500nm value related to the + AM1.5G ASTMG-173-03 reference spectrum. [unitless] + + pw_ref : numeric, default 1.42 + atmospheric precipitable water value related to the AM1.5G ASTMG-173-03 + reference spectrum. [cm] + + Returns + ------- + modifier: array-like + spectral mismatch factor (unitless) which is can be multiplied + with broadband irradiance reaching a module's cells to estimate + effective irradiance, i.e., the irradiance that is converted to + electrical current. + + References + ---------- + .. [1] Caballero, J.A., Fernández, E., Theristis, M., + Almonacid, F., and Nofuentes, G. "Spectral Corrections Based on + Air Mass, Aerosol Optical Depth and Precipitable Water + for PV Performance Modeling." + IEEE Journal of Photovoltaics 2018, 8(2), 552-558. + https://doi.org/10.1109/jphotov.2017.2787019 + .. [2] Gueymard, Christian. SMARTS2: a simple model of the + atmospheric radiative transfer of sunshine: algorithms + and performance assessment. Cocoa, FL: + Florida Solar Energy Center, 1995. + .. [3] Theristis, M., Fernández, E., Almonacid, F., and + Pérez-Higueras, Pedro. "Spectral Corrections Based + on Air Mass, Aerosol Optical Depth and Precipitable + Water for CPV Performance Modeling." + IEEE Journal of Photovoltaics 2016, 6(6), 1598-1604. + https://doi.org/10.1109/jphotov.2016.2606702 + + """ + + # Experimental coefficients + + _coefficients = {} + _coefficients['cdte'] = ( + 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, + -0.0182, 0, 0.0095, 0.0068, 0, 1) + _coefficients['monosi'] = ( + 0.9706, 0.0377, -0.0123, 0.0025, -0.0002, 0.0159, + -0.0165, 0, -0.0016, -0.0027, 1, 0) + _coefficients['multisi'] = ( + 0.9836, 0.0254, -0.0085, 0.0016, -0.0001, 0.0094, + -0.0132, 0, -0.0002, -0.0011, 1, 0) + _coefficients['cigs'] = ( + 0.9801, 0.0283, -0.0092, 0.0019, -0.0001, 0.0117, + -0.0126, 0, -0.0011, -0.0019, 1, 0) + _coefficients['asi'] = ( + 1.1060, -0.0848, 0.0302, -0.0076, 0.0006, -0.1283, + 0.0986, -0.0254, 0.0156, 0.0146, 1, 0) + _coefficients['perovskite'] = ( + 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, + 0.0583, -0.0159, 0.01251, 0.0109, 1, 0) + + if module_type is None and coefficients is None: + raise ValueError('Must provide either `module_type` or `coefficients`') + if module_type is not None and coefficients is not None: + raise ValueError('Only one of `module_type` and `coefficients` should ' + 'be provided') + if module_type is not None: + coeff = _coefficients[module_type] + else: + coeff = coefficients + + # Evaluate spectral correction factor + ama = airmass_absolute + modifier = ( + coeff[0] + (ama) * coeff[1] + (ama * ama) * coeff[2] + + (ama * ama * ama) * coeff[3] + (ama * ama * ama * ama) * coeff[4] + + (aod500 - aod500_ref) * coeff[5] + + ((aod500 - aod500_ref) * (ama) * coeff[6]) * coeff[10] + + ((aod500 - aod500_ref) * (np.log(ama)) * coeff[6]) * coeff[11] + + (aod500 - aod500_ref) * (ama * ama) * coeff[7] + + (pw - pw_ref) * coeff[8] + (pw - pw_ref) * (np.log(ama)) * coeff[9]) + + return modifier diff --git a/pvlib/tests/test_atmosphere.py b/pvlib/tests/test_atmosphere.py index a2386ba4f1..46db622ee5 100644 --- a/pvlib/tests/test_atmosphere.py +++ b/pvlib/tests/test_atmosphere.py @@ -131,56 +131,3 @@ def test_bird_hulstrom80_aod_bb(): aod380, aod500 = 0.22072480948195175, 0.1614279181106312 bird_hulstrom = atmosphere.bird_hulstrom80_aod_bb(aod380, aod500) assert np.isclose(0.11738229553812768, bird_hulstrom) - - -@pytest.mark.parametrize("module_type,expected", [ - ('asi', np.array([0.9108, 0.9897, 0.9707, 1.0265, 1.0798, 0.9537])), - ('perovskite', np.array([0.9422, 0.9932, 0.9868, 1.0183, 1.0604, 0.9737])), - ('cdte', np.array([0.9824, 1.0000, 1.0065, 1.0117, 1.042, 0.9979])), - ('multisi', np.array([0.9907, 0.9979, 1.0203, 1.0081, 1.0058, 1.019])), - ('monosi', np.array([0.9935, 0.9987, 1.0264, 1.0074, 0.9999, 1.0263])), - ('cigs', np.array([1.0014, 1.0011, 1.0270, 1.0082, 1.0029, 1.026])), -]) -def test_caballero_spectral_correction(module_type, expected): - ams = np.array([3.0, 1.5, 3.0, 1.5, 1.5, 3.0]) - aods = np.array([1.0, 1.0, 0.02, 0.02, 0.08, 0.08]) - pws = np.array([1.42, 1.42, 1.42, 1.42, 4.0, 1.0]) - out = atmosphere.caballero_spectral_correction(ams, aods, pws, - module_type=module_type, - aod500_ref=0.084, - pw_ref=1.42) - assert np.allclose(expected, out, atol=1e-3) - - -def test_caballero_spectral_correction_supplied(): - # use the cdte coeffs - coeffs = ( - 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, - -0.0182, 0, 0.0095, 0.0068, 0, 1) - out = atmosphere.caballero_spectral_correction(1, 1, 1, - coefficients=coeffs, - aod500_ref=0.084, - pw_ref=1.42) - expected = 1.0021964 - assert_allclose(out, expected, atol=1e-3) - - -def test_caballero_spectral_correction_supplied_redundant(): - # Error when specifying both module_type and coefficients - coeffs = ( - 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, - -0.0182, 0, 0.0095, 0.0068, 0, 1) - with pytest.raises(ValueError): - atmosphere.caballero_spectral_correction(1, 1, 1, - module_type='cdte', - coefficients=coeffs, - aod500_ref=0.084, pw_ref=1.42) - - -def test_caballero_spectral_correction_supplied_ambiguous(): - # Error when specifying neither module_type nor coefficients - with pytest.raises(ValueError): - atmosphere.caballero_spectral_correction(1, 1, 1, - module_type=None, - coefficients=None, - aod500_ref=0.084, pw_ref=1.42) diff --git a/pvlib/tests/test_spectrum.py b/pvlib/tests/test_spectrum.py index 444e45733c..74ee6f35a2 100644 --- a/pvlib/tests/test_spectrum.py +++ b/pvlib/tests/test_spectrum.py @@ -269,3 +269,56 @@ def test_spectral_factor_sapm(sapm_module_params, airmass, expected): assert_series_equal(out, expected, check_less_precise=4) else: assert_allclose(out, expected, atol=1e-4) + + +@pytest.mark.parametrize("module_type,expected", [ + ('asi', np.array([0.9108, 0.9897, 0.9707, 1.0265, 1.0798, 0.9537])), + ('perovskite', np.array([0.9422, 0.9932, 0.9868, 1.0183, 1.0604, 0.9737])), + ('cdte', np.array([0.9824, 1.0000, 1.0065, 1.0117, 1.042, 0.9979])), + ('multisi', np.array([0.9907, 0.9979, 1.0203, 1.0081, 1.0058, 1.019])), + ('monosi', np.array([0.9935, 0.9987, 1.0264, 1.0074, 0.9999, 1.0263])), + ('cigs', np.array([1.0014, 1.0011, 1.0270, 1.0082, 1.0029, 1.026])), +]) +def test_spectral_factor_caballero(module_type, expected): + ams = np.array([3.0, 1.5, 3.0, 1.5, 1.5, 3.0]) + aods = np.array([1.0, 1.0, 0.02, 0.02, 0.08, 0.08]) + pws = np.array([1.42, 1.42, 1.42, 1.42, 4.0, 1.0]) + out = spectrum.spectral_factor_caballero(ams, aods, pws, + module_type=module_type, + aod500_ref=0.084, + pw_ref=1.42) + assert np.allclose(expected, out, atol=1e-3) + + +def test_spectral_factor_caballero_supplied(): + # use the cdte coeffs + coeffs = ( + 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, + -0.0182, 0, 0.0095, 0.0068, 0, 1) + out = spectrum.spectral_factor_caballero(1, 1, 1, + coefficients=coeffs, + aod500_ref=0.084, + pw_ref=1.42) + expected = 1.0021964 + assert_allclose(out, expected, atol=1e-3) + + +def test_spectral_factor_caballero_supplied_redundant(): + # Error when specifying both module_type and coefficients + coeffs = ( + 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, + -0.0182, 0, 0.0095, 0.0068, 0, 1) + with pytest.raises(ValueError): + spectrum.spectral_factor_caballero(1, 1, 1, + module_type='cdte', + coefficients=coeffs, + aod500_ref=0.084, pw_ref=1.42) + + +def test_spectral_factor_caballero_supplied_ambiguous(): + # Error when specifying neither module_type nor coefficients + with pytest.raises(ValueError): + spectrum.spectral_factor_caballero(1, 1, 1, + module_type=None, + coefficients=None, + aod500_ref=0.084, pw_ref=1.42) From 4ac3a89f95acba6fefc97fb22f0c2d8d5d60784a Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Mon, 12 Jun 2023 10:52:37 -0400 Subject: [PATCH 103/103] misc cleanup - reorder and rename parameters to match #1768 - remove reference parameters - shorten/simplify docstring - restructure calculation to be more readable --- pvlib/spectrum/mismatch.py | 162 ++++++++++++++--------------------- pvlib/tests/test_spectrum.py | 23 ++--- 2 files changed, 73 insertions(+), 112 deletions(-) diff --git a/pvlib/spectrum/mismatch.py b/pvlib/spectrum/mismatch.py index 1e2cea20c6..eeb14f71c3 100644 --- a/pvlib/spectrum/mismatch.py +++ b/pvlib/spectrum/mismatch.py @@ -320,7 +320,7 @@ def spectral_factor_firstsolar(pw, airmass_absolute, module_type=None, Returns ------- modifier: array-like - spectral mismatch factor (unitless) which is can be multiplied + spectral mismatch factor (unitless) which is multiplied with broadband irradiance reaching a module's cells to estimate effective irradiance, i.e., the irradiance that is converted to electrical current. @@ -448,85 +448,50 @@ def spectral_factor_sapm(airmass_absolute, module): return spectral_loss -def caballero_spectral_correction(airmass_absolute, aod500, pw, - module_type=None, coefficients=None, - aod500_ref=0.084, pw_ref=1.42): +def spectral_factor_caballero(precipitable_water, airmass_absolute, aod500, + module_type=None, coefficients=None): r""" - Spectral mismatch modifier based on absolute (pressure-adjusted) - airmass (AM), aerosol optical depth (AOD) at 500 nm and - precipitable water (PW). - - Estimates a spectral mismatch modifier :math:`M` representing - the effect on module short circuit current of variation in the - spectral irradiance. :math:`M` is estimated from absolute - (pressure-adjusted) AM, :math:`ama`, AOD at 500 nm, :math:`aod500` - and PW, :math:`pw` [1]_. - - The best fit polynomial for each atmospheric parameter (AM, AOD, PW) - and PV technology under study has been obtained from synthetic spectra - generated with SMARTS [2]_, considering the following boundary - conditions: - - * :math:`1.0 <= ama <= 5.0` - * :math:`0.05 <= aod500 <= 0.6` - * :math:`0.25 \textrm{cm} <= pw <= 4 \textrm{cm}` - * Spectral range is limited to that of CMP11 (280 nm to 2800 nm) - * All other parameters fixed at G173 standard - - Elevation (deg), AOD and PW data were recorded in the city of Jaén, - Spain for one year synchronously with both, broadband and - spectroradiometric measurements of 30º tilted global irradiance - south-facing logged in 5-min intervals. AM was estimated through - elevation data. - - Finally, the spectral mismatch factor was calculated for each - of the PV technologies and a multivariable regression adjustment - as a function of AM, AOD and PW was performed according to [3] and [1]_. - As such, the polynomial adjustment coefficients included in [1] - were obtained. - + Estimate a technology-specific spectral mismatch modifier from + airmass, aerosol optical depth, and atmospheric precipitable water, + using the Caballero model. + + The model structure was motivated by examining the effect of these three + atmospheric parameters on simulated irradiance spectra and spectral + modifiers. However, the coefficient values reported in [1]_ and + available here via the ``module_type`` parameter were determined + by fitting the model equations to spectral factors calculated from + global tilted spectral irradiance measurements taken in the city of + Jaén, Spain. See [1]_ for details. Parameters ---------- - airmass_absolute : array-like - absolute (pressure-adjusted) airmass. [unitless] - - aod500 : array-like - atmospheric aerosol optical depth at 500 nm. [unitless] - - pw : array-like + precipitable_water : numeric atmospheric precipitable water. [cm] - module_type : None or string, default None - a string specifying a cell type. Values of 'cdte', 'monosi', 'cigs', - 'multisi','asi' and 'perovskite'. If provided, - module_type selects default coefficients for the following modules: + airmass_absolute : numeric + absolute (pressure-adjusted) airmass. [unitless] - * 'cdte' - anonymous CdTe module. - * 'monosi', - anonymous sc-si module. - * 'multisi', - anonymous mc-si- module. - * 'cigs' - anonymous copper indium gallium selenide module. - * 'asi' - anonymous amorphous silicon module. - * 'perovskite' - anonymous pervoskite module. + aod500 : numeric + atmospheric aerosol optical depth at 500 nm. [unitless] - coefficients : None or array-like, optional - the coefficients employed have been obtained with experimental - data in the city of Jaén, Spain. It is pending to verify if such - coefficients vary in places with extreme climates where AOD and - pw values are frequently high. + module_type : str, optional + One of the following PV technology strings from [1]_: - aod500_ref : numeric, default 0.084 - atmospheric aerosol optical depth at 500nm value related to the - AM1.5G ASTMG-173-03 reference spectrum. [unitless] + * ``'cdte'`` - anonymous CdTe module. + * ``'monosi'``, - anonymous sc-si module. + * ``'multisi'``, - anonymous mc-si- module. + * ``'cigs'`` - anonymous copper indium gallium selenide module. + * ``'asi'`` - anonymous amorphous silicon module. + * ``'perovskite'`` - anonymous pervoskite module. - pw_ref : numeric, default 1.42 - atmospheric precipitable water value related to the AM1.5G ASTMG-173-03 - reference spectrum. [cm] + coefficients : array-like, optional + user-defined coefficients, if not using one of the default coefficient + sets via the ``module_type`` parameter. Returns ------- - modifier: array-like - spectral mismatch factor (unitless) which is can be multiplied + modifier: numeric + spectral mismatch factor (unitless) which is multiplied with broadband irradiance reaching a module's cells to estimate effective irradiance, i.e., the irradiance that is converted to electrical current. @@ -538,22 +503,18 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, Air Mass, Aerosol Optical Depth and Precipitable Water for PV Performance Modeling." IEEE Journal of Photovoltaics 2018, 8(2), 552-558. - https://doi.org/10.1109/jphotov.2017.2787019 - .. [2] Gueymard, Christian. SMARTS2: a simple model of the - atmospheric radiative transfer of sunshine: algorithms - and performance assessment. Cocoa, FL: - Florida Solar Energy Center, 1995. - .. [3] Theristis, M., Fernández, E., Almonacid, F., and - Pérez-Higueras, Pedro. "Spectral Corrections Based - on Air Mass, Aerosol Optical Depth and Precipitable - Water for CPV Performance Modeling." - IEEE Journal of Photovoltaics 2016, 6(6), 1598-1604. - https://doi.org/10.1109/jphotov.2016.2606702 - - """ - - # Experimental coefficients + :doi:`10.1109/jphotov.2017.2787019` + """ + + if module_type is None and coefficients is None: + raise ValueError('Must provide either `module_type` or `coefficients`') + if module_type is not None and coefficients is not None: + raise ValueError('Only one of `module_type` and `coefficients` should ' + 'be provided') + # Experimental coefficients from [1]_. + # The extra 0/1 coefficients at the end are used to enable/disable + # terms to match the different equation forms in Table 1. _coefficients = {} _coefficients['cdte'] = ( 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, @@ -574,11 +535,6 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, 1.0637, -0.0491, 0.0180, -0.0047, 0.0004, -0.0773, 0.0583, -0.0159, 0.01251, 0.0109, 1, 0) - if module_type is None and coefficients is None: - raise ValueError('Must provide either `module_type` or `coefficients`') - if module_type is not None and coefficients is not None: - raise ValueError('Only one of `module_type` and `coefficients` should ' - 'be provided') if module_type is not None: coeff = _coefficients[module_type] else: @@ -586,13 +542,27 @@ def caballero_spectral_correction(airmass_absolute, aod500, pw, # Evaluate spectral correction factor ama = airmass_absolute - modifier = ( - coeff[0] + (ama) * coeff[1] + (ama * ama) * coeff[2] - + (ama * ama * ama) * coeff[3] + (ama * ama * ama * ama) * coeff[4] - + (aod500 - aod500_ref) * coeff[5] - + ((aod500 - aod500_ref) * (ama) * coeff[6]) * coeff[10] - + ((aod500 - aod500_ref) * (np.log(ama)) * coeff[6]) * coeff[11] - + (aod500 - aod500_ref) * (ama * ama) * coeff[7] - + (pw - pw_ref) * coeff[8] + (pw - pw_ref) * (np.log(ama)) * coeff[9]) - + aod500_ref = 0.084 + pw_ref = 1.4164 + + f_AM = ( + coeff[0] + + coeff[1] * ama + + coeff[2] * ama**2 + + coeff[3] * ama**3 + + coeff[4] * ama**4 + ) + # Eq 6, with Table 1 + f_AOD = (aod500 - aod500_ref) * ( + coeff[5] + + coeff[10] * coeff[6] * ama + + coeff[11] * coeff[6] * np.log(ama) + + coeff[7] * ama**2 + ) + # Eq 7, with Table 1 + f_PW = (precipitable_water - pw_ref) * ( + coeff[8] + + coeff[9] * np.log(ama) + ) + modifier = f_AM + f_AOD + f_PW # Eq 5 return modifier diff --git a/pvlib/tests/test_spectrum.py b/pvlib/tests/test_spectrum.py index 74ee6f35a2..47a7ebc691 100644 --- a/pvlib/tests/test_spectrum.py +++ b/pvlib/tests/test_spectrum.py @@ -283,10 +283,8 @@ def test_spectral_factor_caballero(module_type, expected): ams = np.array([3.0, 1.5, 3.0, 1.5, 1.5, 3.0]) aods = np.array([1.0, 1.0, 0.02, 0.02, 0.08, 0.08]) pws = np.array([1.42, 1.42, 1.42, 1.42, 4.0, 1.0]) - out = spectrum.spectral_factor_caballero(ams, aods, pws, - module_type=module_type, - aod500_ref=0.084, - pw_ref=1.42) + out = spectrum.spectral_factor_caballero(pws, ams, aods, + module_type=module_type) assert np.allclose(expected, out, atol=1e-3) @@ -295,10 +293,7 @@ def test_spectral_factor_caballero_supplied(): coeffs = ( 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0, 1) - out = spectrum.spectral_factor_caballero(1, 1, 1, - coefficients=coeffs, - aod500_ref=0.084, - pw_ref=1.42) + out = spectrum.spectral_factor_caballero(1, 1, 1, coefficients=coeffs) expected = 1.0021964 assert_allclose(out, expected, atol=1e-3) @@ -309,16 +304,12 @@ def test_spectral_factor_caballero_supplied_redundant(): 1.0044, 0.0095, -0.0037, 0.0002, 0.0000, -0.0046, -0.0182, 0, 0.0095, 0.0068, 0, 1) with pytest.raises(ValueError): - spectrum.spectral_factor_caballero(1, 1, 1, - module_type='cdte', - coefficients=coeffs, - aod500_ref=0.084, pw_ref=1.42) + spectrum.spectral_factor_caballero(1, 1, 1, module_type='cdte', + coefficients=coeffs) def test_spectral_factor_caballero_supplied_ambiguous(): # Error when specifying neither module_type nor coefficients with pytest.raises(ValueError): - spectrum.spectral_factor_caballero(1, 1, 1, - module_type=None, - coefficients=None, - aod500_ref=0.084, pw_ref=1.42) + spectrum.spectral_factor_caballero(1, 1, 1, module_type=None, + coefficients=None)