From d3eb73f70f83001d4072dbd6597d04e3110c8a53 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Tue, 10 Mar 2020 20:12:18 -0400 Subject: [PATCH 01/17] Create ghi_transposition.py --- docs/examples/ghi_transposition.py | 79 ++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 docs/examples/ghi_transposition.py diff --git a/docs/examples/ghi_transposition.py b/docs/examples/ghi_transposition.py new file mode 100644 index 0000000000..436f66a989 --- /dev/null +++ b/docs/examples/ghi_transposition.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Feb 26 12:01:33 2020 + +@author: edfitch + +GHI to POA Transposition +========================= + +Example of transposing clearsky GHI to POA +""" + +# %% +# This example shows how to use the get_clearsky method to generate clearsky +# GHI data as well as how to use the get_total_iradiance function to transpose +# GHI data to Plane of Array (POA) irradiance. + +from pvlib import location +from pvlib.irradiance import get_total_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) + + +# Define a function to handle the transposition +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) + # Generate cleaersky data using the Ineichen model, which is the default + # The get_clearsky method returns a dataframe with values for GHI, DNI, + # and DHI + clearsky_ghi = 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 = 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'], + solar_azimuth=solar_position['azimuth'] + ) + 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) +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)') +ax2.set_ylabel('Irradiance (W/m2)') +ax1.legend() +ax2.legend() +plt.show() + +# %% +# Note that in Summer, there is not much gain when comparing POA irradiance to +# GHI. In the winter, however, POA irradiance is signifiacntly 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. From c8f8fa0e6a2a0f0de1c284ad1db93779234a0c7c Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Tue, 10 Mar 2020 20:32:32 -0400 Subject: [PATCH 02/17] Update ghi_transposition.py --- docs/examples/ghi_transposition.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/examples/ghi_transposition.py b/docs/examples/ghi_transposition.py index 436f66a989..61f4e37ba7 100644 --- a/docs/examples/ghi_transposition.py +++ b/docs/examples/ghi_transposition.py @@ -40,17 +40,18 @@ def get_irradiance(site_location, date, tilt, surface_azimuth): 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'], - solar_azimuth=solar_position['azimuth'] - ) + surface_tilt=tilt, + surface_azimuth=surface_azimuth, + dni=clearsky_ghi['dni'], + ghi=clearsky_ghi['ghi'], + dhi=clearsky_ghi['dhi'], + solar_zenith=solar_position['zenith'], + solar_azimuth=solar_position['azimuth'] + ) 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) From 108f5b8b90f2f0f36ae5cda8975ac0796c70d2bf Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Tue, 10 Mar 2020 20:38:45 -0400 Subject: [PATCH 03/17] Update ghi_transposition.py --- docs/examples/ghi_transposition.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/examples/ghi_transposition.py b/docs/examples/ghi_transposition.py index 61f4e37ba7..cb8755b0da 100644 --- a/docs/examples/ghi_transposition.py +++ b/docs/examples/ghi_transposition.py @@ -46,8 +46,8 @@ def get_irradiance(site_location, date, tilt, surface_azimuth): ghi=clearsky_ghi['ghi'], dhi=clearsky_ghi['dhi'], solar_zenith=solar_position['zenith'], - solar_azimuth=solar_position['azimuth'] - ) + solar_azimuth=solar_position['azimuth']) + # Return DataFrame with only GHI and POA return pd.DataFrame({'GHI': clearsky_ghi['ghi'], 'POA': POA_irradiance['poa_global']}) From 8ea6149fe6e0ebb8841fcba82128389fb962c486 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Tue, 10 Mar 2020 20:49:31 -0400 Subject: [PATCH 04/17] Create plot_ghi_transposition.py --- docs/examples/plot_ghi_transposition.py | 75 +++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 docs/examples/plot_ghi_transposition.py diff --git a/docs/examples/plot_ghi_transposition.py b/docs/examples/plot_ghi_transposition.py new file mode 100644 index 0000000000..416fdd26ae --- /dev/null +++ b/docs/examples/plot_ghi_transposition.py @@ -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 +# GHI data as well as how to use the get_total_iradiance function to transpose +# GHI data to Plane of Array (POA) irradiance. + +from pvlib import location +from pvlib.irradiance import get_total_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) + + +# Define a function to handle the transposition +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) + # Generate cleaersky data using the Ineichen model, which is the default + # The get_clearsky method returns a dataframe with values for GHI, DNI, + # and DHI + clearsky_ghi = 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 = 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'], + 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) +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)') +ax2.set_ylabel('Irradiance (W/m2)') +ax1.legend() +ax2.legend() +plt.show() + +# %% +# Note that in Summer, there is not much gain when comparing POA irradiance to +# GHI. In the winter, however, POA irradiance is signifiacntly 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. From f04591ee68c35f2961e3283bd5151d7cb0e70812 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Tue, 10 Mar 2020 20:56:02 -0400 Subject: [PATCH 05/17] Delete ghi_transposition.py --- docs/examples/ghi_transposition.py | 80 ------------------------------ 1 file changed, 80 deletions(-) delete mode 100644 docs/examples/ghi_transposition.py diff --git a/docs/examples/ghi_transposition.py b/docs/examples/ghi_transposition.py deleted file mode 100644 index cb8755b0da..0000000000 --- a/docs/examples/ghi_transposition.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Wed Feb 26 12:01:33 2020 - -@author: edfitch - -GHI to POA Transposition -========================= - -Example of transposing clearsky GHI to POA -""" - -# %% -# This example shows how to use the get_clearsky method to generate clearsky -# GHI data as well as how to use the get_total_iradiance function to transpose -# GHI data to Plane of Array (POA) irradiance. - -from pvlib import location -from pvlib.irradiance import get_total_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) - - -# Define a function to handle the transposition -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) - # Generate cleaersky data using the Ineichen model, which is the default - # The get_clearsky method returns a dataframe with values for GHI, DNI, - # and DHI - clearsky_ghi = 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 = 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'], - 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) -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)') -ax2.set_ylabel('Irradiance (W/m2)') -ax1.legend() -ax2.legend() -plt.show() - -# %% -# Note that in Summer, there is not much gain when comparing POA irradiance to -# GHI. In the winter, however, POA irradiance is signifiacntly 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. From cea8d2d8654c55d3230cd3d668eb57259fc4867b Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Tue, 10 Mar 2020 22:03:25 -0400 Subject: [PATCH 06/17] Update v0.7.2.rst --- docs/sphinx/source/whatsnew/v0.7.2.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.7.2.rst b/docs/sphinx/source/whatsnew/v0.7.2.rst index a98400efad..7aa5d744a8 100644 --- a/docs/sphinx/source/whatsnew/v0.7.2.rst +++ b/docs/sphinx/source/whatsnew/v0.7.2.rst @@ -67,6 +67,7 @@ Documentation * Add example of IV curve generation. (:pull:`872`) * Add section about gallery examples to Contributing guide. (:pull:`905`) * Add section with link to Code of Conduct in Contributing guide. (:pull:`922`) +* Add example of GHI to POA transposition Requirements ~~~~~~~~~~~~ @@ -81,3 +82,4 @@ Contributors * Kevin Anderson (:ghuser:`kanderso-nrel`) * Karthikeyan Singaravelan (:ghuser:`tirkarthi`) * Siyan (Veronica) Guo (:ghuser:`veronicaguo`) +* Eric Fitch (:ghuser:`eric.f900`) From d7d84f2ed3fe8864794383ff191346ad47fdd4fe Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Tue, 10 Mar 2020 22:19:14 -0400 Subject: [PATCH 07/17] Update v0.7.2.rst --- docs/sphinx/source/whatsnew/v0.7.2.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.7.2.rst b/docs/sphinx/source/whatsnew/v0.7.2.rst index 7aa5d744a8..2eda805c1e 100644 --- a/docs/sphinx/source/whatsnew/v0.7.2.rst +++ b/docs/sphinx/source/whatsnew/v0.7.2.rst @@ -67,7 +67,7 @@ Documentation * Add example of IV curve generation. (:pull:`872`) * Add section about gallery examples to Contributing guide. (:pull:`905`) * Add section with link to Code of Conduct in Contributing guide. (:pull:`922`) -* Add example of GHI to POA transposition +* Add example of GHI to POA transposition (:pull:`933`) Requirements ~~~~~~~~~~~~ @@ -82,4 +82,4 @@ Contributors * Kevin Anderson (:ghuser:`kanderso-nrel`) * Karthikeyan Singaravelan (:ghuser:`tirkarthi`) * Siyan (Veronica) Guo (:ghuser:`veronicaguo`) -* Eric Fitch (:ghuser:`eric.f900`) +* Eric Fitch (:ghuser:`ericf900`) From 9ff04b24d3828ecbd858ff3195d2089e42278ac9 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Wed, 11 Mar 2020 09:27:16 -0400 Subject: [PATCH 08/17] Update docs/examples/plot_ghi_transposition.py Co-Authored-By: Kevin Anderson <57452607+kanderso-nrel@users.noreply.github.com> --- docs/examples/plot_ghi_transposition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/plot_ghi_transposition.py b/docs/examples/plot_ghi_transposition.py index 416fdd26ae..f650c6ed26 100644 --- a/docs/examples/plot_ghi_transposition.py +++ b/docs/examples/plot_ghi_transposition.py @@ -2,7 +2,7 @@ GHI to POA Transposition ========================= -Example of transposing clearsky GHI to POA +Example of generating clearsky GHI and POA irradiance. """ # %% From 8308bc62a080f47ea4684258e8a5194c20cdd951 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Wed, 11 Mar 2020 09:28:17 -0400 Subject: [PATCH 09/17] Update docs/examples/plot_ghi_transposition.py Co-Authored-By: Kevin Anderson <57452607+kanderso-nrel@users.noreply.github.com> --- docs/examples/plot_ghi_transposition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/plot_ghi_transposition.py b/docs/examples/plot_ghi_transposition.py index f650c6ed26..4940755a7c 100644 --- a/docs/examples/plot_ghi_transposition.py +++ b/docs/examples/plot_ghi_transposition.py @@ -27,7 +27,7 @@ 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) - # Generate cleaersky data using the Ineichen model, which is the default + # 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_ghi = site_location.get_clearsky(times) From 6763338af7bc74d3088b2c3acc0bea28ae3fdf50 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Wed, 11 Mar 2020 09:28:56 -0400 Subject: [PATCH 10/17] Update docs/examples/plot_ghi_transposition.py Co-Authored-By: Kevin Anderson <57452607+kanderso-nrel@users.noreply.github.com> --- docs/examples/plot_ghi_transposition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/plot_ghi_transposition.py b/docs/examples/plot_ghi_transposition.py index 4940755a7c..5dbc798856 100644 --- a/docs/examples/plot_ghi_transposition.py +++ b/docs/examples/plot_ghi_transposition.py @@ -68,7 +68,7 @@ def get_irradiance(site_location, date, tilt, surface_azimuth): # %% # Note that in Summer, there is not much gain when comparing POA irradiance to -# GHI. In the winter, however, POA irradiance is signifiacntly higher than +# 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 From 4f1ef52c58da0a370323feec8fcc99a95ea3b545 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Wed, 11 Mar 2020 09:34:33 -0400 Subject: [PATCH 11/17] Update plot_ghi_transposition.py --- docs/examples/plot_ghi_transposition.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/examples/plot_ghi_transposition.py b/docs/examples/plot_ghi_transposition.py index 5dbc798856..9a300de890 100644 --- a/docs/examples/plot_ghi_transposition.py +++ b/docs/examples/plot_ghi_transposition.py @@ -61,7 +61,6 @@ def get_irradiance(site_location, date, tilt, surface_azimuth): ax1.set_xlabel('Time of day (Summer)') ax2.set_xlabel('Time of day (Winter)') ax1.set_ylabel('Irradiance (W/m2)') -ax2.set_ylabel('Irradiance (W/m2)') ax1.legend() ax2.legend() plt.show() From e806e290facb6e66b8e8919201a6abe385fa4fae Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Wed, 11 Mar 2020 09:35:31 -0400 Subject: [PATCH 12/17] Update docs/examples/plot_ghi_transposition.py Co-Authored-By: Kevin Anderson <57452607+kanderso-nrel@users.noreply.github.com> --- docs/examples/plot_ghi_transposition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/plot_ghi_transposition.py b/docs/examples/plot_ghi_transposition.py index 9a300de890..7dd9b156e0 100644 --- a/docs/examples/plot_ghi_transposition.py +++ b/docs/examples/plot_ghi_transposition.py @@ -7,7 +7,7 @@ # %% # This example shows how to use the get_clearsky method to generate clearsky -# GHI data as well as how to use the get_total_iradiance function to transpose +# 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 8bc57d3ec427983d02d068be5298a7f3c7613b26 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Wed, 11 Mar 2020 09:36:17 -0400 Subject: [PATCH 13/17] Update docs/examples/plot_ghi_transposition.py Co-Authored-By: Kevin Anderson <57452607+kanderso-nrel@users.noreply.github.com> --- docs/examples/plot_ghi_transposition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/plot_ghi_transposition.py b/docs/examples/plot_ghi_transposition.py index 7dd9b156e0..4903e0a8b1 100644 --- a/docs/examples/plot_ghi_transposition.py +++ b/docs/examples/plot_ghi_transposition.py @@ -6,7 +6,7 @@ """ # %% -# This example shows how to use the get_clearsky method to generate clearsky +# 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 7fefc74cba8ad57013c8b7927191f10c0108ac95 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Wed, 11 Mar 2020 09:38:46 -0400 Subject: [PATCH 14/17] Update plot_ghi_transposition.py --- docs/examples/plot_ghi_transposition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/plot_ghi_transposition.py b/docs/examples/plot_ghi_transposition.py index 416fdd26ae..f650c6ed26 100644 --- a/docs/examples/plot_ghi_transposition.py +++ b/docs/examples/plot_ghi_transposition.py @@ -2,7 +2,7 @@ GHI to POA Transposition ========================= -Example of transposing clearsky GHI to POA +Example of generating clearsky GHI and POA irradiance. """ # %% From a2446dd27421d55973882e476347b01918d71f5e Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Wed, 11 Mar 2020 09:41:53 -0400 Subject: [PATCH 15/17] Update plot_ghi_transposition.py --- docs/examples/plot_ghi_transposition.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/examples/plot_ghi_transposition.py b/docs/examples/plot_ghi_transposition.py index 4903e0a8b1..729a0fded8 100644 --- a/docs/examples/plot_ghi_transposition.py +++ b/docs/examples/plot_ghi_transposition.py @@ -6,8 +6,10 @@ """ # %% -# 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 +# 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 86a19700cb907bae8c5aa814b4b5729bfeb53ea5 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Wed, 11 Mar 2020 17:28:44 -0400 Subject: [PATCH 16/17] Update plot_ghi_transposition.py --- docs/examples/plot_ghi_transposition.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/examples/plot_ghi_transposition.py b/docs/examples/plot_ghi_transposition.py index 729a0fded8..29c33acdb4 100644 --- a/docs/examples/plot_ghi_transposition.py +++ b/docs/examples/plot_ghi_transposition.py @@ -13,7 +13,7 @@ # GHI data to Plane of Array (POA) irradiance. from pvlib import location -from pvlib.irradiance import get_total_irradiance +from pvlib import irradiance import pandas as pd from matplotlib import pyplot as plt @@ -25,7 +25,9 @@ site = location.Location(lat, lon, tz=tz) -# Define a function to handle the transposition +# 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=tz) @@ -36,13 +38,13 @@ def get_irradiance(site_location, date, tilt, surface_azimuth): # 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( + POA_irradiance = 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'], + solar_zenith=solar_position['apparent_zenith'], solar_azimuth=solar_position['azimuth']) # Return DataFrame with only GHI and POA return pd.DataFrame({'GHI': clearsky_ghi['ghi'], @@ -54,8 +56,12 @@ def get_irradiance(site_location, date, tilt, surface_azimuth): 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) +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') From 03458151c5b24bd5b0bc0c3b0f50345a126b666f Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Wed, 11 Mar 2020 20:09:28 -0400 Subject: [PATCH 17/17] Update plot_ghi_transposition.py --- docs/examples/plot_ghi_transposition.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/examples/plot_ghi_transposition.py b/docs/examples/plot_ghi_transposition.py index 29c33acdb4..5eeb27ca36 100644 --- a/docs/examples/plot_ghi_transposition.py +++ b/docs/examples/plot_ghi_transposition.py @@ -27,27 +27,28 @@ # 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 +# 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=tz) + 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_ghi = site_location.get_clearsky(times) + 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_ghi['dni'], - ghi=clearsky_ghi['ghi'], - dhi=clearsky_ghi['dhi'], + 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['ghi'], + return pd.DataFrame({'GHI': clearsky['ghi'], 'POA': POA_irradiance['poa_global']}) @@ -68,7 +69,7 @@ def get_irradiance(site_location, date, tilt, surface_azimuth): 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)') +ax1.set_ylabel('Irradiance ($W/m^2$)') ax1.legend() ax2.legend() plt.show()