Skip to content

Commit 4462609

Browse files
RDaxiniechedey-lskandersolar
authored
Adopt ghi_clear variable name for clearsky GHI (#2306)
* non-breaking: clearsky_ghi -> ghi_clear * breaking: clearsky_ghi & ghi_clearsky -> ghi_clear * *_test_not_working_* * Apply suggestions from code review Co-authored-by: Echedey Luis <[email protected]> * change all variables * Update pvlib/tests/test_irradiance.py Co-authored-by: Echedey Luis <[email protected]> * dirindex deprecation test * Update pvlib/tests/test_irradiance.py Co-authored-by: Echedey Luis <[email protected]> * add @fail_on_pvlib_version("0.12") decorator * Update test_irradiance.py * correct version number * Update irradiance.py * 0.12->0.13 in test_irradiance.py * Update v0.11.2.rst * Update pvlib/tests/test_irradiance.py Co-authored-by: Echedey Luis <[email protected]> * indents * add missing .. versionchanged:: * refine test * Update pvlib/irradiance.py Co-authored-by: Kevin Anderson <[email protected]> * Update irradiance.py --------- Co-authored-by: Echedey Luis <[email protected]> Co-authored-by: Kevin Anderson <[email protected]>
1 parent 0604d9b commit 4462609

File tree

4 files changed

+52
-12
lines changed

4 files changed

+52
-12
lines changed

docs/sphinx/source/whatsnew/v0.11.2.rst

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Deprecations
99
* Deprecated terms ``dni_clearsky`` and ``clearsky_dni``, replaced with ``dni_clear``.
1010
Affected functions are :py:func:`~pvlib.irradiance.dirindex` and :py:func:`~pvlib.irradiance.dni`.
1111
(:issue:`2272`, :pull:`2274`)
12+
* Deprecated term ``ghi_clearsky``, replaced with ``ghi_clear``.
13+
Affected functions are :py:func:`~pvlib.irradiance.dirindex` and :py:func:`~pvlib.irradiance.clearsky_index`.
14+
(:issue:`2272`, :pull:`2306`)
1215

1316

1417
Enhancements

pvlib/clearsky.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,13 @@ def haurwitz(apparent_zenith):
327327
'''
328328

329329
cos_zenith = tools.cosd(apparent_zenith.values)
330-
clearsky_ghi = np.zeros_like(apparent_zenith.values)
330+
ghi_clear = np.zeros_like(apparent_zenith.values)
331331
cos_zen_gte_0 = cos_zenith > 0
332-
clearsky_ghi[cos_zen_gte_0] = (1098.0 * cos_zenith[cos_zen_gte_0] *
333-
np.exp(-0.059/cos_zenith[cos_zen_gte_0]))
332+
ghi_clear[cos_zen_gte_0] = (1098.0 * cos_zenith[cos_zen_gte_0] *
333+
np.exp(-0.059/cos_zenith[cos_zen_gte_0]))
334334

335335
df_out = pd.DataFrame(index=apparent_zenith.index,
336-
data=clearsky_ghi,
336+
data=ghi_clear,
337337
columns=['ghi'])
338338

339339
return df_out

pvlib/irradiance.py

+24-8
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,12 @@ def ghi_from_poa_driesse_2023(surface_tilt, surface_azimuth,
16141614
return ghi
16151615

16161616

1617-
def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0):
1617+
@renamed_kwarg_warning(
1618+
since='0.11.2',
1619+
old_param_name='clearsky_ghi',
1620+
new_param_name='ghi_clear',
1621+
removal="0.13.0")
1622+
def clearsky_index(ghi, ghi_clear, max_clearsky_index=2.0):
16181623
"""
16191624
Calculate the clearsky index.
16201625
@@ -1626,9 +1631,12 @@ def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0):
16261631
ghi : numeric
16271632
Global horizontal irradiance. [Wm⁻²]
16281633
1629-
clearsky_ghi : numeric
1634+
ghi_clear : numeric
16301635
Modeled clearsky GHI
16311636
1637+
.. versionchanged:: 0.11.2
1638+
Renamed from ``ghi_clearsky`` to ``ghi_clear``.
1639+
16321640
max_clearsky_index : numeric, default 2.0
16331641
Maximum value of the clearsky index. The default, 2.0, allows
16341642
for over-irradiance events typically seen in sub-hourly data.
@@ -1638,12 +1646,12 @@ def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0):
16381646
clearsky_index : numeric
16391647
Clearsky index
16401648
"""
1641-
clearsky_index = ghi / clearsky_ghi
1649+
clearsky_index = ghi / ghi_clear
16421650
# set +inf, -inf, and nans to zero
16431651
clearsky_index = np.where(~np.isfinite(clearsky_index), 0,
16441652
clearsky_index)
16451653
# but preserve nans in the input arrays
1646-
input_is_nan = ~np.isfinite(ghi) | ~np.isfinite(clearsky_ghi)
1654+
input_is_nan = ~np.isfinite(ghi) | ~np.isfinite(ghi_clear)
16471655
clearsky_index = np.where(input_is_nan, np.nan, clearsky_index)
16481656

16491657
clearsky_index = np.maximum(clearsky_index, 0)
@@ -2151,20 +2159,25 @@ def _dirint_bins(times, kt_prime, zenith, w, delta_kt_prime):
21512159
return kt_prime_bin, zenith_bin, w_bin, delta_kt_prime_bin
21522160

21532161

2162+
@renamed_kwarg_warning(
2163+
since='0.11.2',
2164+
old_param_name='ghi_clearsky',
2165+
new_param_name='ghi_clear',
2166+
removal="0.13.0")
21542167
@renamed_kwarg_warning(
21552168
since='0.11.2',
21562169
old_param_name='dni_clearsky',
21572170
new_param_name='dni_clear',
21582171
removal="0.13.0")
2159-
def dirindex(ghi, ghi_clearsky, dni_clear, zenith, times, pressure=101325.,
2172+
def dirindex(ghi, ghi_clear, dni_clear, zenith, times, pressure=101325.,
21602173
use_delta_kt_prime=True, temp_dew=None, min_cos_zenith=0.065,
21612174
max_zenith=87):
21622175
"""
21632176
Determine DNI from GHI using the DIRINDEX model.
21642177
21652178
The DIRINDEX model [1]_ modifies the DIRINT model implemented in
21662179
:py:func:`pvlib.irradiance.dirint` by taking into account information
2167-
from a clear sky model. It is recommended that ``ghi_clearsky`` be
2180+
from a clear sky model. It is recommended that ``ghi_clear`` be
21682181
calculated using the Ineichen clear sky model
21692182
:py:func:`pvlib.clearsky.ineichen` with ``perez_enhancement=True``.
21702183
@@ -2175,9 +2188,12 @@ def dirindex(ghi, ghi_clearsky, dni_clear, zenith, times, pressure=101325.,
21752188
ghi : array-like
21762189
Global horizontal irradiance. [Wm⁻²]
21772190
2178-
ghi_clearsky : array-like
2191+
ghi_clear : array-like
21792192
Global horizontal irradiance from clear sky model. [Wm⁻²]
21802193
2194+
.. versionchanged:: 0.11.2
2195+
Renamed from ``ghi_clearsky`` to ``ghi_clear``.
2196+
21812197
dni_clear : array-like
21822198
Direct normal irradiance from clear sky model. [Wm⁻²]
21832199
@@ -2240,7 +2256,7 @@ def dirindex(ghi, ghi_clearsky, dni_clear, zenith, times, pressure=101325.,
22402256
temp_dew=temp_dew, min_cos_zenith=min_cos_zenith,
22412257
max_zenith=max_zenith)
22422258

2243-
dni_dirint_clearsky = dirint(ghi_clearsky, zenith, times,
2259+
dni_dirint_clearsky = dirint(ghi_clear, zenith, times,
22442260
pressure=pressure,
22452261
use_delta_kt_prime=use_delta_kt_prime,
22462262
temp_dew=temp_dew,

pvlib/tests/test_irradiance.py

+21
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,20 @@ def test_dirindex(times):
10951095
equal_nan=True)
10961096

10971097

1098+
@fail_on_pvlib_version("0.13")
1099+
def test_dirindex_ghi_clearsky_deprecation():
1100+
times = pd.DatetimeIndex(['2014-06-24T18-1200'])
1101+
ghi = pd.Series([1038.62], index=times)
1102+
ghi_clearsky = pd.Series([1042.48031487], index=times)
1103+
dni_clearsky = pd.Series([939.95469881], index=times)
1104+
zenith = pd.Series([10.56413562], index=times)
1105+
pressure, tdew = 93193, 10
1106+
with pytest.warns(pvlibDeprecationWarning, match='ghi_clear'):
1107+
irradiance.dirindex(
1108+
ghi=ghi, ghi_clearsky=ghi_clearsky, dni_clear=dni_clearsky,
1109+
zenith=zenith, times=times, pressure=pressure, temp_dew=tdew)
1110+
1111+
10981112
def test_dirindex_min_cos_zenith_max_zenith():
10991113
# map out behavior under difficult conditions with various
11001114
# limiting kwargs settings
@@ -1260,6 +1274,13 @@ def test_clearsky_index():
12601274
assert_series_equal(out, expected)
12611275

12621276

1277+
@fail_on_pvlib_version("0.13")
1278+
def test_clearsky_index_clearsky_ghi_deprecation():
1279+
with pytest.warns(pvlibDeprecationWarning, match='ghi_clear'):
1280+
ghi, clearsky_ghi = 200, 300
1281+
irradiance.clearsky_index(ghi, clearsky_ghi=clearsky_ghi)
1282+
1283+
12631284
def test_clearness_index():
12641285
ghi = np.array([-1, 0, 1, 1000])
12651286
solar_zenith = np.array([180, 90, 89.999, 0])

0 commit comments

Comments
 (0)