-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Create plot_ghi_transposition.py example #933
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d3eb73f
Create ghi_transposition.py
ericf900 c8f8fa0
Update ghi_transposition.py
ericf900 108f5b8
Update ghi_transposition.py
ericf900 8ea6149
Create plot_ghi_transposition.py
ericf900 f04591e
Delete ghi_transposition.py
ericf900 f94f8d7
Merge remote-tracking branch 'upstream/master' into Transposition-exa…
ericf900 cea8d2d
Update v0.7.2.rst
ericf900 dc0950a
Merge branch 'Transposition-example' of https://github.com/ericf900/p…
ericf900 d7d84f2
Update v0.7.2.rst
ericf900 9ff04b2
Update docs/examples/plot_ghi_transposition.py
ericf900 8308bc6
Update docs/examples/plot_ghi_transposition.py
ericf900 6763338
Update docs/examples/plot_ghi_transposition.py
ericf900 4f1ef52
Update plot_ghi_transposition.py
ericf900 e806e29
Update docs/examples/plot_ghi_transposition.py
ericf900 8bc57d3
Update docs/examples/plot_ghi_transposition.py
ericf900 7fefc74
Update plot_ghi_transposition.py
ericf900 e23a6d3
Merge branch 'Transposition-example' of https://github.com/ericf900/p…
ericf900 a2446dd
Update plot_ghi_transposition.py
ericf900 86a1970
Update plot_ghi_transposition.py
ericf900 0345815
Update plot_ghi_transposition.py
ericf900 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
""" | ||
GHI to POA Transposition | ||
========================= | ||
|
||
Example of generating clearsky GHI and POA irradiance. | ||
""" | ||
|
||
# %% | ||
# This example shows how to use the | ||
# :py:meth:`pvlib.location.Location.get_clearsky` method to generate clearsky | ||
# GHI data as well as how to use the | ||
# :py:meth:`pvlib.irradiance.get_total_irradiance` function to transpose | ||
# GHI data to Plane of Array (POA) irradiance. | ||
|
||
from pvlib import location | ||
from pvlib import irradiance | ||
import pandas as pd | ||
from matplotlib import pyplot as plt | ||
|
||
# For this example, we will be using Golden, Colorado | ||
tz = 'MST' | ||
lat, lon = 39.755, -105.221 | ||
|
||
# Create location object to store lat, lon, timezone | ||
site = location.Location(lat, lon, tz=tz) | ||
|
||
|
||
# Calculate clear-sky GHI and transpose to plane of array | ||
# Define a function so that we can re-use the sequence of operations with | ||
# different locations | ||
def get_irradiance(site_location, date, tilt, surface_azimuth): | ||
# Creates one day's worth of 10 min intervals | ||
times = pd.date_range(date, freq='10min', periods=6*24, | ||
tz=site_location.tz) | ||
# Generate clearsky data using the Ineichen model, which is the default | ||
# The get_clearsky method returns a dataframe with values for GHI, DNI, | ||
# and DHI | ||
clearsky = site_location.get_clearsky(times) | ||
# Get solar azimuth and zenith to pass to the transposition function | ||
solar_position = site_location.get_solarposition(times=times) | ||
# Use the get_total_irradiance function to transpose the GHI to POA | ||
POA_irradiance = irradiance.get_total_irradiance( | ||
surface_tilt=tilt, | ||
surface_azimuth=surface_azimuth, | ||
dni=clearsky['dni'], | ||
ghi=clearsky['ghi'], | ||
dhi=clearsky['dhi'], | ||
solar_zenith=solar_position['apparent_zenith'], | ||
solar_azimuth=solar_position['azimuth']) | ||
# Return DataFrame with only GHI and POA | ||
return pd.DataFrame({'GHI': clearsky['ghi'], | ||
'POA': POA_irradiance['poa_global']}) | ||
|
||
|
||
# Get irradiance data for summer and winter solstice, assuming 25 degree tilt | ||
# and a south facing array | ||
summer_irradiance = get_irradiance(site, '06-20-2020', 25, 180) | ||
winter_irradiance = get_irradiance(site, '12-21-2020', 25, 180) | ||
|
||
# Convert Dataframe Indexes to Hour:Minute format to make plotting easier | ||
summer_irradiance.index = summer_irradiance.index.strftime("%H:%M") | ||
winter_irradiance.index = winter_irradiance.index.strftime("%H:%M") | ||
|
||
# Plot GHI vs. POA for winter and summer | ||
fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True) | ||
summer_irradiance['GHI'].plot(ax=ax1, label='GHI') | ||
summer_irradiance['POA'].plot(ax=ax1, label='POA') | ||
winter_irradiance['GHI'].plot(ax=ax2, label='GHI') | ||
winter_irradiance['POA'].plot(ax=ax2, label='POA') | ||
ax1.set_xlabel('Time of day (Summer)') | ||
ax2.set_xlabel('Time of day (Winter)') | ||
ax1.set_ylabel('Irradiance ($W/m^2$)') | ||
ax1.legend() | ||
ax2.legend() | ||
plt.show() | ||
|
||
# %% | ||
# Note that in Summer, there is not much gain when comparing POA irradiance to | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 for this note, answers a question often asked by newcomers to PV modeling |
||
# GHI. In the winter, however, POA irradiance is significantly higher than | ||
# GHI. This is because, in winter, the sun is much lower in the sky, so a | ||
# tilted array will be at a more optimal angle compared to a flat array. | ||
# In summer, the sun gets much higher in the sky, and there is very little | ||
# gain for a tilted array compared to a flat array. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice choice of location, +1