def test_check_irradiance_consistency_qcrad(irradiance_qcrad): """Test that QCRad identifies consistent irradiance measurements. 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. """ expected = irradiance_qcrad cons_comp, diffuse = irradiance.check_irradiance_consistency_qcrad( expected['ghi'], expected['solar_zenith'], expected['dhi'], expected['dni']) assert_series_equal(cons_comp, expected['consistent_components'], check_names=False) assert_series_equal(diffuse, expected['diffuse_ratio_limit'], check_names=False)
latitude = 39.742 longitude = -105.18 time_zone = "Etc/GMT+7" data = data.tz_localize(time_zone) solar_position = pvlib.solarposition.get_solarposition(data.index, latitude, longitude) # %% # Use # :py:func:`pvanalytics.quality.irradiance.check_irradiance_consistency_qcrad` # to generate the QCRAD consistency mask. qcrad_consistency_mask = check_irradiance_consistency_qcrad( solar_zenith=solar_position['zenith'], ghi=data['irradiance_ghi__7981'], dhi=data['irradiance_dhi__7983'], dni=data['irradiance_dni__7982']) # %% # Plot the GHI, DHI, and DNI data streams with the QCRAD # consistency mask overlay. This mask applies to all 3 data streams. fig = data[['irradiance_ghi__7981', 'irradiance_dhi__7983', 'irradiance_dni__7982']].plot() # Highlight periods where the QCRAD consistency mask is True fig.fill_between(data.index, fig.get_ylim()[0], fig.get_ylim()[1], where=qcrad_consistency_mask[0], alpha=0.4) fig.legend(labels=["RMIS GHI", "RMIS DHI", "RMIS DNI", "QCRAD Consistent"], loc="upper center") plt.xlabel("Date")