From f0a10abe6adef7a9482ff8bf135878fdba80624d Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Mon, 10 Sep 2018 22:00:18 -0400 Subject: [PATCH 01/15] basic code for irradiance.clearsky_index, still needs full docstring and tests --- pvlib/irradiance.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 261bd64e49..054d1d1549 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -1182,6 +1182,39 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra, return sky_diffuse +def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0): + """ + Calculate the clearsky index. + + The clearsky index is the ratio of global to clearsky global irradiance. + + Parameters + ---------- + ghi : numeric + Global horizontal irradiance in W/m^2. + + clearsky_ghi : numeric + Modeled clearsky GHI + + max_clearsky_index : numeric, default 2.0 + Maximum value of the clearsky index. The default, 2.0, allows + for over-irradiance events typically seen in sub-hourly data. + + Returns + ------- + kt : numeric + Clearness index + + References + ---------- + .. [1] None + """ + kt = ghi / clearsky_ghi + kt = np.maximum(kt, 0) + kt = np.minimum(kt, max_clearsky_index) + return kt + + def clearness_index(ghi, solar_zenith, extra_radiation, min_cos_zenith=0.065, max_clearness_index=2.0): """ From 1350d2a53cb982263fddd98e20799b177966b24e Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Sun, 18 Nov 2018 11:03:29 -0500 Subject: [PATCH 02/15] Add a float conversion to irradiance.clearsky_index to allow integer inputs --- pvlib/irradiance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 054d1d1549..4c06609c86 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -1209,7 +1209,7 @@ def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0): ---------- .. [1] None """ - kt = ghi / clearsky_ghi + kt = ghi * 1. / clearsky_ghi kt = np.maximum(kt, 0) kt = np.minimum(kt, max_clearsky_index) return kt From cd7a596213aaaa208556a93b693a4ebfbc9eee6d Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Sun, 18 Nov 2018 11:49:48 -0500 Subject: [PATCH 03/15] added tests for irradiance.clearsky_index --- pvlib/test/test_irradiance.py | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/pvlib/test/test_irradiance.py b/pvlib/test/test_irradiance.py index 6335b2350c..08c77ca92d 100644 --- a/pvlib/test/test_irradiance.py +++ b/pvlib/test/test_irradiance.py @@ -718,6 +718,43 @@ def test_kt_kt_prime_factor(airmass_kt): assert_allclose(out, expected, atol=1e-5) +def test_clearsky_index(): + ghi = np.array([-1., 0., 1., 500., 1000.]) + ghi_measured, ghi_modeled = np.meshgrid(ghi, ghi) + # default max_clearsky_index + with np.errstate(invalid='ignore', divide='ignore'): + out = irradiance.clearsky_index(ghi_measured, ghi_modeled) + expected = np.array( + [[1. , 0. , 0. , 0. , 0. ], + [0. , nan , 2. , 2. , 2. ], + [0. , 0. , 1. , 2. , 2. ], + [0. , 0. , 0.002, 1. , 2. ], + [0. , 0. , 0.001, 0.5 , 1. ]]) + assert_allclose(out, expected, atol=0.001) + # specify max_clearsky_index + with np.errstate(invalid='ignore', divide='ignore'): + out = irradiance.clearsky_index(ghi_measured, ghi_modeled, + max_clearsky_index=1.5) + expected = np.array( + [[1. , 0. , 0. , 0. , 0. ], + [0. , nan , 1.5 , 1.5 , 1.5 ], + [0. , 0. , 1. , 1.5 , 1.5 ], + [0. , 0. , 0.002, 1. , 1.5 ], + [0. , 0. , 0.001, 0.5 , 1. ]]) + assert_allclose(out, expected, atol=0.001) + # scalars + out = irradiance.clearsky_index(10, 1000) + expected = 0.1 + assert_allclose(out, expected, atol=0.001) + # series + times = pd.DatetimeIndex(start='20180601', periods=2, freq='12H') + ghi_measured = pd.Series([100, 500], index=times) + ghi_modeled = pd.Series([500, 1000], index=times) + out = irradiance.clearness_index(ghi_measured, ghi_modeled) + expected = pd.Series([0.2, 0.5], index=times) + assert_series_equal(out, expected) + + def test_clearness_index(): ghi = np.array([-1, 0, 1, 1000]) solar_zenith = np.array([180, 90, 89.999, 0]) From 0099762c4429787ffda9ae668c76ae50c77c1f25 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Sun, 18 Nov 2018 12:00:21 -0500 Subject: [PATCH 04/15] fix typo in irradiance.clearsky_index test --- pvlib/test/test_irradiance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/test/test_irradiance.py b/pvlib/test/test_irradiance.py index 08c77ca92d..0813a7392c 100644 --- a/pvlib/test/test_irradiance.py +++ b/pvlib/test/test_irradiance.py @@ -744,7 +744,7 @@ def test_clearsky_index(): assert_allclose(out, expected, atol=0.001) # scalars out = irradiance.clearsky_index(10, 1000) - expected = 0.1 + expected = 0.01 assert_allclose(out, expected, atol=0.001) # series times = pd.DatetimeIndex(start='20180601', periods=2, freq='12H') From 4b208e9bc9b4ffe831f1fa7b2a2f0ae11220e9df Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Sun, 18 Nov 2018 12:12:53 -0500 Subject: [PATCH 05/15] fix typo in irradiance.clearsky_index test --- pvlib/test/test_irradiance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/test/test_irradiance.py b/pvlib/test/test_irradiance.py index 0813a7392c..06c7265972 100644 --- a/pvlib/test/test_irradiance.py +++ b/pvlib/test/test_irradiance.py @@ -750,7 +750,7 @@ def test_clearsky_index(): times = pd.DatetimeIndex(start='20180601', periods=2, freq='12H') ghi_measured = pd.Series([100, 500], index=times) ghi_modeled = pd.Series([500, 1000], index=times) - out = irradiance.clearness_index(ghi_measured, ghi_modeled) + out = irradiance.clearsky_index(ghi_measured, ghi_modeled) expected = pd.Series([0.2, 0.5], index=times) assert_series_equal(out, expected) From c57892adad05c468e5fe85691e43e0993d0d6870 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Thu, 22 Nov 2018 11:03:40 -0500 Subject: [PATCH 06/15] Update pvlib/test/test_irradiance.py to remove extra spaces --- pvlib/test/test_irradiance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/test/test_irradiance.py b/pvlib/test/test_irradiance.py index 01aeb01c47..59808849f3 100644 --- a/pvlib/test/test_irradiance.py +++ b/pvlib/test/test_irradiance.py @@ -756,7 +756,7 @@ def test_clearsky_index(): # series times = pd.DatetimeIndex(start='20180601', periods=2, freq='12H') ghi_measured = pd.Series([100, 500], index=times) - ghi_modeled = pd.Series([500, 1000], index=times) + ghi_modeled = pd.Series([500, 1000], index=times) out = irradiance.clearsky_index(ghi_measured, ghi_modeled) expected = pd.Series([0.2, 0.5], index=times) assert_series_equal(out, expected) From 9ae594c05153325c19344b8bcfc06f7cbdb11344 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Sat, 26 Jan 2019 12:44:09 -0500 Subject: [PATCH 07/15] fixed incorrect documentation for irradiance.clearsky_index --- pvlib/irradiance.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 6bf5be29f9..a73af44626 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -1214,12 +1214,8 @@ def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0): Returns ------- - kt : numeric - Clearness index - - References - ---------- - .. [1] None + clearsky_index : numeric + Clearsky index """ kt = ghi * 1. / clearsky_ghi kt = np.maximum(kt, 0) From 96d0cf397d4d353ba90f8a69345401e3d57087fa Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Sun, 27 Jan 2019 10:15:02 -0500 Subject: [PATCH 08/15] rename poorly-named variables in irradiance.clearsky_index --- pvlib/irradiance.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index a73af44626..19b4034990 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -1217,10 +1217,10 @@ def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0): clearsky_index : numeric Clearsky index """ - kt = ghi * 1. / clearsky_ghi - kt = np.maximum(kt, 0) - kt = np.minimum(kt, max_clearsky_index) - return kt + clearsky_index = ghi * 1. / clearsky_ghi + clearsky_index = np.maximum(clearsky_index, 0) + clearsky_index = np.minimum(clearsky_index, max_clearsky_index) + return clearsky_index def clearness_index(ghi, solar_zenith, extra_radiation, min_cos_zenith=0.065, From dc5b9cafc904af7fcacb6000684858cf11401ab7 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Tue, 29 Jan 2019 20:18:38 -0500 Subject: [PATCH 09/15] truncate nan/inf values to zero in irradiance.clearsky_index --- pvlib/irradiance.py | 10 +++++++++- pvlib/test/test_irradiance.py | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 19b4034990..a399dadfb6 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -1199,6 +1199,7 @@ def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0): Calculate the clearsky index. The clearsky index is the ratio of global to clearsky global irradiance. + Negative and non-finite clearsky index values will be truncated to zero. Parameters ---------- @@ -1217,9 +1218,16 @@ def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0): clearsky_index : numeric Clearsky index """ - clearsky_index = ghi * 1. / clearsky_ghi + clearsky_index = ghi / clearsky_ghi + # set +inf, -inf, and nans to zero, while preserving input type + if isinstance(clearsky_index, pd.Series): + clearsky_index[~np.isfinite(clearsky_index)] = 0 + else: + clearsky_index = np.where(~np.isfinite(clearsky_index), 0, clearsky_index) + clearsky_index = np.maximum(clearsky_index, 0) clearsky_index = np.minimum(clearsky_index, max_clearsky_index) + return clearsky_index diff --git a/pvlib/test/test_irradiance.py b/pvlib/test/test_irradiance.py index 59808849f3..92d6347d01 100644 --- a/pvlib/test/test_irradiance.py +++ b/pvlib/test/test_irradiance.py @@ -733,7 +733,7 @@ def test_clearsky_index(): out = irradiance.clearsky_index(ghi_measured, ghi_modeled) expected = np.array( [[1. , 0. , 0. , 0. , 0. ], - [0. , nan , 2. , 2. , 2. ], + [0. , 0. , 0. , 0. , 0. ], [0. , 0. , 1. , 2. , 2. ], [0. , 0. , 0.002, 1. , 2. ], [0. , 0. , 0.001, 0.5 , 1. ]]) @@ -744,7 +744,7 @@ def test_clearsky_index(): max_clearsky_index=1.5) expected = np.array( [[1. , 0. , 0. , 0. , 0. ], - [0. , nan , 1.5 , 1.5 , 1.5 ], + [0. , 0. , 0. , 0. , 0. ], [0. , 0. , 1. , 1.5 , 1.5 ], [0. , 0. , 0.002, 1. , 1.5 ], [0. , 0. , 0.001, 0.5 , 1. ]]) From 86e4531293f82adcf3a295c584d05f244615d0cc Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Tue, 29 Jan 2019 20:46:18 -0500 Subject: [PATCH 10/15] update whatsnew and api.rst --- docs/sphinx/source/api.rst | 1 + docs/sphinx/source/whatsnew/v0.6.1.rst | 3 +++ 2 files changed, 4 insertions(+) diff --git a/docs/sphinx/source/api.rst b/docs/sphinx/source/api.rst index 2716c7fbe6..e9c0cef304 100644 --- a/docs/sphinx/source/api.rst +++ b/docs/sphinx/source/api.rst @@ -190,6 +190,7 @@ Clearness index models irradiance.clearness_index irradiance.clearness_index_zenith_independent + irradiance.clearsky_index PV Modeling diff --git a/docs/sphinx/source/whatsnew/v0.6.1.rst b/docs/sphinx/source/whatsnew/v0.6.1.rst index e53c374d3a..f95433e451 100644 --- a/docs/sphinx/source/whatsnew/v0.6.1.rst +++ b/docs/sphinx/source/whatsnew/v0.6.1.rst @@ -41,6 +41,8 @@ Enhancements to read NREL MIDC data. (:issue:`601`) * Change :py:func:`pvlib.pvsystem.sapm_spectral_loss` to avoid numpy warning. * Add warning message when :py:func:`pvlib.spa` is reloaded. +* Add :py:func:`pvlib.irradiance.clearsky_index` to calculate clear-sky index + from measured GHI and modeled clear-sky GHI. (:issue:`551`) Bug fixes @@ -65,3 +67,4 @@ Contributors * Ben Ellis (:ghuser:`bhellis725`) * Cliff Hansen (:ghuser:`cwhanse`) * Mark Mikofski (:ghuser:`mikofski`) +* Kevin Anderson (:ghuser:`kevinsa5`) From 6fbe8a355c664b374759f79c441a1d25e3b8751a Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Tue, 29 Jan 2019 20:59:33 -0500 Subject: [PATCH 11/15] improved formatting to satisfy stickler --- pvlib/irradiance.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index a399dadfb6..0a65752bc0 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -1199,7 +1199,7 @@ def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0): Calculate the clearsky index. The clearsky index is the ratio of global to clearsky global irradiance. - Negative and non-finite clearsky index values will be truncated to zero. + Negative and non-finite clearsky index values will be truncated to zero. Parameters ---------- @@ -1223,11 +1223,12 @@ def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0): if isinstance(clearsky_index, pd.Series): clearsky_index[~np.isfinite(clearsky_index)] = 0 else: - clearsky_index = np.where(~np.isfinite(clearsky_index), 0, clearsky_index) + clearsky_index = np.where(~np.isfinite(clearsky_index), 0, + clearsky_index) clearsky_index = np.maximum(clearsky_index, 0) clearsky_index = np.minimum(clearsky_index, max_clearsky_index) - + return clearsky_index From 20f189acde58b459714640751004cddd081afb18 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 30 Jan 2019 18:42:43 -0500 Subject: [PATCH 12/15] preserve input nans for irradiance.clearsky_index --- pvlib/irradiance.py | 4 ++++ pvlib/test/test_irradiance.py | 24 +++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 602e4802d9..5d50c3d0b0 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -1224,11 +1224,15 @@ def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0): """ clearsky_index = ghi / clearsky_ghi # set +inf, -inf, and nans to zero, while preserving input type + # but preserve nans in the input arrays as well + input_is_nan = ~np.isfinite(ghi) | ~np.isfinite(clearsky_ghi) if isinstance(clearsky_index, pd.Series): clearsky_index[~np.isfinite(clearsky_index)] = 0 + clearsky_index[input_is_nan] = np.nan else: clearsky_index = np.where(~np.isfinite(clearsky_index), 0, clearsky_index) + clearsky_index = np.where(input_is_nan, np.nan, clearsky_index) clearsky_index = np.maximum(clearsky_index, 0) clearsky_index = np.minimum(clearsky_index, max_clearsky_index) diff --git a/pvlib/test/test_irradiance.py b/pvlib/test/test_irradiance.py index 15b03fc90b..285c5a6bd8 100644 --- a/pvlib/test/test_irradiance.py +++ b/pvlib/test/test_irradiance.py @@ -767,28 +767,30 @@ def test_kt_kt_prime_factor(airmass_kt): def test_clearsky_index(): - ghi = np.array([-1., 0., 1., 500., 1000.]) + ghi = np.array([-1., 0., 1., 500., 1000., np.nan]) ghi_measured, ghi_modeled = np.meshgrid(ghi, ghi) # default max_clearsky_index with np.errstate(invalid='ignore', divide='ignore'): out = irradiance.clearsky_index(ghi_measured, ghi_modeled) expected = np.array( - [[1. , 0. , 0. , 0. , 0. ], - [0. , 0. , 0. , 0. , 0. ], - [0. , 0. , 1. , 2. , 2. ], - [0. , 0. , 0.002, 1. , 2. ], - [0. , 0. , 0.001, 0.5 , 1. ]]) + [[1. , 0. , 0. , 0. , 0. , np.nan], + [0. , 0. , 0. , 0. , 0. , np.nan], + [0. , 0. , 1. , 2. , 2. , np.nan], + [0. , 0. , 0.002 , 1. , 2. , np.nan], + [0. , 0. , 0.001 , 0.5 , 1. , np.nan], + [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]]) assert_allclose(out, expected, atol=0.001) # specify max_clearsky_index with np.errstate(invalid='ignore', divide='ignore'): out = irradiance.clearsky_index(ghi_measured, ghi_modeled, max_clearsky_index=1.5) expected = np.array( - [[1. , 0. , 0. , 0. , 0. ], - [0. , 0. , 0. , 0. , 0. ], - [0. , 0. , 1. , 1.5 , 1.5 ], - [0. , 0. , 0.002, 1. , 1.5 ], - [0. , 0. , 0.001, 0.5 , 1. ]]) + [[1. , 0. , 0. , 0. , 0. , np.nan], + [0. , 0. , 0. , 0. , 0. , np.nan], + [0. , 0. , 1. , 1.5 , 1.5 , np.nan], + [0. , 0. , 0.002 , 1. , 1.5 , np.nan], + [0. , 0. , 0.001 , 0.5 , 1. , np.nan], + [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]]) assert_allclose(out, expected, atol=0.001) # scalars out = irradiance.clearsky_index(10, 1000) From f9f6079862815c612d197bec15a60791de1bfb9d Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 30 Jan 2019 18:44:41 -0500 Subject: [PATCH 13/15] remove trailing whitespace --- pvlib/irradiance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 5d50c3d0b0..28ecf992db 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -1230,7 +1230,7 @@ def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0): clearsky_index[~np.isfinite(clearsky_index)] = 0 clearsky_index[input_is_nan] = np.nan else: - clearsky_index = np.where(~np.isfinite(clearsky_index), 0, + clearsky_index = np.where(~np.isfinite(clearsky_index), 0, clearsky_index) clearsky_index = np.where(input_is_nan, np.nan, clearsky_index) From 329d0ca662ff6c1ca2e35cef642225d53cd16a3c Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 30 Jan 2019 19:19:28 -0500 Subject: [PATCH 14/15] refactor irradiance.clearsky_index to simplify type-handling logic. also changed behavior for input inf values to set clearsky index to zero --- pvlib/irradiance.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 28ecf992db..0b5b592935 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -1223,20 +1223,20 @@ def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0): Clearsky index """ clearsky_index = ghi / clearsky_ghi - # set +inf, -inf, and nans to zero, while preserving input type - # but preserve nans in the input arrays as well - input_is_nan = ~np.isfinite(ghi) | ~np.isfinite(clearsky_ghi) - if isinstance(clearsky_index, pd.Series): - clearsky_index[~np.isfinite(clearsky_index)] = 0 - clearsky_index[input_is_nan] = np.nan - else: - clearsky_index = np.where(~np.isfinite(clearsky_index), 0, - clearsky_index) - clearsky_index = np.where(input_is_nan, np.nan, clearsky_index) + # set +inf, -inf, and nans to zero + clearsky_index = np.where(~np.isfinite(clearsky_index), 0, + clearsky_index) + # but preserve nans in the input arrays + input_is_nan = np.isnan(ghi) | np.isnan(clearsky_ghi) + clearsky_index = np.where(input_is_nan, np.nan, clearsky_index) clearsky_index = np.maximum(clearsky_index, 0) clearsky_index = np.minimum(clearsky_index, max_clearsky_index) + # preserve input type + if isinstance(ghi, pd.Series): + clearsky_index = pd.Series(clearsky_index, index=ghi.index) + return clearsky_index From a6e1940892cec52317a4ec170e4fd2f5af592f66 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 30 Jan 2019 19:26:45 -0500 Subject: [PATCH 15/15] revert change to inf/nan handling; input infs yield clearsky_index=nan --- pvlib/irradiance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 0b5b592935..c79ce618a9 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -1227,7 +1227,7 @@ def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0): clearsky_index = np.where(~np.isfinite(clearsky_index), 0, clearsky_index) # but preserve nans in the input arrays - input_is_nan = np.isnan(ghi) | np.isnan(clearsky_ghi) + input_is_nan = ~np.isfinite(ghi) | ~np.isfinite(clearsky_ghi) clearsky_index = np.where(input_is_nan, np.nan, clearsky_index) clearsky_index = np.maximum(clearsky_index, 0)