Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Irradiance sphinx documentation #140

Merged
merged 48 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
c722854
added initial files for all of the irradiance documentation (need to …
Mar 24, 2022
dadca92
added RMIS example data for irradiance Sphinx documentation.
Mar 24, 2022
af2c31b
added the new qcrad function.
Mar 24, 2022
50209e2
update the examples for both qcrad functions.
Mar 24, 2022
b861e24
added qcrad-limits documentation.
Mar 24, 2022
e48e11d
ensured outputs for all irradiance functions in examples.
Mar 24, 2022
1e7d222
added plotting functionality for some of the examples.
Mar 29, 2022
2cbc810
added graphics for all of the irradiance documentation.
Mar 30, 2022
fa23f96
added new line at end of file to stop pep8 failure.
Mar 30, 2022
c8eb69b
Clean up of doc strings for irradiance documentation.
Apr 4, 2022
f03667c
Fixed the docstring PEP8 error.
Apr 4, 2022
83ce71c
Update docs/examples/clearsky-limits-irradiance.py
kperrynrel Apr 8, 2022
cc874e0
Update docs/examples/clearsky-limits-irradiance.py
kperrynrel Apr 8, 2022
6640a2c
Update docs/examples/clearsky-limits-irradiance.py
kperrynrel Apr 8, 2022
840015f
Update docs/examples/clearsky-limits-irradiance.py
kperrynrel Apr 8, 2022
4d72586
Update docs/examples/qcrad-limits-irradiance.py
kperrynrel Apr 8, 2022
166dc4a
Update docs/examples/qcrad-limits-irradiance.py
kperrynrel Apr 8, 2022
5bc6f1e
Update docs/examples/qcrad-consistency-irradiance.py
kperrynrel Apr 8, 2022
2522373
Update docs/examples/qcrad-consistency-irradiance.py
kperrynrel Apr 8, 2022
45fe82d
Removed 'sampled' reference from docstring when describing data
Apr 8, 2022
e9544f0
changed py:func to py:meth in docstring
Apr 8, 2022
3ec503c
Updated the routine to calculate extraterrestrial radition as dni_ext…
Apr 8, 2022
ea0ee90
Renamed the routine Clearsky Limits for Daily Insolation
Apr 8, 2022
e0bb19b
removed pep8 issues
Apr 8, 2022
f3decdb
Merge branch 'pvlib:master' into irradiance_sphinx_documentation
kperrynrel Apr 18, 2022
e055c8a
added the documentation to the whatsnew file.
Apr 18, 2022
8778dc6
Update docs/examples/clearsky-limits-irradiance.py
kperrynrel Apr 29, 2022
940773c
Update docs/examples/clearsky-limits-irradiance.py
kperrynrel Apr 29, 2022
225a5e2
Update docs/examples/qcrad-consistency-irradiance.py
kperrynrel Apr 29, 2022
b47089d
Update docs/examples/qcrad-consistency-irradiance.py
kperrynrel Apr 29, 2022
4e318d6
Update docs/examples/qcrad-consistency-irradiance.py
kperrynrel Apr 29, 2022
03f3b6a
Update docs/examples/qcrad-limits-irradiance.py
kperrynrel Apr 29, 2022
321ebae
Update docs/examples/daily-insolation-limits-irradiance.py
kperrynrel Apr 29, 2022
37a43a5
Update docs/examples/clearsky-limits-irradiance.py
kperrynrel Apr 29, 2022
cca9b12
added day-night mask to clearsky-limits-irradiance documentation
Apr 29, 2022
181f250
removed hardcoded path!
Apr 29, 2022
7c308e7
Update docs/examples/daily-insolation-limits-irradiance.py
kperrynrel Apr 29, 2022
e090999
Update docs/examples/daily-insolation-limits-irradiance.py
kperrynrel Apr 29, 2022
b03cbce
Update docs/examples/daily-insolation-limits-irradiance.py
kperrynrel Apr 29, 2022
b4f86cd
switched the ordering of parameters in ) per @cwhanse's request.
Apr 29, 2022
455a60e
switched the ordering of parameters in ) per @cwhanse's request.
Apr 29, 2022
2befe87
rearranged the order of inputs for irradiance_consistency_qcrad funct…
May 2, 2022
13d9f7d
Update docs/examples/qcrad-consistency-irradiance.py
kperrynrel May 2, 2022
6375308
updated clearsky-limits-irradiance example to comment on Ineichen mod…
May 2, 2022
f44af77
updated clearsky-limits-irradiance example to comment on Ineichen mod…
May 2, 2022
c2ee16c
Update docs/examples/qcrad-limits-irradiance.py
kperrynrel May 10, 2022
6068f19
Update docs/examples/qcrad-consistency-irradiance.py
kperrynrel May 10, 2022
07bd477
Update docs/examples/daily-insolation-limits-irradiance.py
kperrynrel May 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions docs/examples/clearsky-limits-irradiance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"""
Clearsky Limits for Irradiance Data
===================================

Checking the clearsky limits of irradiance data.
"""

