def test_clearsky_limits_csi_max(times): """Increasing `csi_max` passes larger values.""" measured = pd.Series(np.linspace(800, 1000, len(times)), index=times) measured.iloc[0] = 1300 measured.iloc[1] = 1200 measured.iloc[2] = 1100 clearsky = pd.Series(1000, index=times) expected = pd.Series(True, index=times) expected.iloc[0:3] = False assert_series_equal( irradiance.clearsky_limits(measured, clearsky, csi_max=1.0), expected) expected.iloc[2] = True assert_series_equal( irradiance.clearsky_limits(measured, clearsky, csi_max=1.1), expected) expected.iloc[1] = True assert_series_equal( irradiance.clearsky_limits(measured, clearsky, csi_max=1.2), expected)
def test_clearsky_limits(times): """Values greater than clearsky values are flagged False. Notes ----- Copyright (c) 2019 SolarArbiter. See the file LICENSES/SOLARFORECASTARBITER_LICENSE at the top level directory of this distribution and at `<https://github.com/pvlib/ pvanalytics/blob/master/LICENSES/SOLARFORECASTARBITER_LICENSE>`_ for more information. """ clearsky = pd.Series(np.linspace(50, 55, len(times)), index=times) measured = clearsky.copy() measured.iloc[0] *= 0.5 measured.iloc[-1] *= 2.0 clear_times = np.tile(True, len(times)) clear_times[-1] = False assert_series_equal(irradiance.clearsky_limits(measured, clearsky), pd.Series(index=times, data=clear_times))
def test_clearsky_limits_negative_and_nan(): """Irradiance values greater than clearsky valuse are flagged False along with NaNs. Notes ----- Copyright (c) 2019 SolarArbiter. See the file LICENSES/SOLARFORECASTARBITER_LICENSE at the top level directory of this distribution and at `<https://github.com/pvlib/ pvanalytics/blob/master/LICENSES/SOLARFORECASTARBITER_LICENSE>`_ for more information. """ index = pd.date_range(start=datetime(2019, 6, 15, 12, 0, 0), freq='15T', periods=5) measured = pd.Series(index=index, data=[800, 1000, 1200, -200, np.nan]) clearsky = pd.Series(index=index, data=1000) assert_series_equal( irradiance.clearsky_limits(measured, clearsky), pd.Series(index=index, data=[True, True, False, True, False]))
# :py:meth:`pvlib.location.Location.get_clearsky`, using the lat-long # coordinates associated the RMIS NREL system. location = pvlib.location.Location(39.7407, -105.1686) clearsky = location.get_clearsky(data.index) # %% # Use :py:func:`pvanalytics.quality.irradiance.clearsky_limits`. # Here, we check GHI data in field 'irradiance_ghi__7981'. # :py:func:`pvanalytics.quality.irradiance.clearsky_limits` # returns a mask that identifies data that falls between # lower and upper limits. The defaults (used here) # are upper bound of 110% of clear-sky GHI, and # no lower bound. clearsky_limit_mask = clearsky_limits(data['irradiance_ghi__7981'], clearsky['ghi']) # %% # Mask nighttime values in the GHI time series using the # :py:func:`pvanalytics.features.daytime.power_or_irradiance` function. # We will then remove nighttime values from the GHI time series. day_night_mask = power_or_irradiance(series=data['irradiance_ghi__7981'], freq=freq) # %% # Plot the 'irradiance_ghi__7981' data stream and its associated clearsky GHI # data stream. Mask the GHI time series by its clearsky_limit_mask for daytime # periods. # Please note that a simple Ineichen model with static monthly turbidities # isn't always accurate, as in this case. Other models that may provide better