-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathecmwf_data_download.py
41 lines (37 loc) · 1.91 KB
/
ecmwf_data_download.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
34
35
36
37
38
39
40
41
import os
import click
from ecmwf_utils import download_CDS_data
@click.command()
@click.option('--area', required=False)
@click.option('--start_date', required=True)
@click.option('--end_date', required=True)
@click.option('--download_path', required=True, type=click.Path(dir_okay=False))
@click.option('--download_temperature', required=True, type=click.BOOL)
@click.option('--download_dewpoint', required=True, type=click.BOOL)
@click.option('--download_pressure', required=True, type=click.BOOL)
@click.option('--download_wind_speed', required=True, type=click.BOOL)
@click.option('--download_clear_sky_solar_radiation', required=True, type=click.BOOL)
@click.option('--download_solar_radiation', required=True, type=click.BOOL)
@click.option('--overwrite', required=True, type=click.BOOL)
def main(area, start_date, end_date, download_path, download_pressure,
download_temperature, download_dewpoint, download_wind_speed,
download_clear_sky_solar_radiation, download_solar_radiation, overwrite):
fields = []
if download_temperature:
fields.extend(['2m_temperature', 'z', '2m_dewpoint_temperature', 'surface_pressure'])
if download_dewpoint and '2m_dewpoint_temperature' not in fields:
fields.append('2m_dewpoint_temperature')
if download_pressure and 'surface_pressure' not in fields:
fields.append('surface_pressure')
if download_wind_speed:
fields.extend(['100m_v_component_of_wind', '100m_u_component_of_wind'])
if download_clear_sky_solar_radiation:
fields.append("surface_solar_radiation_downward_clear_sky")
if download_solar_radiation:
fields.append('surface_solar_radiation_downwards')
download_CDS_data(start_date, end_date, fields, download_path, overwrite, area)
if __name__ == "__main__":
try:
main()
except Exception as e:
print("ERROR:" + str(e))