The maximum possible daylight hours can be calculated as:
where is the sunset hour angle in radians.
The following Python code demonstrates the calculation of possible daylight hours based on the calculation of sunset hour angles that depend on the calculation of solar declination
from pylab import * from numpy import * def daylighthours(latitude,J): ds=0.4093*sin(2*pi/365*J-1.405) # to be replaced by class sha=arccos(-tan(latitude)*tan(ds)) # to be replaced by class dh=24/pi*sha return dh latitude=23 J=arange(1,365,1) plot(J,daylighthours(latitude,J)) ytext = ylabel('daylight hours') xtext = xlabel('Julian day') show()