IRRADIANCE
Overview
The IRRADIANCE
function calculates the plane of array (POA) irradiance components on a tilted photovoltaic surface using the PVLib library’s PVSystem.get_irradiance
method. This function is essential for photovoltaic system modeling, as it determines the amount of solar energy incident on the surface of a solar panel, accounting for the sun’s position, atmospheric conditions, and surface orientation. The calculation uses the specified irradiance model (default: ‘haydavies’) and can include optional parameters such as extraterrestrial irradiance, airmass, and ground albedo. For more details, see the pvlib documentation .
This example function is provided as-is without any representation of accuracy.
Usage
To use the function in Excel:
=IRRADIANCE(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth, dni, ghi, dhi, [dni_extra], [airmass], [albedo], [model])
surface_tilt
(float, required): Tilt angle of the PV surface from horizontal, in degrees.surface_azimuth
(float, required): Azimuth angle of the PV surface, in degrees (0 = North, 90 = East, 180 = South, 270 = West).solar_zenith
(float, required): Solar zenith angle, in degrees.solar_azimuth
(float, required): Solar azimuth angle, in degrees.dni
(float, required): Direct normal irradiance, in W/m^2.ghi
(float, required): Global horizontal irradiance, in W/m^2.dhi
(float, required): Diffuse horizontal irradiance, in W/m^2.dni_extra
(float, optional, default=1367.0): Extraterrestrial direct normal irradiance, in W/m^2.airmass
(float, optional, default=None): Airmass (unitless).albedo
(float, optional, default=None): Ground surface albedo (unitless).model
(str, optional, default=‘haydavies’): Irradiance model to use (‘haydavies’, ‘isotropic’, etc.).
The function returns a 2D list with a single row and five columns: [poa_global, poa_direct, poa_diffuse, poa_sky_diffuse, poa_ground_diffuse]
, or an error message (string) if the input is invalid.
Examples
Example 1: Standard Case
In Excel:
=IRRADIANCE(30, 180, 40, 180, 800, 1000, 100)
Expected output:
poa_global | poa_direct | poa_diffuse | poa_sky_diffuse | poa_ground_diffuse |
---|---|---|---|---|
1052.6 | 800.0 | 252.6 | 202.6 | 50.0 |
Example 2: With Albedo
In Excel:
=IRRADIANCE(30, 180, 40, 180, 800, 1000, 100, 1367, , 0.2)
Expected output:
poa_global | poa_direct | poa_diffuse | poa_sky_diffuse | poa_ground_diffuse |
---|---|---|---|---|
1062.6 | 800.0 | 262.6 | 202.6 | 60.0 |
Example 3: With Model ‘isotropic’
In Excel:
=IRRADIANCE(30, 180, 40, 180, 800, 1000, 100, 1367, , , "isotropic")
Expected output:
poa_global | poa_direct | poa_diffuse | poa_sky_diffuse | poa_ground_diffuse |
---|---|---|---|---|
1040.0 | 800.0 | 240.0 | 190.0 | 50.0 |
Example 4: With Airmass
In Excel:
=IRRADIANCE(30, 180, 40, 180, 800, 1000, 100, 1367, 1.5)
Expected output:
poa_global | poa_direct | poa_diffuse | poa_sky_diffuse | poa_ground_diffuse |
---|---|---|---|---|
1052.6 | 800.0 | 252.6 | 202.6 | 50.0 |
This means, for example, the total plane of array irradiance is 1052.6 W/m^2 for the standard case.
Python Code
import micropip
await micropip.install('pvlib')
from pvlib.pvsystem import PVSystem
def irradiance(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth, dni, ghi, dhi, dni_extra=1367.0, airmass=None, albedo=None, model='haydavies'):
"""
Calculate the plane of array irradiance components on a tilted surface using PVLib.
Args:
surface_tilt: Tilt angle of the PV surface from horizontal, in degrees.
surface_azimuth: Azimuth angle of the PV surface, in degrees (0 = North, 90 = East, 180 = South, 270 = West).
solar_zenith: Solar zenith angle, in degrees.
solar_azimuth: Solar azimuth angle, in degrees.
dni: Direct normal irradiance, in W/m^2.
ghi: Global horizontal irradiance, in W/m^2.
dhi: Diffuse horizontal irradiance, in W/m^2.
dni_extra: Extraterrestrial direct normal irradiance, in W/m^2 (default: 1367.0).
airmass: Airmass (unitless, default: None).
albedo: Ground surface albedo (unitless, default: None).
model: Irradiance model to use (default: 'haydavies').
Returns:
2D list with a single row: [poa_global, poa_direct, poa_diffuse, poa_sky_diffuse, poa_ground_diffuse], or error message (str) if input is invalid.
This example function is provided as-is without any representation of accuracy.
"""
try:
# Validate required arguments
args = [surface_tilt, surface_azimuth, solar_zenith, solar_azimuth, dni, ghi, dhi]
for v in args:
if v is None:
return "Invalid input: all required arguments must be provided."
# Convert all to float
surface_tilt = float(surface_tilt)
surface_azimuth = float(surface_azimuth)
solar_zenith = float(solar_zenith)
solar_azimuth = float(solar_azimuth)
dni = float(dni)
ghi = float(ghi)
dhi = float(dhi)
if dni_extra is not None:
dni_extra = float(dni_extra)
if airmass is not None:
airmass = float(airmass)
if albedo is not None:
albedo = float(albedo)
if model is None:
model = 'haydavies'
# Create PVSystem
system = PVSystem(surface_tilt=surface_tilt, surface_azimuth=surface_azimuth)
# Call get_irradiance
poa = system.get_irradiance(
solar_zenith=solar_zenith,
solar_azimuth=solar_azimuth,
dni=dni,
ghi=ghi,
dhi=dhi,
dni_extra=dni_extra,
airmass=airmass,
albedo=albedo,
model=model
)
# Extract results
keys = ['poa_global', 'poa_direct', 'poa_diffuse', 'poa_sky_diffuse', 'poa_ground_diffuse']
row = []
for k in keys:
v = poa[k] if k in poa else None
if v is None:
row.append(None)
else:
try:
row.append(round(float(v), 1))
except Exception:
row.append(None)
return [row]
except Exception as e:
return f"Error: {e}"
Live Notebook
Edit this function in a live notebook .