.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated/gallery/clearsky-detection/clearsky-detection.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_generated_gallery_clearsky-detection_clearsky-detection.py: Clear-Sky Detection =================== Identifying periods of clear-sky conditions using measured irradiance. .. GENERATED FROM PYTHON SOURCE LINES 9-14 Identifying and filtering for clear-sky conditions is a useful way to reduce noise when analyzing measured data. This example shows how to use :py:func:`pvanalytics.features.clearsky.reno` to identify clear-sky conditions using measured GHI data. For this example we'll use GHI measurements from NREL in Golden CO. .. GENERATED FROM PYTHON SOURCE LINES 14-22 .. code-block:: default import pvanalytics from pvanalytics.features.clearsky import reno import pvlib import matplotlib.pyplot as plt import pandas as pd import pathlib .. GENERATED FROM PYTHON SOURCE LINES 23-26 First, read in the GHI measurements. For this example we'll use an example file included in pvanalytics covering a single day, but the same process applies to data of any length. .. GENERATED FROM PYTHON SOURCE LINES 26-37 .. code-block:: default pvanalytics_dir = pathlib.Path(pvanalytics.__file__).parent ghi_file = pvanalytics_dir / 'data' / 'midc_bms_ghi_20220120.csv' data = pd.read_csv(ghi_file, index_col=0, parse_dates=True) # or you can fetch the data straight from the source using pvlib: # date = pd.to_datetime('2022-01-20') # data = pvlib.iotools.read_midc_raw_data_from_nrel('BMS', date, date) measured_ghi = data['Global CMP22 (vent/cor) [W/m^2]'] .. GENERATED FROM PYTHON SOURCE LINES 38-40 Now model clear-sky irradiance for the location and times of the measured data: .. GENERATED FROM PYTHON SOURCE LINES 40-45 .. code-block:: default location = pvlib.location.Location(39.742, -105.18) clearsky = location.get_clearsky(data.index) clearsky_ghi = clearsky['ghi'] .. GENERATED FROM PYTHON SOURCE LINES 46-48 Finally, use :py:func:`pvanalytics.features.clearsky.reno` to identify measurements during clear-sky conditions: .. GENERATED FROM PYTHON SOURCE LINES 48-56 .. code-block:: default is_clearsky = reno(measured_ghi, clearsky_ghi) # clear-sky times indicated in black measured_ghi.plot() measured_ghi[is_clearsky].plot(ls='', marker='o', ms=2, c='k') plt.ylabel('Global Horizontal Irradiance [W/m2]') plt.show() .. image-sg:: /generated/gallery/clearsky-detection/images/sphx_glr_clearsky-detection_001.png :alt: clearsky detection :srcset: /generated/gallery/clearsky-detection/images/sphx_glr_clearsky-detection_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.279 seconds) .. _sphx_glr_download_generated_gallery_clearsky-detection_clearsky-detection.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: clearsky-detection.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: clearsky-detection.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_