I am trying to create a code for the Basic evapotranspiration equation by Hargreaves. I have attached a screenshot of the equation to be replicated.
I want to create a class wherein I can input data which consists of tmin, tmax, tmean, day and lat. I have written the code below based on what I can understand from the equation.
import math
import numpy as np
class Hargreaves:
#Instantiating the class
def __init__(self, tmin, tmax, tmean, day, lat):
self.tmin = tmin
self.tmax = tmax
self.tmean = tmean
self.day = day
self.lat = lat
# latrad = pyeto.deg2rad(lat) # Convert latitude to radians
# day_of_year = datetime.date(2014, 2, 1).timetuple().tm_yday
# setting the gsc value
@property
def gsc(self):
return 0.082
# Calculating d
@property
def d(self):
return 0.409 * math.sin((2*math.pi) * (self.day/365) - 1.39)
# Calculating ws
@property
def ws(self):
return math.acos(-math.tan(self.lat) * math.tan(self.d))
# Calculating dr
@property
def dr(self):
return 1 + 0.033 * math.cos((2*math.pi) * (self.day/365))
# Calculating Radiation
@property
def ra(self):
return 24 * 60 * (self.gsc/math.pi) * self.dr * self.ws * math.sin(self.lat) * math.sin(self.d) + (math.cos(self.lat) * math.cos(self.d) * math.sin(self.ws))
# Function to calculate evapotranspiration
@property
def et(self):
return (0.0023/2.45) * (self.tmean + 17.8) * ((self.tmax - self.tmin) ** 0.5 ) * self.ra
a/b/c
is not the same asa/(b/c)
. \$\endgroup\$