Spaces:
Runtime error
Runtime error
mohamed.tsouli
commited on
Commit
·
6a1c12b
1
Parent(s):
1e9c075
add function compute et0
Browse files- compute_et0_adjusted.py +76 -0
- docs/agro_indicators.py +1 -1
compute_et0_adjusted.py
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import docs.agro_indicators as agro_indicators
|
2 |
+
import datetime
|
3 |
+
import pandas as pd
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
|
7 |
+
def compute_et0_future(
|
8 |
+
df: pd.DataFrame,
|
9 |
+
latitude: float,
|
10 |
+
longitude: float
|
11 |
+
):
|
12 |
+
"""
|
13 |
+
Compute reference evapotranspiration.
|
14 |
+
|
15 |
+
Parameters
|
16 |
+
----------
|
17 |
+
df : DataFrame
|
18 |
+
The input dataframe containing sensor data.
|
19 |
+
|
20 |
+
latitude : float
|
21 |
+
Latitude of the location.
|
22 |
+
longitude : float
|
23 |
+
Longitude of the location
|
24 |
+
|
25 |
+
Returns
|
26 |
+
-------
|
27 |
+
arraylike
|
28 |
+
Daily reference evapotranspiration.
|
29 |
+
"""
|
30 |
+
|
31 |
+
irradiance = df.irradiance
|
32 |
+
Tmin = df.air_temperature_min
|
33 |
+
Tmax = df.air_temperature_max
|
34 |
+
T = (Tmin + Tmin) / 2
|
35 |
+
RHmin = df.relative_humidity_min
|
36 |
+
RHmax = df.relative_humidity_max
|
37 |
+
WS = df.wind_speed
|
38 |
+
month = df.month
|
39 |
+
year = df.year
|
40 |
+
first_day = datetime.date(year, month, 1)
|
41 |
+
day_of_year = first_day.timetuple().tm_yday
|
42 |
+
JJulien = day_of_year
|
43 |
+
|
44 |
+
l = agro_indicators.et0(
|
45 |
+
irradiance,
|
46 |
+
T,
|
47 |
+
Tmax,
|
48 |
+
Tmin,
|
49 |
+
RHmin,
|
50 |
+
RHmax,
|
51 |
+
WS,
|
52 |
+
JJulien,
|
53 |
+
latitude,
|
54 |
+
longitude,
|
55 |
+
)
|
56 |
+
|
57 |
+
return l
|
58 |
+
|
59 |
+
|
60 |
+
if __name__ == "__main__":
|
61 |
+
data_test = pd.DataFrame()
|
62 |
+
data_test["irradiance"] = [20, 30, 40]
|
63 |
+
data_test["air_temperature_min"] = [10, 15, 20]
|
64 |
+
data_test["air_temperature_max"] = [20, 25, 30]
|
65 |
+
data_test["relative_humidity_min"] = [50, 60, 70]
|
66 |
+
data_test["relative_humidity_max"] = [50, 60, 70]
|
67 |
+
data_test["wind_speed"] = [5, 10, 15]
|
68 |
+
data_test["month"] = [1, 2, 3]
|
69 |
+
data_test["year"] = [2020, 2020, 2020]
|
70 |
+
|
71 |
+
latitude = 40.7128
|
72 |
+
longitude = 74.0060
|
73 |
+
|
74 |
+
for i in range(len(data_test)):
|
75 |
+
et0 = compute_et0_future(data_test.iloc[i], latitude, longitude)
|
76 |
+
print(et0)
|
docs/agro_indicators.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import numpy as np
|
2 |
from pvlib.location import lookup_altitude
|
3 |
-
from
|
4 |
|
5 |
def et0(irradiance, T, Tmax, Tmin, RHmin, RHmax, WS, JJulien, latitude, longitude):
|
6 |
"""
|
|
|
1 |
import numpy as np
|
2 |
from pvlib.location import lookup_altitude
|
3 |
+
from docs.pyeto import fao
|
4 |
|
5 |
def et0(irradiance, T, Tmax, Tmin, RHmin, RHmax, WS, JJulien, latitude, longitude):
|
6 |
"""
|