# %%
# Identifying and filtering out invalid irradiance data is a
# useful way to reduce noise during analysis. In this example,
# we use :py:func:`pvanalytics.quality.irradiance.clearsky_limits`
# to identify irradiance values that do not exceed
# a limit based on a clear-sky model. For this example we will
# use GHI data from the RMIS weather system located on the NREL campus in CO.

import pvanalytics
from pvanalytics.quality.irradiance import clearsky_limits
from pvanalytics.features.daytime import power_or_irradiance
import pvlib
import matplotlib.pyplot as plt
import pandas as pd
import pathlib

# %%
# First, read in data from the RMIS NREL system. This data set contains
# 5-minute right-aligned POA, GHI, DNI, DHI, and GNI measurements,
# but only the GHI is relevant here.

pvanalytics_dir = pathlib.Path(pvanalytics.__file__).parent
rmis_file = pvanalytics_dir / 'data' / 'irradiance_RMIS_NREL.csv'
data = pd.read_csv(rmis_file, index_col=0, parse_dates=True)
freq = '5T'
# Make the datetime index tz-aware.
data.index = data.index.tz_localize("Etc/GMT+7")


# %%
# Now model clear-sky irradiance for the location and times of the
# measured data. You can do this using
# :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
# clear-sky estimates include McClear or PSM3.
data['irradiance_ghi__7981'].plot()
clearsky['ghi'].plot()
kperrynrel marked this conversation as resolved.
Show resolved Hide resolved
data.loc[clearsky_limit_mask & day_night_mask][
'irradiance_ghi__7981'].plot(ls='', marker='.')
plt.legend(labels=["RMIS GHI", "Clearsky GHI",
"Under Clearsky Limit"],
loc="upper left")
plt.xlabel("Date")
plt.ylabel("GHI (W/m^2)")
plt.tight_layout()
plt.show()
69 changes: 69 additions & 0 deletions docs/examples/daily-insolation-limits-irradiance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""
Clearsky Limits for Daily Insolation
====================================

