I have this python function that calculates day length depending on latitude and day of the year (source : https://gist.github.com/anttilipp/ed3ab35258c7636d87de6499475301ce).
def daylength(dayOfYear, lat):
latInRad = np.deg2rad(lat)
declinationOfEarth = 23.45*np.sin(np.deg2rad(360.0*(283.0+dayOfYear)/365.0))
if -np.tan(latInRad) * np.tan(np.deg2rad(declinationOfEarth)) <= -1.0:
return 24.0
elif -np.tan(latInRad) * np.tan(np.deg2rad(declinationOfEarth)) >= 1.0:
return 0.0
else:
hourAngle = np.rad2deg(np.arccos(-np.tan(latInRad) * np.tan(np.deg2rad(declinationOfEarth))))
return 2.0*hourAngle/15.0
where dayOfYear : int and lat : float
How do I adapt this so lat uses the values from my array latarray to create a new array of the same .shape(883,1368) ?