ETo 1.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
eto/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from eto.core import ETo
2
+ import eto.datasets
3
+ import eto.methods
4
+
5
+ __version__ = '1.1.1'
eto/core.py ADDED
@@ -0,0 +1,65 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Class to estimate reference ET (ETo) from the FAO 56 paper using a minimum of T_min and T_max for daily estimates and T_mean and RH_mean for hourly, but utilizing the maximum number of available met parameters. The function prioritizes the estimation of specific parameters based on the available input data.
4
+ """
5
+ import pandas as pd
6
+ from copy import copy
7
+ from eto.param_est import param_est
8
+ from eto.methods.ETo import eto_fao
9
+ from eto.methods.hargreaves import hargreaves
10
+
11
+ #from param_est import param_est
12
+ #from methods.ETo import eto_fao
13
+ #from methods.hargreaves import hargreaves
14
+
15
+
16
+ class ETo(object):
17
+ """
18
+ Class to handle the parameter estimation of metereological values and the calcuation of reference ET and similar ET methods.
19
+
20
+ This class can be either initiated with empty parameters or will initialise to the param_est function.
21
+ """
22
+
23
+
24
+ def __init__(self, df=None, freq='D', z_msl=None, lat=None, lon=None, TZ_lon=None, z_u=2, K_rs=0.16, a_s=0.25, b_s=0.5, alb=0.23):
25
+
26
+ if df is None:
27
+ pass
28
+ else:
29
+ self.param_est(df, freq, z_msl, lat, lon, TZ_lon, z_u, K_rs, a_s, b_s, alb)
30
+
31
+
32
+ @staticmethod
33
+ def tsreg(ts, freq=None, interp=False, maxgap=None):
34
+ """
35
+ Function to regularize a time series object (pandas).
36
+ The first three indexes must be regular for freq=None!!!
37
+
38
+ Parameters
39
+ ----------
40
+ ts : DataFrame
41
+ With a DateTimeIndex.
42
+ freq : str or None
43
+ Either specify the known frequency of the data or use None and
44
+ determine the frequency from the first three indices.
45
+ interp : str
46
+ Interpolation method fro the pandas interpolate method.
47
+
48
+ Returns
49
+ -------
50
+ DataFrame
51
+ """
52
+ if freq is None:
53
+ freq = pd.infer_freq(ts.index[:3])
54
+ ts1 = ts.resample(freq).mean()
55
+ if isinstance(interp, str):
56
+ ts1 = ts1.interpolate(interp, limit=maxgap)
57
+
58
+ return ts1
59
+
60
+
61
+ ### Add in the ETo methods and other functions
62
+ ETo.param_est = param_est
63
+ ETo.eto_fao = eto_fao
64
+ ETo.eto_hargreaves = hargreaves
65
+ ETo.copy = copy
@@ -0,0 +1,27 @@
1
+ import os
2
+
3
+
4
+ __all__ = ['available', 'get_path']
5
+
6
+ _module_path = os.path.dirname(__file__)
7
+ _available_csv = {p.split('.')[0]: p for p in os.listdir(_module_path) if p.endswith('.csv.zip')}
8
+ available = list(_available_csv.keys())
9
+
10
+
11
+ def get_path(dataset):
12
+ """
13
+ Get the path to the data file.
14
+
15
+ Parameters
16
+ ----------
17
+ dataset : str
18
+ The name of the dataset. See ``geopandas.datasets.available`` for
19
+ all options.
20
+
21
+ """
22
+ if dataset in _available_csv:
23
+ return os.path.abspath(
24
+ os.path.join(_module_path, _available_csv[dataset]))
25
+ else:
26
+ msg = f"The dataset '{dataset}' is not available"
27
+ raise ValueError(msg)
Binary file
eto/methods/ETo.py ADDED
@@ -0,0 +1,56 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Function to estimate reference ET (ETo) from the FAO 56 paper using a minimum of T_min and T_max for daily estimates and T_mean and RH_mean for hourly, but utilizing the maximum number of available met parameters.
4
+ """
5
+ import pandas as pd
6
+ import numpy as np
7
+
8
+
9
+ def eto_fao(self, max_ETo=15, min_ETo=0, interp=False, maxgap=15):
10
+ """
11
+ Function to estimate reference ET (ETo) from the `FAO 56 paper <http://www.fao.org/docrep/X0490E/X0490E00.htm>`_ [1]_ using a minimum of T_min and T_max for daily estimates and T_mean and RH_mean for hourly, but optionally utilising the maximum number of available met parameters. The function prioritizes the estimation of specific parameters based on the available input data.
12
+
13
+ Parameters
14
+ ----------
15
+ max_ETo : float or int
16
+ The max realistic value of ETo (mm).
17
+ min_ETo : float or int
18
+ The min realistic value of ETo (mm).
19
+ interp : False or str
20
+ Should missing values be filled by interpolation? Either False if no interpolation should be performed, or a string of the interpolation method. See Pandas interpolate function for methods. Recommended interpolators are 'linear' or 'pchip'.
21
+ maxgap : int
22
+ The maximum missing value gap for the interpolation.
23
+
24
+ Returns
25
+ -------
26
+ DataFrame or Series
27
+ If fill=False, then the function will return a Series of estimated ETo in mm. If fill is a str, then the function will return a DataFrame with an additional column for the filled ETo value in mm.
28
+
29
+ References
30
+ ----------
31
+
32
+ .. [1] Allen, R. G., Pereira, L. S., Raes, D., & Smith, M. (1998). Crop evapotranspiration-Guidelines for computing crop water requirements-FAO Irrigation and drainage paper 56. FAO, Rome, 300(9), D05109.
33
+ """
34
+
35
+ ######
36
+ ## ETo equation
37
+ if 'h' in self.freq.lower():
38
+ ETo_FAO = (0.408*self.ts_param['delta']*(self.ts_param['R_n'] - self.ts_param['G']) + self.ts_param['gamma']*37/(self.ts_param['T_mean'] + 273)*self.ts_param['U_2']*(self.ts_param['e_mean'] - self.ts_param['e_a']))/(self.ts_param['delta'] + self.ts_param['gamma']*(1 + 0.34*self.ts_param['U_2']))
39
+ else:
40
+ ETo_FAO = (0.408*self.ts_param['delta']*(self.ts_param['R_n'] - self.ts_param['G']) + self.ts_param['gamma']*900/(self.ts_param['T_mean'] + 273)*self.ts_param['U_2']*(self.ts_param['e_s'] - self.ts_param['e_a']))/(self.ts_param['delta'] + self.ts_param['gamma']*(1 + 0.34*self.ts_param['U_2']))
41
+
42
+ ETo_FAO.name = 'ETo_FAO_mm'
43
+
44
+ ## Remove extreme values
45
+ ETo_FAO[ETo_FAO > max_ETo] = np.nan
46
+ ETo_FAO[ETo_FAO < min_ETo] = np.nan
47
+
48
+ ## ETo equation with filled holes using interpolation (use with caution)
49
+ if isinstance(interp, str):
50
+ ETo_FAO_fill = self.tsreg(ETo_FAO, self.freq, interp, maxgap)
51
+ ETo_FAO_fill.name = 'ETo_FAO_interp_mm'
52
+ ETo = pd.concat([ETo_FAO, ETo_FAO_fill], axis=1).round(2)
53
+ else:
54
+ ETo = ETo_FAO.round(2)
55
+
56
+ return ETo
@@ -0,0 +1,7 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Sun May 13 21:06:22 2018
4
+
5
+ @author: MichaelEK
6
+ """
7
+
@@ -0,0 +1,56 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Sun May 13 09:45:39 2018
4
+
5
+ @author: MichaelEK
6
+ """
7
+ import pandas as pd
8
+ import numpy as np
9
+
10
+
11
+ def hargreaves(self, max_ETo=15, min_ETo=0, interp=False, maxgap=15):
12
+ """
13
+ Function to estimate Hargreaves ETo using a minimum of T_min and T_max, but optionally utilising the maximum number of available met parameters. The function prioritizes the estimation of specific parameters based on the available input data.
14
+
15
+ Parameters
16
+ ----------
17
+ max_ETo : float or int
18
+ The max realistic value of ETo (mm).
19
+ min_ETo : float or int
20
+ The min realistic value of ETo (mm).
21
+ interp : False or str
22
+ Should missing values be filled by interpolation? Either False if no interpolation should be performed, or a string of the interpolation method. See Pandas interpolate function for methods. Recommended interpolators are 'linear' or 'pchip'.
23
+ maxgap : int
24
+ The maximum missing value gap for the interpolation.
25
+
26
+ Returns
27
+ -------
28
+ DataFrame or Series
29
+ If fill=False, then the function will return a Series of estimated ETo in mm. If fill is a str, then the function will return a DataFrame with an additional column for the filled ETo value in mm.
30
+ """
31
+
32
+ ######
33
+ ## ETo equation
34
+
35
+ if 'h' in self.freq.lower():
36
+ raise ValueError('Hargreaves should not be calculated at time frequencies of less than a day.')
37
+
38
+ ETo_Har = 0.0023*(self.ts_param['T_mean'] + 17.8)*((self.ts_param['T_max'] - self.ts_param['T_min']) **0.5)*self.ts_param['R_a']*0.408
39
+
40
+ ETo_Har.name = 'ETo_Har_mm'
41
+
42
+ ## Remove extreme values
43
+ ETo_Har[ETo_Har > max_ETo] = np.nan
44
+ ETo_Har[ETo_Har < min_ETo] = np.nan
45
+
46
+ ## ETo equation with filled holes using interpolation (use with caution)
47
+ if isinstance(interp, str):
48
+ ETo_Har_fill = self.tsreg(ETo_Har, self.freq, interp, maxgap)
49
+ ETo_Har_fill.name = 'ETo_Har_interp_mm'
50
+ ETo = pd.concat([ETo_Har, ETo_Har_fill], axis=1).round(2)
51
+ else:
52
+ ETo = ETo_Har.round(2)
53
+
54
+ return ETo
55
+
56
+
eto/param_est.py ADDED
@@ -0,0 +1,223 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Function for parameter estimation.
4
+ """
5
+ import numpy as np
6
+ import pandas as pd
7
+
8
+
9
+ def param_est(self, df, freq='D', z_msl=None, lat=None, lon=None, TZ_lon=None, z_u=2, K_rs=0.16, a_s=0.25, b_s=0.5, alb=0.23):
10
+ """
11
+ Function to estimate the parameters necessary to calculate reference ET (ETo) from the `FAO 56 paper <http://www.fao.org/docrep/X0490E/X0490E00.htm>`_ [1]_ using a minimum of T_min and T_max for daily estimates and T_mean and RH_mean for hourly, but optionally utilising the maximum number of available met parameters. The function prioritizes the estimation of specific parameters based on the available input data.
12
+
13
+ Parameters
14
+ ----------
15
+ df : DataFrame
16
+ Input Metereological data (see Notes section).
17
+ z_msl : float, int, or None
18
+ Elevation of the met station above mean sea level (m) (only needed if P is not in df).
19
+ lat : float, int, or None
20
+ The latitude of the met station (dec deg) (only needed if R_s or R_n are not in df).
21
+ lon : float, int, or None
22
+ The longitude of the met station (dec deg) (only needed if calculating ETo hourly)
23
+ TZ_lon : float, int, or None
24
+ The longitude of the center of the time zone (dec deg) (only needed if calculating ETo hourly).
25
+ z_u : float or int
26
+ The height of the wind speed measurement (m). Default is 2 m.
27
+ freq : str
28
+ The Pandas time frequency string of the input and output. The minimum frequency is hours (H) and the maximum is month (M).
29
+ K_rs : float
30
+ Rs calc coefficient (0.16 for inland stations, 0.19 for coastal stations)
31
+ a_s : float
32
+ Rs calc coefficient
33
+ b_s : float
34
+ Rs calc coefficient
35
+ alb : float
36
+ Albedo. Should be 0.23 for the reference crop.
37
+
38
+ Returns
39
+ -------
40
+ DataFrame
41
+
42
+ Notes
43
+ --------
44
+ The input data must be a DataFrame with specific column names according to the met parameter. The column names should be a minimum of T_min and T_max for daily estimates and T_mean and RH_mean for hourly, but can contain any/all of the following:
45
+
46
+ R_n
47
+ Net radiation (MJ/m2)
48
+ R_s
49
+ Incoming shortwave radiation (MJ/m2)
50
+ G
51
+ Net soil heat flux (MJ/m2)
52
+ T_min
53
+ Minimum Temperature (deg C)
54
+ T_max
55
+ Maximum Temperature (deg C)
56
+ T_mean
57
+ Mean Temperature (deg C)
58
+ T_dew
59
+ Dew point temperature (deg C)
60
+ RH_min
61
+ Minimum relative humidity
62
+ RH_max
63
+ Maximum relative humidity
64
+ RH_mean
65
+ Mean relative humidity
66
+ n_sun
67
+ Number of sunshine hours per day
68
+ U_z
69
+ Wind speed at height z (m/s)
70
+ P
71
+ Atmospheric pressure (kPa)
72
+ e_a
73
+ Actual Vapour pressure derrived from RH
74
+
75
+
76
+ Parameter estimation values refer to the quality level of the input parameters into the ETo equations. Where a 0 (or nothing) refers to no necessary parameter estimation (all measurement data was available), while a 1 refers to parameters that have the best input estimations and up to a value of 3 is the worst. Starting from the right, the first value refers to U_z, the second value refers to G, the third value refers to R_n, the fourth value refers to R_s, the fifth value refers to e_a, the sixth value refers to T_mean, the seventh value refers to P.
77
+
78
+ References
79
+ ----------
80
+
81
+ .. [1] Allen, R. G., Pereira, L. S., Raes, D., & Smith, M. (1998). Crop evapotranspiration-Guidelines for computing crop water requirements-FAO Irrigation and drainage paper 56. FAO, Rome, 300(9), D05109.
82
+ """
83
+
84
+ met_names = np.array(['R_n', 'R_s', 'G', 'T_min', 'T_max', 'T_mean', 'T_dew', 'RH_min', 'RH_max', 'RH_mean', 'n_sun', 'U_z', 'P', 'e_a'])
85
+ self.freq = freq
86
+
87
+ ####################################
88
+ ##### Set up the DataFrame and estimated values series
89
+ new_cols = met_names[~np.isin(met_names, df.columns)]
90
+ new_df = pd.DataFrame(np.nan, index=df.index, columns=new_cols)
91
+ self.ts_param = pd.concat([df, new_df], axis=1).copy()
92
+
93
+ self.est_val = pd.Series(0, index=self.ts_param.index, name='est_val')
94
+
95
+ ####################################
96
+ ###### Check to make sure minimum requirements are met
97
+ if 'h' in freq.lower():
98
+ T_mean_bool = self.ts_param['T_mean'].isnull().any()
99
+ RH_mean_bool = self.ts_param['RH_mean'].isnull().any()
100
+ e_a_bool = self.ts_param['e_a'].isnull().any()
101
+ if T_mean_bool | (RH_mean_bool & e_a_bool):
102
+ raise ValueError('Minimum data input was not met. Check your data.')
103
+ else:
104
+ T_min_bool = self.ts_param['T_min'].isnull().any()
105
+ T_max_bool = self.ts_param['T_max'].isnull().any()
106
+ if T_min_bool | T_max_bool:
107
+ raise ValueError('Minimum data input was not met. Check your data.')
108
+
109
+ ####################################
110
+ ###### Calculations
111
+
112
+ ######
113
+ ### Time index
114
+ if type(df.index) is not pd.DatetimeIndex:
115
+ raise ValueError('DataFrame must have a datetime index!')
116
+
117
+ # Create the Day of the year vector
118
+ Day = df.index.dayofyear
119
+
120
+ ######
121
+ ## Atmospheric components
122
+
123
+ # Air Pressure
124
+ self.est_val.loc[self.ts_param['P'].isnull()] = self.est_val.loc[self.ts_param['P'].isnull()] + 1000000
125
+ self.ts_param.loc[self.ts_param['P'].isnull(), 'P'] = 101.3*((293 - 0.0065*z_msl)/293)**5.26
126
+
127
+ # Psychrometric constant
128
+ self.ts_param['gamma'] = (0.665*10**-3)*self.ts_param['P']
129
+
130
+ ######
131
+ ## Temperature and humidity components
132
+ self.est_val.loc[self.ts_param['T_mean'].isnull()] = self.est_val.loc[self.ts_param['T_mean'].isnull()] + 100000
133
+ self.ts_param.loc[self.ts_param['T_mean'].isnull(), 'T_mean'] = (self.ts_param.loc[self.ts_param['T_mean'].isnull(), 'T_max'] + self.ts_param.loc[self.ts_param['T_mean'].isnull(), 'T_min'])/2
134
+
135
+ ## Vapor pressures
136
+ if 'h' in freq.lower():
137
+ self.ts_param['e_mean'] = 0.6108*np.exp(17.27*self.ts_param['T_mean']/(self.ts_param['T_mean']+237.3))
138
+ self.ts_param.loc[self.ts_param['e_a'].isnull(), 'e_a'] = self.ts_param.loc[self.ts_param['e_a'].isnull(), 'e_mean']*self.ts_param.loc[self.ts_param['e_a'].isnull(), 'RH_mean']/100
139
+ else:
140
+ self.ts_param['e_max'] = 0.6108*np.exp(17.27*self.ts_param['T_max']/(self.ts_param['T_max']+237.3))
141
+ self.ts_param['e_min'] = 0.6108*np.exp(17.27*self.ts_param['T_min']/(self.ts_param['T_min']+237.3))
142
+ self.ts_param['e_s'] = (self.ts_param['e_max']+self.ts_param['e_min'])/2
143
+
144
+ # e_a if dewpoint temperature is known
145
+ self.ts_param.loc[self.ts_param['e_a'].isnull(), 'e_a'] = 0.6108*np.exp(17.27*self.ts_param.loc[self.ts_param['e_a'].isnull(), 'T_dew']/(self.ts_param.loc[self.ts_param['e_a'].isnull(), 'T_dew'] + 237.3))
146
+
147
+ # e_a if min and max temperatures and humidities are known
148
+ self.est_val.loc[self.ts_param['T_dew'].isnull()] = self.est_val.loc[self.ts_param['T_dew'].isnull()] + 10000
149
+ self.ts_param.loc[self.ts_param['e_a'].isnull(), 'e_a'] = (self.ts_param['e_min'][self.ts_param['e_a'].isnull()] * self.ts_param.loc[self.ts_param['e_a'].isnull(), 'RH_max']/100 + self.ts_param['e_max'][self.ts_param['e_a'].isnull()] * self.ts_param.loc[self.ts_param['e_a'].isnull(), 'RH_min']/100)/2
150
+
151
+ # self.ts_param['e_a'] if only mean humidity is known
152
+ self.est_val.loc[self.ts_param['e_a'].isnull()] = self.est_val.loc[self.ts_param['e_a'].isnull()] + 10000
153
+ self.ts_param.loc[self.ts_param['e_a'].isnull(), 'e_a'] = self.ts_param.loc[self.ts_param['e_a'].isnull(), 'RH_mean']/100*(self.ts_param['e_max'][self.ts_param['e_a'].isnull()] + self.ts_param['e_min'][self.ts_param['e_a'].isnull()])/2
154
+
155
+ # e_a if humidity is not known
156
+ self.est_val.loc[self.ts_param['e_a'].isnull()] = self.est_val.loc[self.ts_param['e_a'].isnull()] + 10000
157
+ self.ts_param.loc[self.ts_param['e_a'].isnull(), 'e_a'] = 0.6108*np.exp(17.27*self.ts_param.loc[self.ts_param['e_a'].isnull(), 'T_min']/(self.ts_param.loc[self.ts_param['e_a'].isnull(), 'T_min'] + 237.3))
158
+
159
+ # Delta
160
+ self.ts_param['delta'] = 4098*(0.6108*np.exp(17.27*self.ts_param['T_mean']/(self.ts_param['T_mean'] + 237.3)))/((self.ts_param['T_mean'] + 237.3)**2)
161
+
162
+
163
+ ######
164
+ ## Raditation components
165
+
166
+ # R_a
167
+ phi = lat*np.pi/180
168
+ delta = 0.409*np.sin(2*np.pi*Day/365-1.39)
169
+ d_r = 1+0.033*np.cos(2*np.pi*Day/365)
170
+ w_s = np.arccos(-np.tan(phi)*np.tan(delta))
171
+
172
+ if 'h' in freq.lower():
173
+ hour_vec = df.index.hour
174
+ b = (2*np.pi*(Day - 81))/364
175
+ S_c = 0.1645*np.sin(2*b) - 0.1255*np.cos(b) - 0.025*np.sin(b)
176
+ w = np.pi/12*(((hour_vec+0.5) + 0.6666667*(TZ_lon - lon) + S_c) - 12)
177
+ w_1 = w - (np.pi*1)/24 # Need to update one day for different hourly periods
178
+ w_2 = w + (np.pi*1)/24 # Need to update one day for different hourly periods
179
+
180
+ self.ts_param['R_a'] = 12*60/np.pi*0.082*d_r*((w_2 - w_1)*np.sin(phi)*np.sin(delta) + np.cos(phi)*np.cos(delta)*(np.sin(w_2) - np.sin(w_1)))
181
+ else:
182
+ self.ts_param['R_a'] = 24*60/np.pi*0.082*d_r*(w_s*np.sin(phi)*np.sin(delta) + np.cos(phi)*np.cos(delta)*np.sin(w_s))
183
+
184
+ # Daylight hours
185
+ N = 24*w_s/np.pi
186
+
187
+ # R_s if n_sun is known
188
+ self.est_val.loc[self.ts_param['R_s'].isnull()] = self.est_val.loc[self.ts_param['R_s'].isnull()] + 1000
189
+ self.ts_param.loc[self.ts_param['R_s'].isnull(), 'R_s'] = (a_s + b_s*self.ts_param.loc[self.ts_param['R_s'].isnull(), 'n_sun']/N[self.ts_param['R_s'].isnull().values])*self.ts_param['R_a'][self.ts_param['R_s'].isnull().values]
190
+
191
+ # R_s if n_sun is not known
192
+ self.est_val.loc[self.ts_param['R_s'].isnull()] = self.est_val.loc[self.ts_param['R_s'].isnull()] + 1000
193
+ self.ts_param.loc[self.ts_param['R_s'].isnull(), 'R_s'] = K_rs*((self.ts_param.loc[self.ts_param['R_s'].isnull(), 'T_max'] - self.ts_param.loc[self.ts_param['R_s'].isnull(), 'T_min'])**0.5)*self.ts_param['R_a'][self.ts_param['R_s'].isnull().values]
194
+
195
+ # R_so
196
+ R_so = (0.75 + 2*10**(-5)*z_msl)*self.ts_param['R_a']
197
+
198
+ # R_ns from R_s
199
+ R_ns = (1 - alb)*self.ts_param['R_s']
200
+
201
+ # R_nl
202
+ if 'h' in freq.lower():
203
+ R_nl = (2.043*10**(-10))*((self.ts_param['T_mean'] + 273.16)**4)*(0.34-0.14*(self.ts_param['e_a']) **0.5)*((1.35*self.ts_param['R_s']/R_so) - 0.35)
204
+ else:
205
+ R_nl = (4.903*10**(-9))*(((self.ts_param['T_max'] + 273.16)**4 + (self.ts_param['T_min'] + 273.16) **4)/2)*(0.34-0.14*(self.ts_param['e_a']) **0.5)*((1.35*self.ts_param['R_s']/R_so) - 0.35)
206
+
207
+ # R_n
208
+ self.est_val.loc[self.ts_param['R_n'].isnull()] = self.est_val.loc[self.ts_param['R_n'].isnull()] + 100
209
+ self.ts_param.loc[self.ts_param['R_n'].isnull(), 'R_n'] = R_ns[self.ts_param['R_n'].isnull()] - R_nl[self.ts_param['R_n'].isnull()]
210
+
211
+ # G
212
+ self.est_val.loc[self.ts_param['G'].isnull()] = self.est_val.loc[self.ts_param['G'].isnull()] + 10
213
+ self.ts_param.loc[self.ts_param['G'].isnull(), 'G'] = 0
214
+
215
+
216
+ ######
217
+ ## Wind component
218
+
219
+ self.ts_param['U_2'] = self.ts_param['U_z']*4.87/(np.log(67.8*z_u - 5.42))
220
+
221
+ # or use 2 if wind speed is not known
222
+ self.est_val.loc[self.ts_param['U_z'].isnull()] = self.est_val.loc[self.ts_param['U_z'].isnull()] + 1
223
+ self.ts_param.loc[self.ts_param['U_z'].isnull(), 'U_2'] = 2
eto/tests/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ # the inclusion of the tests module is not meant to offer best practices for
2
+ # testing in general, but rather to support the `find_packages` example in
3
+ # setup.py that excludes installing the "tests" package
eto/tests/test_eto.py ADDED
@@ -0,0 +1,75 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Wed May 9 15:12:14 2018
4
+
5
+ @author: MichaelEK
6
+ """
7
+ import pandas as pd
8
+ import os
9
+ from eto import ETo, datasets
10
+ import pytest
11
+
12
+ ###############################
13
+ ### Parameters
14
+
15
+ # _module_path = os.path.dirname(__file__)
16
+ # example_csv = 'example_daily.csv'
17
+ # results_csv = 'example_daily_results.csv'
18
+
19
+ # example1 = os.path.join(_module_path, example_csv)
20
+ # results1 = os.path.join(_module_path, results_csv)
21
+
22
+ example1 = datasets.get_path('example_daily')
23
+ results1 = datasets.get_path('example_daily_results')
24
+
25
+ z_msl=500
26
+ lat=-43.6
27
+ lon=172
28
+ TZ_lon=173
29
+
30
+ ###############################
31
+ ### Tests
32
+
33
+ tsdata = pd.read_csv(example1, parse_dates=True, index_col='date', compression='zip')
34
+
35
+ tsresults = pd.read_csv(results1, parse_dates=True, index_col='date', compression='zip')
36
+
37
+
38
+ def test_eto_fao_daily():
39
+ et1 = ETo(tsdata, 'D', z_msl, lat, lon, TZ_lon)
40
+ eto1 = et1.eto_fao().sum()
41
+ res1 = tsresults['ETo_FAO_mm'].sum()
42
+
43
+ assert eto1 == res1
44
+
45
+ et1 = ETo(tsdata, 'D', z_msl, lat, lon, TZ_lon)
46
+
47
+ def test_eto_har_daily():
48
+ eto2 = et1.eto_hargreaves().sum()
49
+ res1 = tsresults['ETo_Har_mm'].sum()
50
+
51
+ assert eto2 == res1
52
+
53
+ def test_eto_fao_hourly():
54
+ tsdata2 = et1.ts_param[['R_s', 'T_mean', 'e_a']]
55
+ tsdata3 = et1.tsreg(tsdata2, 'h', 'time')
56
+ et2 = ETo(tsdata3, 'h', z_msl, lat, lon, TZ_lon)
57
+ eto3 = et2.eto_fao().sum()
58
+
59
+ res1 = tsresults['ETo_FAO_mm'].sum()
60
+
61
+ assert eto3 > res1
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
eto/tests/utest_eto.py ADDED
@@ -0,0 +1,52 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Wed May 9 15:12:14 2018
4
+
5
+ @author: MichaelEK
6
+ """
7
+ import pandas as pd
8
+ import os
9
+ from eto import ETo
10
+
11
+ ###############################
12
+ ### Parameters
13
+
14
+ # _module_path = os.path.dirname(__file__)
15
+ file_path = '/media/sdb1/Projects/eto/issues/mendosa'
16
+ example_csv = 'alnarp.csv'
17
+ results_csv = 'example_daily_results.csv'
18
+
19
+ example1 = os.path.join(file_path, example_csv)
20
+ # results1 = os.path.join(_module_path, results_csv)
21
+
22
+ z_msl=12
23
+ lat=55.6689
24
+ lon=13.10
25
+ TZ_lon=15
26
+
27
+ ###############################
28
+ ### Tests
29
+
30
+ tsdata1 = pd.read_table(example1, sep=';', parse_dates=True, infer_datetime_format=True, index_col='DATUM').drop('STATION', axis=1)
31
+
32
+ # tsresults = pd.read_csv(results1, parse_dates=True, infer_datetime_format=True, index_col='date')
33
+
34
+ et1 = ETo(tsdata1, 'H', z_msl, lat, lon, TZ_lon, K_rs=0.16)
35
+ eto1 = et1.eto_fao()
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
eto/util.py ADDED
@@ -0,0 +1,34 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Utility functions.
4
+ """
5
+ import pandas as pd
6
+
7
+
8
+ def tsreg(ts, freq=None, interp=False, maxgap=None):
9
+ """
10
+ Function to regularize a time series object (pandas).
11
+ The first three indeces must be regular for freq=None!!!
12
+
13
+ Parameters
14
+ ----------
15
+ ts : DataFrame
16
+ pandas time series dataframe.
17
+ freq : str
18
+ Either specify the known frequency of the data or use None and
19
+ determine the frequency from the first three indices.
20
+ interp : str
21
+ Pandas Interpolation method.
22
+
23
+ Returns
24
+ -------
25
+ DataFrame
26
+ """
27
+
28
+ if freq is None:
29
+ freq = pd.infer_freq(ts.index[:3])
30
+ ts1 = ts.resample(freq).mean()
31
+ if isinstance(interp, str):
32
+ ts1 = ts1.interpolate(interp, limit=maxgap)
33
+
34
+ return ts1
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.3
2
+ Name: ETo
3
+ Version: 1.1.1
4
+ Summary: Class and functions to estimate reference ET
5
+ Project-URL: Homepage, https://github.com/mullenkamp/ETo
6
+ Author-email: Mike Kittridge <mullenkamp1@gmail.com>
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE.txt
9
+ Keywords: et,reference
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 2
14
+ Classifier: Programming Language :: Python :: 2.7
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.4
17
+ Classifier: Programming Language :: Python :: 3.5
18
+ Classifier: Programming Language :: Python :: 3.6
19
+ Classifier: Topic :: Software Development :: Build Tools
20
+ Requires-Python: >=3.8
21
+ Requires-Dist: pandas
22
+ Description-Content-Type: text/x-rst
23
+
24
+ ETo - A Python package for calculating reference evapotranspiration
25
+ ===================================================================
26
+
27
+ The ETo package contains a class and associated functions to calculate reference evapotranspiration (ETo) using the `UN-FAO 56 paper <http://www.fao.org/docrep/X0490E/X0490E00.htm>`_. Additional functions have been added to calculate historic ETo or potential evapotranspiration (PET) for comparison purposes.
28
+
29
+ A parameter estimation function has also been added to the base class to convert most any variety of meterological parameter inputs to the necessary parameters needed to calculate ETo.
30
+
31
+ Documentation
32
+ --------------
33
+ The primary documentation for the package can be found `here <http://eto.readthedocs.io>`_.
34
+
35
+ Installation
36
+ ------------
37
+ ETo can be installed via pip or conda::
38
+
39
+ pip install eto
40
+
41
+ or::
42
+
43
+ conda install -c mullenkamp eto
44
+
45
+ The core dependency is `Pandas <http://pandas.pydata.org/pandas-docs/stable/>`_.
@@ -0,0 +1,17 @@
1
+ eto/__init__.py,sha256=Ute6xvEj-KycEGlrqwDtZLCYa2NDh7VoOK3Ktqj493c,87
2
+ eto/core.py,sha256=w8iGiDlUe1cgrOffMGL16h-I5ayYbBAqFHIA98rDzY4,2161
3
+ eto/param_est.py,sha256=uhjSLjjk6dEnYH6DrLCQolbAJ6V6YX78bYdFyrm215E,11152
4
+ eto/util.py,sha256=IGN7u42MogzsAQ6pI7SR9i-XwOqMBJbgAtzq0blIvU0,786
5
+ eto/datasets/__init__.py,sha256=3dU3tFJRdmV3QYBgdfQmWaxEdIcT4nk0-y_VKD8kcDY,678
6
+ eto/datasets/example_daily.csv.zip,sha256=1b0TJ92PmULBugV2kkY-HTBqBxlQsFJvETpCQTAHkJo,63188
7
+ eto/datasets/example_daily_results.csv.zip,sha256=QJyerR4W1VuVfJx0Qpil447FaGHQ2iHiWDw7ARLWtAI,34584
8
+ eto/methods/ETo.py,sha256=1bYcpQO8YinCfTuOFVH-s3eAFWtg1QAXCtGCzAg_Lu0,2952
9
+ eto/methods/__init__.py,sha256=PLjhQ_wdf_PFfxzV-NmzUdYvzzs5CUA1VSy1Z1-0Pw0,89
10
+ eto/methods/hargreaves.py,sha256=mArwfs-tEFbFju3QT0L0KDGXSQPz3lVKTyftfBi1jdg,2049
11
+ eto/tests/__init__.py,sha256=38pdDhEZk2RiT5kga2DPbhTYeDHdsCXNaEr7HH1-k20,208
12
+ eto/tests/test_eto.py,sha256=tDVKYB1aL2NSxOKdho1nMdHaRfKq7JXkT5qIH2rCVQs,1450
13
+ eto/tests/utest_eto.py,sha256=RlPRgwb3HJ9WmsDegig47IQXG0NWxN9i2nC7XIxSq-4,873
14
+ eto-1.1.1.dist-info/METADATA,sha256=hscImgKNnbIoxIffn5nVXSh2bl6o5vDLQ83wVFkfdv0,1842
15
+ eto-1.1.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
16
+ eto-1.1.1.dist-info/licenses/LICENSE.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
+ eto-1.1.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.25.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.