|
| 1 | +""" |
| 2 | +GHI to POA Transposition |
| 3 | +========================= |
| 4 | +
|
| 5 | +Example of generating clearsky GHI and POA irradiance. |
| 6 | +""" |
| 7 | + |
| 8 | +# %% |
| 9 | +# This example shows how to use the |
| 10 | +# :py:meth:`pvlib.location.Location.get_clearsky` method to generate clearsky |
| 11 | +# GHI data as well as how to use the |
| 12 | +# :py:meth:`pvlib.irradiance.get_total_irradiance` function to transpose |
| 13 | +# GHI data to Plane of Array (POA) irradiance. |
| 14 | + |
| 15 | +from pvlib import location |
| 16 | +from pvlib import irradiance |
| 17 | +import pandas as pd |
| 18 | +from matplotlib import pyplot as plt |
| 19 | + |
| 20 | +# For this example, we will be using Golden, Colorado |
| 21 | +tz = 'MST' |
| 22 | +lat, lon = 39.755, -105.221 |
| 23 | + |
| 24 | +# Create location object to store lat, lon, timezone |
| 25 | +site = location.Location(lat, lon, tz=tz) |
| 26 | + |
| 27 | + |
| 28 | +# Calculate clear-sky GHI and transpose to plane of array |
| 29 | +# Define a function so that we can re-use the sequence of operations with |
| 30 | +# different locations |
| 31 | +def get_irradiance(site_location, date, tilt, surface_azimuth): |
| 32 | + # Creates one day's worth of 10 min intervals |
| 33 | + times = pd.date_range(date, freq='10min', periods=6*24, |
| 34 | + tz=site_location.tz) |
| 35 | + # Generate clearsky data using the Ineichen model, which is the default |
| 36 | + # The get_clearsky method returns a dataframe with values for GHI, DNI, |
| 37 | + # and DHI |
| 38 | + clearsky = site_location.get_clearsky(times) |
| 39 | + # Get solar azimuth and zenith to pass to the transposition function |
| 40 | + solar_position = site_location.get_solarposition(times=times) |
| 41 | + # Use the get_total_irradiance function to transpose the GHI to POA |
| 42 | + POA_irradiance = irradiance.get_total_irradiance( |
| 43 | + surface_tilt=tilt, |
| 44 | + surface_azimuth=surface_azimuth, |
| 45 | + dni=clearsky['dni'], |
| 46 | + ghi=clearsky['ghi'], |
| 47 | + dhi=clearsky['dhi'], |
| 48 | + solar_zenith=solar_position['apparent_zenith'], |
| 49 | + solar_azimuth=solar_position['azimuth']) |
| 50 | + # Return DataFrame with only GHI and POA |
| 51 | + return pd.DataFrame({'GHI': clearsky['ghi'], |
| 52 | + 'POA': POA_irradiance['poa_global']}) |
| 53 | + |
| 54 | + |
| 55 | +# Get irradiance data for summer and winter solstice, assuming 25 degree tilt |
| 56 | +# and a south facing array |
| 57 | +summer_irradiance = get_irradiance(site, '06-20-2020', 25, 180) |
| 58 | +winter_irradiance = get_irradiance(site, '12-21-2020', 25, 180) |
| 59 | + |
| 60 | +# Convert Dataframe Indexes to Hour:Minute format to make plotting easier |
| 61 | +summer_irradiance.index = summer_irradiance.index.strftime("%H:%M") |
| 62 | +winter_irradiance.index = winter_irradiance.index.strftime("%H:%M") |
| 63 | + |
| 64 | +# Plot GHI vs. POA for winter and summer |
| 65 | +fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True) |
| 66 | +summer_irradiance['GHI'].plot(ax=ax1, label='GHI') |
| 67 | +summer_irradiance['POA'].plot(ax=ax1, label='POA') |
| 68 | +winter_irradiance['GHI'].plot(ax=ax2, label='GHI') |
| 69 | +winter_irradiance['POA'].plot(ax=ax2, label='POA') |
| 70 | +ax1.set_xlabel('Time of day (Summer)') |
| 71 | +ax2.set_xlabel('Time of day (Winter)') |
| 72 | +ax1.set_ylabel('Irradiance ($W/m^2$)') |
| 73 | +ax1.legend() |
| 74 | +ax2.legend() |
| 75 | +plt.show() |
| 76 | + |
| 77 | +# %% |
| 78 | +# Note that in Summer, there is not much gain when comparing POA irradiance to |
| 79 | +# GHI. In the winter, however, POA irradiance is significantly higher than |
| 80 | +# GHI. This is because, in winter, the sun is much lower in the sky, so a |
| 81 | +# tilted array will be at a more optimal angle compared to a flat array. |
| 82 | +# In summer, the sun gets much higher in the sky, and there is very little |
| 83 | +# gain for a tilted array compared to a flat array. |
0 commit comments