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

Component sum functions #163

Merged
merged 53 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
01712c5
added framework for the component sum equations for ghi, dhi, and dni
Sep 21, 2022
cc50ad6
update the component sum functions
Sep 21, 2022
ab971f0
update the routines again with documentation
Sep 21, 2022
ece80f8
updated the routines to run properly
Sep 23, 2022
ac92167
added unit testing for component sum equations
Sep 26, 2022
180bfb2
update the file name for RMIS data in unit test
Sep 26, 2022
bc387d6
update unit tests
Sep 27, 2022
0337b9c
update the routines to make the initial RMIS df tz-naive
Sep 27, 2022
6f773a2
Added to the whatsnew doc
Oct 3, 2022
0e525af
added info to the api.rst file
Oct 3, 2022
f4fd907
Merge branch 'pvlib:master' into component-sum-functions
kperrynrel Oct 3, 2022
b1bfff3
Added documentation for the component sum equations in the example ga…
Oct 3, 2022
eed845a
update the pep8 protocols for the example doc
Oct 3, 2022
0dcaaf3
Merge branch 'master' into component-sum-functions
kperrynrel Nov 4, 2022
51de46e
updated routines with new pvlib complete_irradiance() function incorp…
kperrynrel Nov 4, 2022
a347ea6
get rid of tz-awareness call
kperrynrel Nov 4, 2022
6982e08
fixed pep8 errors
kperrynrel Nov 4, 2022
23f610b
fixed escape sequence on component sum equation as it was a flake8 flag
kperrynrel Nov 4, 2022
c67986e
removed tz-localization on documentation
kperrynrel Nov 4, 2022
1e8a0c0
fixed RMIS data error (made it tz-naive again bc it was breaking ever…
kperrynrel Nov 4, 2022
f07fb7c
added back in pvanalytics irradiance call in documentation
kperrynrel Nov 4, 2022
bbc349f
debugged unit test
kperrynrel Nov 4, 2022
cc553e9
added rounding to unit test output as results were not exact (round t…
kperrynrel Nov 4, 2022
0dcd27e
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 4, 2022
0b5ce0f
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 4, 2022
d34476a
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 4, 2022
6ff51df
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 7, 2022
897d7d5
updated the if-else statements for dni/dhi/ghi
kperrynrel Nov 8, 2022
9f053f0
merge commits
kperrynrel Nov 8, 2022
52b9c3b
updated the routine to only include fill_value for _fill_nighttime pr…
kperrynrel Nov 8, 2022
30e5482
updated the unit tests associated with irradiance
kperrynrel Nov 8, 2022
5f2045e
update the documentation
kperrynrel Nov 8, 2022
37eb655
further docstring cleanup after changes
kperrynrel Nov 8, 2022
fc7aa58
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 9, 2022
4bb3c52
update the routine to throw error if fill_night_value not correct
kperrynrel Nov 10, 2022
537bd13
update the routine
kperrynrel Nov 10, 2022
bfbf164
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 14, 2022
173b748
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 14, 2022
15141ae
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 14, 2022
c38fde5
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 14, 2022
d27a79f
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 14, 2022
8d6aa59
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 14, 2022
565f70f
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 14, 2022
25589ec
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 14, 2022
3a15d72
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 14, 2022
da7c6bf
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 14, 2022
90fc9a7
Update pvanalytics/quality/irradiance.py
kperrynrel Nov 14, 2022
c6741aa
docstring nit
cwhanse Nov 14, 2022
bc752b4
slashes and spaces
cwhanse Nov 14, 2022
294562b
Need a new line
cwhanse Nov 14, 2022
1fe5807
A-ha
cwhanse Nov 14, 2022
a503d84
this is getting old
cwhanse Nov 14, 2022
d32c4c9
think I did this right
kandersolar Nov 14, 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
11 changes: 11 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ clearsky insolation for the same day.

quality.irradiance.daily_insolation_limits

There is function for calculating the component sum for GHI, DHI,
and DNI, and correcting for nighttime periods. Using this function, we can
estimate one irradiance field using the two other irradiance fields.
This can be useful for comparison, as well as to
calculate missing data fields.

.. autosummary::
:toctree: generated/

quality.irradiance.calculate_component_sum_series

Gaps
----

Expand Down
119 changes: 119 additions & 0 deletions docs/examples/irradiance-quality/component-sum-irradiance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
"""
Component Sum Equations for Irradiance Data
===========================================

Estimate GHI, DHI, and DNI using the component sum equations, with
nighttime corrections.
"""

# %%
# Estimating GHI, DHI, and DNI using the component sum equations is useful
# if the associated field is missing, or as a comparison to an existing
# physical data stream.

import pvanalytics
from pvanalytics.quality.irradiance import calculate_component_sum_series
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)


# %%
# Get the clearsky DNI values associated with the current location, using
# the :py:func:`pvlib.solarposition.get_solarposition` function. These clearsky
# values are used to calculate DNI data.
site = pvlib.location.Location(latitude, longitude, tz=time_zone)
clearsky = site.get_clearsky(data.index)

# %%
# Use :py:func:`pvanalytics.quality.irradiance.calcuate_ghi_component`
# to estimate GHI measurements using DHI and DNI measurements

component_sum_ghi = calculate_component_sum_series(
solar_zenith=solar_position['zenith'],
dhi=data['irradiance_dhi__7983'],
dni=data['irradiance_dni__7982'],
zenith_limit=90,
fill_night_value='equation')

# %%
# Plot the 'irradiance_ghi__7981' data stream against the estimated component
# sum GHI, for comparison
data['irradiance_ghi__7981'].plot()
component_sum_ghi.plot()
plt.legend(labels=["RMIS GHI", "Component Sum GHI"],
loc="upper left")
plt.xlabel("Date")
plt.ylabel("GHI (W/m^2)")
plt.tight_layout()
plt.show()

# %%
# Use :py:func:`pvanalytics.quality.irradiance.calcuate_dhi_component`
# to estimate DHI measurements using GHI and DNI measurements

component_sum_dhi = calculate_component_sum_series(
solar_zenith=solar_position['zenith'],
dni=data['irradiance_dni__7982'],
ghi=data['irradiance_ghi__7981'],
zenith_limit=90,
fill_night_value='equation')

# %%
# Plot the 'irradiance_dhi__7983' data stream against the estimated component
# sum GHI, for comparison
data['irradiance_dhi__7983'].plot()
component_sum_dhi.plot()
plt.legend(labels=["RMIS DHI", "Component Sum DHI"],
loc="upper left")
plt.xlabel("Date")
plt.ylabel("GHI (W/m^2)")
plt.tight_layout()
plt.show()

# %%
# Use :py:func:`pvanalytics.quality.irradiance.calcuate_dni_component`
# to estimate DNI measurements using GHI and DHI measurements

component_sum_dni = calculate_component_sum_series(
solar_zenith=solar_position['zenith'],
dhi=data['irradiance_dhi__7983'],
ghi=data['irradiance_ghi__7981'],
dni_clear=clearsky['dni'],
zenith_limit=90,
fill_night_value='equation')

# %%
# Plot the 'irradiance_dni__7982' data stream against the estimated component
# sum GHI, for comparison
data['irradiance_dni__7982'].plot()
component_sum_dni.plot()
plt.legend(labels=["RMIS DNI", "Component Sum DNI"],
loc="upper left")
plt.xlabel("Date")
plt.ylabel("DNI (W/m^2)")
plt.tight_layout()
plt.show()
6 changes: 4 additions & 2 deletions docs/whatsnew/0.1.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

Enhancements
~~~~~~~~~~~~
* Added function ``pvanalytics.quality.irradiance.calculate_component_sum_series`` for calculating the component sum values of GHI, DHI, and DNI, and performing nighttime corrections (:issue:`157`, :pull:`163`)
* Updated the :py:func:`~pvanalytics.gaps.stale_values_round` function with pandas functionality, leading to the same results with a 300X speedup. (:issue:`156`, :pull:`158`)


Bug Fixes
~~~~~~~~~

Expand All @@ -19,7 +19,7 @@ Requirements
Documentation
~~~~~~~~~~~~~

Added 4 new gallery example pages:
Added new gallery example pages:

* ``pvanalytics.metrics`` (:issue:`133`, :pull:`153`):

Expand All @@ -33,6 +33,8 @@ Added 4 new gallery example pages:
* :py:func:`~pvanalytics.quality.weather.wind_limits`
* :py:func:`~pvanalytics.quality.weather.module_temperature_check`

* ``pvanalytics.quality.irradiance.calculate_component_sum_series``(:issue:`157`, :pull:`163`)

Restructured the example gallery by separating the examples into categories
and adding README's (:issue:`154`, :pull:`155`).

Expand Down
Loading