-
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
Changes from 9 commits
d3eb73f
c8f8fa0
108f5b8
8ea6149
f04591e
f94f8d7
cea8d2d
dc0950a
d7d84f2
9ff04b2
8308bc6
6763338
4f1ef52
e806e29
8bc57d3
7fefc74
e23a6d3
a2446dd
86a1970
0345815
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,75 @@ | ||||||
""" | ||||||
GHI to POA Transposition | ||||||
========================= | ||||||
|
||||||
Example of transposing clearsky GHI to POA | ||||||
""" | ||||||
|
||||||
# %% | ||||||
# This example shows how to use the get_clearsky method to generate clearsky | ||||||
ericf900 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
# GHI data as well as how to use the get_total_iradiance function to transpose | ||||||
ericf900 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
# GHI data to Plane of Array (POA) irradiance. | ||||||
|
||||||
from pvlib import location | ||||||
from pvlib.irradiance import get_total_irradiance | ||||||
ericf900 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
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 | ||||||
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. very nice choice of location, +1 |
||||||
|
||||||
# Create location object to store lat, lon, timezone | ||||||
site = location.Location(lat, lon, tz=tz) | ||||||
|
||||||
|
||||||
# Define a function to handle the transposition | ||||||
ericf900 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
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=tz) | ||||||
ericf900 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
# Generate cleaersky data using the Ineichen model, which is the default | ||||||
ericf900 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
# The get_clearsky method returns a dataframe with values for GHI, DNI, | ||||||
# and DHI | ||||||
clearsky_ghi = site_location.get_clearsky(times) | ||||||
ericf900 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
# 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 = get_total_irradiance( | ||||||
surface_tilt=tilt, | ||||||
surface_azimuth=surface_azimuth, | ||||||
dni=clearsky_ghi['dni'], | ||||||
ghi=clearsky_ghi['ghi'], | ||||||
dhi=clearsky_ghi['dhi'], | ||||||
solar_zenith=solar_position['zenith'], | ||||||
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.
Suggested change
FYI I'd like someone else to confirm that using apparent solar position is appropriate before making this change 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. According to the parameters for each transposition model option in It's a different matter to verify that each model actually expects |
||||||
solar_azimuth=solar_position['azimuth']) | ||||||
# Return DataFrame with only GHI and POA | ||||||
return pd.DataFrame({'GHI': clearsky_ghi['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) | ||||||
|
||||||
# Plot GHI vs. POA for winter and summer | ||||||
fig, (ax1, ax2) = plt.subplots(1, 2) | ||||||
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. This example is really great! Thanks! I have a minor suggestion, can you vertically stack the plots and share the x-axis? fig, ax = plt.subplots(2, 1, sharex=True) # stack plots (2, 1) and share the x axis
ax1, ax2 = ax # or you can just use ax[0] instead of ax1, and ax[1] instead ax2, minor preference I'm having a hard time reading the dates on the x-axis because they're a bit crowded, so I thought trying them vertical and sharing them might look nicer, but your call - but not a blocker for me - also fine as is, THANKS! 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. Unfortunately the indexes are 6 months apart so I don't think 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. Hi Mike and Kevin! I am looking at this now- I agree the x-axis is a bit cluttered. I think the benefit of keeping the plots side-by-side is that it highlights that, while there is not much of a gain for POA compared to GHI in the summer, overall irradiance is higher. I'll make some edits now and push up the new version! 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. You're both right! Sorry for the distraction! Great work |
||||||
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/m2)') | ||||||
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. 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. Thanks for the feedback Mike! Made these changes and am uploading a new version now :) |
||||||
ax2.set_ylabel('Irradiance (W/m2)') | ||||||
ericf900 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
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 signifiacntly higher than | ||||||
ericf900 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
# 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. |
Uh oh!
There was an error while loading. Please reload this page.