Changeset 2fb99de in flex_extract.git for python/get_mars_data.py
- Timestamp:
- Sep 20, 2018, 11:56:37 AM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 5d42acd
- Parents:
- 3232589
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/get_mars_data.py
r54a8a01 r2fb99de 57 57 58 58 # software specific classes and modules from flex_extract 59 import _config 59 60 from tools import my_error, normal_exit, get_cmdline_arguments, read_ecenv 60 61 from EcFlexpart import EcFlexpart 61 62 from UioFiles import UioFiles 62 63 # add path to pythonpath so that python finds its buddies64 LOCAL_PYTHON_PATH = os.path.dirname(os.path.abspath(65 inspect.getfile(inspect.currentframe())))66 if LOCAL_PYTHON_PATH not in sys.path:67 sys.path.append(LOCAL_PYTHON_PATH)68 69 63 # ------------------------------------------------------------------------------ 70 64 # FUNCTION … … 89 83 c = ControlFile(args.controlfile) 90 84 except IOError: 91 try: 92 c = ControlFile(LOCAL_PYTHON_PATH + args.controlfile) 93 except IOError: 94 print 'Could not read CONTROL file "' + args.controlfile + '"' 95 print 'Either it does not exist or its syntax is wrong.' 96 print 'Try "' + sys.argv[0].split('/')[-1] + \ 97 ' -h" to print usage information' 98 sys.exit(1) 99 100 env_parameter = read_ecenv(c.ecmwfdatadir + 'python/ECMWF_ENV') 85 print('Could not read CONTROL file "' + args.controlfile + '"') 86 print('Either it does not exist or its syntax is wrong.') 87 print('Try "' + sys.argv[0].split('/')[-1] + \ 88 ' -h" to print usage information') 89 sys.exit(1) 90 91 env_parameter = read_ecenv(_config.PATH_ECMWF_ENV) 101 92 c.assign_args_to_control(args, env_parameter) 102 93 c.assign_envs_to_control(env_parameter) 103 c.check_conditions( )94 c.check_conditions(args.queue) 104 95 105 96 get_mars_data(c) … … 137 128 os.makedirs(c.inputdir) 138 129 139 print "Retrieving EC data!" 140 print "start date %s " % (c.start_date) 141 print "end date %s " % (c.end_date) 130 if c.request == 0 or c.request == 2: 131 print("Retrieving EC data!") 132 elif c.request == 1: 133 print("Printing mars requests!") 134 135 print("start date %s " % (c.start_date)) 136 print("end date %s " % (c.end_date)) 142 137 143 138 if ecapi: … … 147 142 148 143 c.ecapi = ecapi 149 print 'ecapi: ', c.ecapi144 print('Using ECMWF WebAPI: ' + str(c.ecapi)) 150 145 151 146 # basetime geht rückwärts … … 192 187 193 188 # -------------- flux data ------------------------------------------------ 194 print 'removing old flux content of ' + c.inputdir 195 tobecleaned = UioFiles(c.inputdir, 196 '*_acc_*.' + str(os.getppid()) + '.*.grb') 197 tobecleaned.delete_files() 189 if c.request == 0 or c.request == 2: 190 print('... removing old flux content of ' + c.inputdir) 191 tobecleaned = UioFiles(c.inputdir, 192 '*_acc_*.' + str(os.getppid()) + '.*.grb') 193 tobecleaned.delete_files() 198 194 199 195 # if forecast for maximum one day (upto 24h) are to be retrieved, … … 213 209 214 210 # -------------- non flux data -------------------------------------------- 215 print 'removing old non flux content of ' + c.inputdir 216 tobecleaned = UioFiles(c.inputdir, 217 '*__*.' + str(os.getppid()) + '.*.grb') 218 tobecleaned.delete_files() 211 if c.request == 0 or c.request == 2: 212 print('... removing old non flux content of ' + c.inputdir) 213 tobecleaned = UioFiles(c.inputdir, 214 '*__*.' + str(os.getppid()) + '.*.grb') 215 tobecleaned.delete_files() 219 216 220 217 do_retrievement(c, server, start, end, datechunk, fluxes=False) … … 280 277 end.strftime("%Y%m%d") 281 278 282 print "retrieve " + dates + " in dir " + c.inputdir279 print("... retrieve " + dates + " in dir " + c.inputdir) 283 280 284 281 try: 285 flexpart.retrieve(server, dates, c. inputdir)282 flexpart.retrieve(server, dates, c.request, c.inputdir) 286 283 except IOError: 287 284 my_error(c.mailfail, 'MARS request failed')
Note: See TracChangeset
for help on using the changeset viewer.