I am trying to calculate the solar potential/solar exposure of the littoral zones for a few lakes in Python. I already got the bathymetry/topographic data but I am still searching for ways to calculate the solar potential in Python. I know that there are good solutions in the QGIS SAGA and GRASS toolboxes, but I would like a solution that can be integrated into my Python processing pipeline. And I also know about Pysolar or Pvlib, but I can not find a built-in function to include the surface angle and surface orientation into the calculations.

Am I missing something or is there a good solution to include a DEM within the existing Python libraries?

1 Answer 1


Okay so I found a solution, I got a downwelling irradiance (Ed) approximation from the satellite data I was using, aswell as solar zenith angle and solar azimuth angle. From there I calculated the zenith and azimuth angles below the water surface using Snell's law, and the irradiance at the bottom of the water basin via the following functions:

import numpy as np 

def snells_law(angle):   
# Calculate the angle of refraction using Snell's law
n1 = 1  # Refractive index of air
n2 = 1.33  # Refractive index of water
theta2 = math.asin(n1 * math.sin(angle) / n2)

return theta2

def calculate_downwelling_irradiance(Ed,zenith, azimuth, tilt, orientation):
# Convert angles to radians and implement water refraction
zenith_rad = snells_law(np.radians(zenith))
azimuth_rad = snells_law(np.radians(azimuth))
tilt_rad = np.radians(tilt)
orientation_rad = np.radians(orientation)

# Calculate the angle of incidence
cos_theta = np.cos(zenith_rad) * np.cos(tilt_rad) + np.sin(zenith_rad) * np.sin(tilt_rad) * np.cos(azimuth_rad - orientation_rad)
theta = np.arccos(cos_theta)

# Calculate downwelling irradiance on the surface
Ed_surface = Ed * np.cos(theta)

return Ed_surface

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.