Checking the clearsky limits for daily insolation data.
"""

# %%
# Identifying and filtering out invalid irradiance data is a
# useful way to reduce noise during analysis. In this example,
# we use :py:func:`pvanalytics.quality.irradiance.daily_insolation_limits`
# to determine when the daily insolation lies between a minimum
# and a maximum value. Irradiance measurements and clear-sky
# irradiance on each day are integrated with the trapezoid rule
# to calculate daily insolation. For this example we will use data
# from the RMIS weather system located on the NREL campus
# in Colorado, USA.

import pvanalytics
from pvanalytics.quality.irradiance import daily_insolation_limits
import pvlib
import matplotlib.pyplot as plt
import pandas as pd
import pathlib

# %%
# First, read in data from the RMIS NREL system. This data set contains
# 5-minute right-aligned data. It includes POA, GHI,
# DNI, DHI, and GNI measurements.

pvanalytics_dir = pathlib.Path(pvanalytics.__file__).parent
rmis_file = pvanalytics_dir / 'data' / 'irradiance_RMIS_NREL.csv'
data = pd.read_csv(rmis_file, index_col=0, parse_dates=True)
# Make the datetime index tz-aware.
data.index = data.index.tz_localize("Etc/GMT+7")

# %%
# Now model clear-sky irradiance for the location and times of the
# measured data:
location = pvlib.location.Location(39.7407, -105.1686)
clearsky = location.get_clearsky(data.index)

# %%
# Use :py:func:`pvanalytics.quality.irradiance.daily_insolation_limits`
# to identify if the daily insolation lies between a minimum
# and a maximum value. Here, we check GHI irradiance field
# 'irradiance_ghi__7981'.
kperrynrel marked this conversation as resolved.
Show resolved Hide resolved
# :py:func:`pvanalytics.quality.irradiance.daily_insolation_limits`
# returns a mask that identifies data that falls between
# lower and upper limits. The defaults (used here)
# are upper bound of 125% of clear-sky daily insolation,
# and lower bound of 40% of clear-sky daily insolation.

daily_insolation_mask = daily_insolation_limits(data['irradiance_ghi__7981'],
clearsky['ghi'])

# %%
# Plot the 'irradiance_ghi__7981' data stream and its associated clearsky GHI
# data stream. Mask the GHI time series by its daily_insolation_mask.
data['irradiance_ghi__7981'].plot()
clearsky['ghi'].plot()
data.loc[daily_insolation_mask, 'irradiance_ghi__7981'].plot(ls='', marker='.')
plt.legend(labels=["RMIS GHI", "Clearsky GHI",
"Within Daily Insolation Limit"],
loc="upper left")
plt.xlabel("Date")
plt.ylabel("GHI (W/m^2)")
plt.tight_layout()
plt.show()
88 changes: 88 additions & 0 deletions docs/examples/qcrad-consistency-irradiance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
"""
QCrad Consistency for Irradiance Data
=====================================

Check consistency of GHI, DHI and DNI using QCRad criteria.
"""

# %%
# Identifying and filtering out invalid irradiance data is a
# useful way to reduce noise during analysis. In this example,
# we use
# :py:func:`pvanalytics.quality.irradiance.check_irradiance_consistency_qcrad`
# to check the consistency of GHI, DHI and DNI data using QCRad criteria.
# For this example we will use data from the RMIS weather system located
# on the NREL campus in Colorado, USA.


import pvanalytics
from pvanalytics.quality.irradiance import check_irradiance_consistency_qcrad
import pvlib
import matplotlib.pyplot as plt
import pandas as pd
import pathlib

# %%
# First, read in data from the RMIS NREL system. This data set contains
# 5-minute right-aligned data. It includes POA, GHI,
# DNI, DHI, and GNI measurements.

pvanalytics_dir = pathlib.Path(pvanalytics.__file__).parent
rmis_file = pvanalytics_dir / 'data' / 'irradiance_RMIS_NREL.csv'
data = pd.read_csv(rmis_file, index_col=0, parse_dates=True)

# %%
# Now generate solar zenith estimates for the location,
# based on the data's time zone and site latitude-longitude
# coordinates.
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'])
kperrynrel marked this conversation as resolved.
Show resolved Hide resolved


# %%
# 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")
plt.ylabel("Irradiance (W/m^2)")
plt.tight_layout()
plt.show()

# %%
# Plot the GHI, DHI, and DNI data streams with the diffuse
# ratio limit mask overlay. This mask is true when the
# DHI / GHI ratio passes the limit test.
fig = data[['irradiance_ghi__7981', 'irradiance_dhi__7983',
'irradiance_dni__7982']].plot()
# Highlight periods where the GHI ratio passes the limit test
fig.fill_between(data.index, fig.get_ylim()[0], fig.get_ylim()[1],
where=qcrad_consistency_mask[1], alpha=0.4)
fig.legend(labels=["RMIS GHI", "RMIS DHI", "RMIS DNI",
"Within Diffuse Ratio Limit"],
loc="upper center")
plt.xlabel("Date")
plt.ylabel("Irradiance (W/m^2)")
plt.tight_layout()
plt.show()
97 changes: 97 additions & 0 deletions docs/examples/qcrad-limits-irradiance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
"""
QCrad Limits for Irradiance Data
================================

