import datetime

# global download configuration ==============================================================================

# modes: 'all': download all the available files
#        'nrt': download data that includes last x days
mode = 'all'

# when nrt mode, provide time period in which data should be downloaded; if mode == 'all' these dates will be overwritten
latency_days = 7
start_date = datetime.date.today() - datetime.timedelta(days = latency_days)
stop_date = datetime.date.today()

# ghost version
version = '1.6'

# want to download data?
dl_data = True

# want to download meta data?
dl_metadata = False

# number of cpus
num_cpu = 2

# download location
root = '/esarchive/obs/ghost'


# download parameters per network =============================================================================
download_params = {'US_EPA_AQS':                {'max_time_dl': 5,  'max_number_tries': 3},
                    'US_EPA_CASTNET':           {'max_time_dl': 10, 'max_number_tries': 3},
                    'EEA_AQ_eReporting':        {'max_time_dl': 5,  'max_number_tries': 3},
                    'AERONET_v3_lev1.5':        {'max_time_dl': 1,  'max_number_tries': 3},
                    'AERONET_v3_lev2.0':        {'max_time_dl': 1,  'max_number_tries': 3},
                    'BJMEMC':                   {'max_time_dl': 3,  'max_number_tries': 3},
                    'CNEMC':                    {'max_time_dl': 3,  'max_number_tries': 3},
                    'CANADA_NAPS':              {'max_time_dl': 5,  'max_number_tries': 3},
                    'CAPMoN':                   {'max_time_dl': 5,  'max_number_tries': 3},
                    'US_NADP_AMNet':            {'max_time_dl': 10, 'max_number_tries': 3},
                    'US_NADP_AMoN':             {'max_time_dl': 7,  'max_number_tries': 3},
                    'MEXICO_CDMX':              {'max_time_dl': 10, 'max_number_tries': 3},
                    'NOAA_ISD':                 {'max_time_dl': 15, 'max_number_tries': 3},
                    'MITECO':                   {'max_time_dl': 10, 'max_number_tries': 3},
                    'EANET':                    {'max_time_dl': 5,  'max_number_tries': 3},
                    'CHILE_SINCA':              {'max_time_dl': 30, 'max_number_tries': 3},
                    'EEA_AQ_eReporting':        {'max_time_dl': 20, 'max_number_tries': 3},
                    'JAPAN_NIES':               {'max_time_dl': 60, 'max_number_tries': 3},
                    'WMO_WDCGG':                {'max_time_dl': 60, 'max_number_tries': 3},
                    'UK_AIR':                   {'max_time_dl': 60, 'max_number_tries': 3},
                    'US_EPA_AirNow_DOS':        {'max_time_dl': 10, 'max_number_tries': 3}}


# networks you want to download
#networks_to_download = 'all'
networks_to_download = ['BJMEMC', 'CNEMC', 'CAPMoN', 'CANADA_NAPS']


all_networks = ['US_EPA_AirNow_DOS', 
                'US_EPA_CASTNET', 
                'BJMEMC', 
                'CNEMC', 
                'WMO_WDCGG', 
                'CAPMoN', 
                'EANET', 
                'CANADA_NAPS', 
                'CHILE_SINCA', 
                'US_NADP_AMNet', 
                'US_NADP_AMoN', 
                'MEXICO_CDMX', 
                'JAPAN_NIES',
                'MITECO', 
                'UK_AIR', 
                'NOAA_ISD', 
                'US_EPA_AQS',  
                'AERONET_v3_lev1.5',
                'AERONET_v3_lev2.0', 
                'EEA_AQ_eReporting', 
                'EBAS']


all_nrt_networks = ['US_EPA_AirNow_DOS', # download last 2 months to alwyas cover 30 days; monthly files
                    'US_EPA_CASTNET', # download 2024; error occured randomly: requests.exceptions.ConnectionError: HTTPSConnectionPool(host='gaftp.epa.gov', port=443): Max retries exceeded with url: /castnet/CASTNET_Outgoing/data/ozone_2024.zip (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f54f0e7f3d0>: Failed to establish a new connection: [Errno -2] Name or service not known'))
                    'BJMEMC', # went fine, download only last day
                    'CNEMC', # went fine, download only last day
                    'WMO_WDCGG', # downloads all data in nrt
                    'CHILE_SINCA', # ???, download last 30 days
                    'JAPAN_NIES', # went fine, download last 2 months to always cover 30 days
                    'UK_AIR', # went fine, download 2024; only one stream 'auto' -> corrected, now all streams
                    'NOAA_ISD', # went fine, download 2024
                    'AERONET_v3_lev1.5', # went fine, download only last day
                    'AERONET_v3_lev2.0', # went fine, download only last day
                    'EEA_AQ_eReporting'] # went fine, E2a stream from 2023-01-01 until now ### new download: only last 48 hours available, always download those

