Changeset f20af73 in flex_extract.git for source/python/mods/get_mars_data.py
- Timestamp:
- Mar 8, 2019, 10:05:20 AM (5 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 82c2959
- Parents:
- b4a4777
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/python/mods/get_mars_data.py
r45b99e6 rf20af73 67 67 inspect.getfile(inspect.currentframe()))) + '/../') 68 68 import _config 69 from tools import (my_error, normal_exit, get_cmdline_args,69 from .tools import (setup_controldata, my_error, normal_exit, get_cmdline_args, 70 70 read_ecenv, make_dir) 71 71 from classes.EcFlexpart import EcFlexpart … … 74 74 75 75 try: 76 ec api = True76 ec_api = True 77 77 import ecmwfapi 78 78 except ImportError: 79 ecapi = False 79 ec_api = False 80 81 try: 82 cds_api = True 83 import cdsapi 84 except ImportError: 85 cds_api = False 80 86 # ------------------------------------------------------------------------------ 81 87 # FUNCTION … … 95 101 ''' 96 102 97 args = get_cmdline_args() 98 c = ControlFile(args.controlfile) 99 100 env_parameter = read_ecenv(_config.PATH_ECMWF_ENV) 101 c.assign_args_to_control(args) 102 c.assign_envs_to_control(env_parameter) 103 c.check_conditions(args.queue) 104 103 c, _, _, _ = setup_controldata() 105 104 get_mars_data(c) 106 normal_exit( c.mailops, c.queue, 'Done!')105 normal_exit('Retrieving MARS data: Done!') 107 106 108 107 return … … 125 124 126 125 ''' 127 c.ecapi = ecapi 126 c.ec_api = ec_api 127 c.cds_api = cds_api 128 128 129 129 if not os.path.exists(c.inputdir): … … 182 182 183 183 def mk_server(c): 184 '''Creates server connection if ECMWF WebAPI is available. 184 '''Creates a server connection with available python API. 185 186 Which API is used depends on availability and the dataset to be retrieved. 187 The CDS API is used for ERA5 dataset no matter if the user is a member or 188 a public user. ECMWF WebAPI is used for all other available datasets. 185 189 186 190 Parameters … … 192 196 Return 193 197 ------ 194 server : ECMWFDataServer or ECMWFService 195 Connection to ECMWF server via python interface ECMWF WebAPI. 196 197 ''' 198 if c.ecapi: 198 server : ECMWFDataServer, ECMWFService or Client 199 Connection to ECMWF server via python interface ECMWF WebAPI or CDS API. 200 201 ''' 202 if cds_api and (c.marsclass.upper() == 'EA'): 203 server = cdsapi.Client() 204 c.ec_api = False 205 elif c.ec_api: 199 206 if c.public: 200 207 server = ecmwfapi.ECMWFDataServer() 201 208 else: 202 209 server = ecmwfapi.ECMWFService("mars") 210 c.cds_api = False 203 211 else: 204 212 server = False 205 213 206 print('Using ECMWF WebAPI: ' + str(c.ecapi)) 214 print('Using ECMWF WebAPI: ' + str(c.ec_api)) 215 print('Using CDS API: ' + str(c.cds_api)) 207 216 208 217 return server … … 353 362 flexpart.retrieve(server, dates, c.public, c.request, c.inputdir) 354 363 except IOError: 355 my_error( c.mailfail,'MARS request failed')364 my_error('MARS request failed') 356 365 357 366 day += delta_t
Note: See TracChangeset
for help on using the changeset viewer.