Test for physical limits on GHI, DHI or DNI using the QCRad criteria.
"""

# %%
# Identifying and filtering out invalid irradiance data is a
# useful way to reduce noise during analysis. In this example,
# we use
# :py:func:`pvanalytics.quality.irradiance.check_irradiance_limits_qcrad`
# to test for physical limits on GHI, DHI or DNI using the QCRad criteria.
# For this example we will use data from the RMIS weather system located
# on the NREL campus in Colorado, USA.

import pvanalytics
from pvanalytics.quality.irradiance import check_irradiance_limits_qcrad
import pvlib
import matplotlib.pyplot as plt
import pandas as pd
import pathlib

# %%
# First, read in data from the RMIS NREL system. This data set contains
# 5-minute right-aligned data. It includes POA, GHI,
# DNI, DHI, and GNI measurements.

pvanalytics_dir = pathlib.Path(pvanalytics.__file__).parent
rmis_file = pvanalytics_dir / 'data' / 'irradiance_RMIS_NREL.csv'
data = pd.read_csv(rmis_file, index_col=0, parse_dates=True)

# %%
# Now generate solar zenith estimates for the location,
# based on the data's time zone and site latitude-longitude
# coordinates. This is done using the
# :py:func:`pvlib.solarposition.get_solarposition` function.
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)

# %%
# Generate the estimated extraterrestrial radiation for the time series,
# referred to as dni_extra. This is done using the
# :py:func:`pvlib.irradiance.get_extra_radiation` function.
dni_extra = pvlib.irradiance.get_extra_radiation(data.index)

# %%
# Use :py:func:`pvanalytics.quality.irradiance.check_irradiance_limits_qcrad`
# to generate the QCRAD irradiance limit mask

qcrad_limit_mask = check_irradiance_limits_qcrad(
solar_zenith=solar_position['zenith'],
dni_extra=dni_extra,
ghi=data['irradiance_ghi__7981'],
dhi=data['irradiance_dhi__7983'],
dni=data['irradiance_dni__7982'])

# %%
# Plot the 'irradiance_ghi__7981' data stream with its associated QCRAD limit
# mask.
data['irradiance_ghi__7981'].plot()
data.loc[qcrad_limit_mask[0], 'irradiance_ghi__7981'].plot(ls='', marker='.')
plt.legend(labels=["RMIS GHI", "Within QCRAD Limits"],
loc="upper left")
plt.xlabel("Date")
plt.ylabel("GHI (W/m^2)")
plt.tight_layout()
plt.show()

# %%
# Plot the 'irradiance_dhi__7983 data stream with its associated QCRAD limit
# mask.
data['irradiance_dhi__7983'].plot()
data.loc[qcrad_limit_mask[1], 'irradiance_dhi__7983'].plot(ls='', marker='.')
plt.legend(labels=["RMIS DHI", "Within QCRAD Limits"],
loc="upper left")
plt.xlabel("Date")
plt.ylabel("DHI (W/m^2)")
plt.tight_layout()
plt.show()

# %%
# Plot the 'irradiance_dni__7982' data stream with its associated QCRAD limit
# mask.
data['irradiance_dni__7982'].plot()
data.loc[qcrad_limit_mask[2], 'irradiance_dni__7982'].plot(ls='', marker='.')
plt.legend(labels=["RMIS DNI", "Within QCRAD Limits"],
loc="upper left")
plt.xlabel("Date")
plt.ylabel("DNI (W/m^2)")
plt.tight_layout()
plt.show()
6 changes: 6 additions & 0 deletions docs/whatsnew/0.1.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ Documentation
* Added examples for the pvanalytics.features.daytime module,
including :py:func:`pvanalytics.features.daytime.power_or_irradiance`
(:issue:`133`, :pull:`139`)
* Added examples for the pvanalytics.quality.irradiance module,
including :py:func:`pvanalytics.quality.irradiance.clearsky_limits`,
:py:func:`pvanalytics.quality.irradiance.daily_insolation_limits`,
:py:func:`pvanalytics.quality.irradiance.check_irradiance_consistency_qcrad`,
and :py:func:`pvanalytics.quality.irradiance.check_irradiance_limits_qcrad`
(:issue:`133`, :pull:`140`)


Contributors
Expand Down
Loading