def test_clearsky_index(): 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., 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., 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) expected = 0.01 assert_allclose(out, expected, atol=0.001) # series times = pd.date_range(start='20180601', periods=2, freq='12H') ghi_measured = pd.Series([100, 500], 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)
def check_poa_clearsky(poa_global, poa_clearsky, kt_max=1.1): """ Flags plane of array irradiance values greater than clearsky values. Parameters ---------- poa_global : Series Plane of array irradiance in W/m^2 poa_clearsky : Series Plane of array irradiance under clear sky conditions, in W/m^2 kt_max : float maximum allowed ratio of poa_global to poa_clearsky Returns ------- flags : Series True if poa_global is less than or equal to clear sky value. """ kt = clearsky_index(poa_global, poa_clearsky, max_clearsky_index=np.Inf) flags = _check_limits(kt, ub=kt_max, ub_le=True) return flags
def check_ghi_clearsky(ghi, ghi_clearsky, kt_max=1.1): """ Flags GHI values greater than clearsky values. Parameters ---------- ghi : Series Global horizontal irradiance in W/m^2 ghi_clearsky : Series Global horizontal irradiance in W/m^2 under clear sky conditions kt_max : float maximum clearness index that defines when ghi exceeds clear-sky value. Returns ------- flags : Series True if ghi is less than or equal to clear sky value. """ kt = clearsky_index(ghi, ghi_clearsky, max_clearsky_index=np.Inf) flags = _check_limits(kt, ub=kt_max, ub_le=True) return flags