-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdaily_evapotranspiration.py
33 lines (25 loc) · 1.22 KB
/
daily_evapotranspiration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import click
import numpy as np
import snappy_utils as su
from pyTSEB import meteo_utils as met
@click.command()
@click.option('--ief_file', required=True, type=click.Path(dir_okay=False, exists=True))
@click.option('--mi_file', required=True, type=click.Path(dir_okay=False, exists=True))
@click.option('--output_file', required=True, type=click.Path(dir_okay=False, exists=False))
def main(ief_file, mi_file, output_file):
# Read the required data
le_band, geo_coding = su.read_snappy_product(ief_file, 'latent_heat_flux')
le_band = le_band.astype(np.float32)
sdn_band = su.read_snappy_product(mi_file, 'clear_sky_solar_radiation')[0].astype(np.float32)
sdn_24_band = su.read_snappy_product(mi_file, 'average_daily_solar_irradiance')[0].astype(np.float32)
le = np.array(le_band)
sdn = np.array(sdn_band)
sdn_24 = np.array(sdn_24_band)
et_daily = met.flux_2_evaporation(sdn_24 * le / sdn, T_K=20+273.15, time_domain=24)
su.write_snappy_product(output_file, [{'band_name': 'daily_evapotranspiration', 'band_data': et_daily}],
'dailySpectra', geo_coding)
if __name__ == "__main__":
try:
main()
except Exception as e:
print("ERROR:" + str(e))