Newer
Older
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
configure and run the download of network data
"""
# import python modules
import argparse
# import all the download scripts
import CNEMC_download
import WMO_WDCGG_download
import BJMEMC_download
import US_EPA_CASTNET_download
import US_EPA_AirNow_DOS_download
import EEA_AQ_eReporting_download
import CAPMoN_download
import EANET_download
import CANADA_NAPS_download
import CHILE_SINCA_download
import US_NADP_AMNet_download
import US_NADP_AMoN_download
import MEXICO_CDMX_download
import JAPAN_NIES_download
import MITECO_download
import UK_AIR_download
import NOAA_ISD_download
import US_EPA_AQS_download
import AERONETv3_download
import EEA_AQ_eReporting_download
import EBAS_download
if __name__ == "__main__":
# add arguments
#parser = argparse.ArgumentParser(description="Script that runs network downloads")
#parser.add_argument("--mode", type=str, help="Enter 'all' for entire time period or 'nrt' for most recent file", default='nrt')
#args = parser.parse_args()
# modes: 'all': download all the available files
# 'nrt': download most recent file
mode = 'nrt'
print("Mode: {}".format(mode))
# ghost version
version = '1.6'
print("Ghost version: {}".format(version))
# maximum number of downloads attempts
n_max_tries = 3
# maximum time one download attempt should take per network
download_params = {'US_EPA_AQS': {'max_time_dl': 5},
'US_EPA_AirNow_DOS': {'max_time_dl': 10},
'US_EPA_CASTNET': {'max_time_dl': 10},
'EEA_AQ_eReporting': {'max_time_dl': 5},
'AERONETv3': {'max_time_dl': 1},
'BJMEMC': {'max_time_dl': 3},
'CNEMC': {'max_time_dl': 3}}
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# download all networks
#networks = ['all']
if networks == 'all':
networks = [US_EPA_AirNow_DOS_download,
US_EPA_CASTNET_download,
BJMEMC_download,
CNEMC_download,
WMO_WDCGG_download,
CAPMoN_download,
EANET_download,
CANADA_NAPS_download,
CHILE_SINCA_download,
US_NADP_AMNet_download,
US_NADP_AMoN_download,
MEXICO_CDMX_download,
JAPAN_NIES_download,
MITECO_download,
UK_AIR_download,
NOAA_ISD_download,
US_EPA_AQS_download,
AERONETv3_download,
EEA_AQ_eReporting_download,
EBAS_download]
# run the desired networks
for network in networks:
network_name = str(network).split('/')[-1].split('_download')[0]
max_time_per_dl = download_params[network_name]['max_time_dl']
if dl_data == True:
network.download_data(mode, version, n_max_tries, max_time_per_dl)
pass
if dl_metadata == True:
network.download_metadata(n_max_tries, max_time_per_dl)