Changeset 25b14be in flex_extract.git for source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/mods
- Timestamp:
- Sep 23, 2018, 11:40:28 AM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 4971f63
- Parents:
- 5d42acd
- Location:
- source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/mods
- Files:
-
- 1 added
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/mods/get_mars_data.py
r2fb99de r25b14be 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 from EcFlexpart import EcFlexpart 61 from UioFiles import UioFiles 62 63 # add path to pythonpath so that python finds its buddies 64 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 61 from classes.EcFlexpart import EcFlexpart 62 from classes.UioFiles import UioFiles 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) … … 286 277 end.strftime("%Y%m%d") 287 278 288 289 279 print("... retrieve " + dates + " in dir " + c.inputdir) 290 280 -
source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/mods/plot_retrieved.py
r2fb99de r25b14be 53 53 54 54 # software specific classes and modules from flex_extract 55 from ControlFile import ControlFile 56 from UioFiles import UioFiles 57 58 # add path to pythonpath so that python finds its buddies 59 LOCAL_PYTHON_PATH = os.path.dirname(os.path.abspath( 60 inspect.getfile(inspect.currentframe()))) 61 if LOCAL_PYTHON_PATH not in sys.path: 62 sys.path.append(LOCAL_PYTHON_PATH) 55 import _config 56 from classes.ControlFile import ControlFile 57 from classes.UioFiles import UioFiles 63 58 64 59 font = {'family': 'monospace', 'size': 12} -
source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/mods/prepare_flexpart.py
r2fb99de r25b14be 57 57 import sys 58 58 import socket 59 import _config60 59 61 60 # software specific classes and modules from flex_extract 62 from UioFiles import UioFiles 61 import _config 62 from classes.UioFiles import UioFiles 63 63 from tools import clean_up, get_cmdline_arguments, read_ecenv 64 from EcFlexpart import EcFlexpart64 from classes.EcFlexpart import EcFlexpart 65 65 66 66 ecapi = 'ecmwf' not in socket.gethostname() … … 70 70 except ImportError: 71 71 ecapi = False 72 73 # add path to pythonpath so that python finds its buddies74 LOCAL_PYTHON_PATH = os.path.dirname(os.path.abspath(75 inspect.getfile(inspect.currentframe())))76 if LOCAL_PYTHON_PATH not in sys.path:77 sys.path.append(LOCAL_PYTHON_PATH)78 79 72 80 73 # ------------------------------------------------------------------------------ … … 100 93 c = ControlFile(args.controlfile) 101 94 except IOError: 102 try: 103 c = ControlFile(LOCAL_PYTHON_PATH + args.controlfile) 104 except IOError: 105 print 'Could not read CONTROL file "' + args.controlfile + '"' 106 print 'Either it does not exist or its syntax is wrong.' 107 print 'Try "' + sys.argv[0].split('/')[-1] + \ 108 ' -h" to print usage information' 109 sys.exit(1) 95 print('Could not read CONTROL file "' + args.controlfile + '"') 96 print('Either it does not exist or its syntax is wrong.') 97 print('Try "' + sys.argv[0].split('/')[-1] + \ 98 ' -h" to print usage information') 99 sys.exit(1) 110 100 111 env_parameter = read_ecenv( c.ecmwfdatadir + 'python/ECMWF_ENV')101 env_parameter = read_ecenv(_config.PATH_ECMWF_ENV) 112 102 c.assign_args_to_control(args, env_parameter) 113 103 c.assign_envs_to_control(env_parameter) 114 c.check_conditions( )104 c.check_conditions(args.queue) 115 105 prepare_flexpart(args.ppid, c) 116 106 … … 170 160 start = start - datetime.timedelta(days=1) 171 161 172 print 'Prepare ' + start.strftime("%Y%m%d") + \173 "/to/" + end.strftime("%Y%m%d") 162 print('Prepare ' + start.strftime("%Y%m%d") + 163 "/to/" + end.strftime("%Y%m%d")) 174 164 175 165 # create output dir if necessary … … 182 172 # deaccumulate the flux data 183 173 flexpart = EcFlexpart(c, fluxes=True) 184 flexpart.write_namelist(c, 'fort.4')174 flexpart.write_namelist(c, _config.FILE_NAMELIST) 185 175 flexpart.deacc_fluxes(inputfiles, c) 186 176 … … 197 187 # otherwise delete temporary files 198 188 if int(c.debug) != 0: 199 print '\nTemporary files left intact'189 print('\nTemporary files left intact') 200 190 else: 201 191 clean_up(c) -
source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/mods/profiling.py
r2fb99de r25b14be 66 66 result = fn(*args, **kwargs) 67 67 t2 = time.time() 68 print "@timefn:" + fn.func_name + " took " + str(t2 - t1) + " seconds"68 print("@timefn:" + fn.func_name + " took " + str(t2 - t1) + " seconds") 69 69 70 70 return result -
source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/mods/tools.py
r2fb99de r25b14be 140 140 @Input: 141 141 filename: string 142 Name offile where the ECMWV environment parameters are stored.142 Path to file where the ECMWV environment parameters are stored. 143 143 144 144 @Return: 145 145 envs: dict 146 Contains the environment parameter ecuid, ecgid, gateway 147 and destination for ECMWF server environments. 146 148 ''' 147 149 envs= {} 148 print filename 150 149 151 with open(filename, 'r') as f: 150 152 for line in f: … … 178 180 ''' 179 181 180 print "clean_up"182 print("clean_up") 181 183 182 184 cleanlist = glob.glob(c.inputdir + "/*") … … 187 189 silent_remove(clist) 188 190 189 print "Done"191 print("Done") 190 192 191 193 return … … 211 213 ''' 212 214 213 print message215 print(message) 214 216 215 217 # comment if user does not want email notification directly from python … … 227 229 pout = p.communicate(input=message + '\n\n' + trace)[0] 228 230 except ValueError as e: 229 print 'ERROR: ', e231 print('ERROR: ', e) 230 232 sys.exit('Email could not be sent!') 231 233 else: 232 print 'Email sent to ' + os.path.expandvars(user) + ' ' + \233 pout.decode() 234 print('Email sent to ' + os.path.expandvars(user) + ' ' + 235 pout.decode()) 234 236 235 237 sys.exit(1) … … 256 258 257 259 ''' 258 print message260 print(message) 259 261 260 262 # comment if user does not want notification directly from python … … 271 273 pout = p.communicate(input=message+'\n\n')[0] 272 274 except ValueError as e: 273 print 'ERROR: ', e274 print 'Email could not be sent!'275 print('ERROR: ', e) 276 print('Email could not be sent!') 275 277 else: 276 print 'Email sent to ' + os.path.expandvars(user) + ' ' + \277 pout.decode() 278 print('Email sent to ' + os.path.expandvars(user) + ' ' + 279 pout.decode()) 278 280 279 281 return … … 395 397 break 396 398 else: 397 print 'Warning: par ' + par + ' not found in table 128'399 print('Warning: par ' + par + ' not found in table 128') 398 400 399 401 return ipar … … 441 443 raise # re-raise exception if a different error occured 442 444 else: 443 print 'WARNING: Directory {0} already exists!'.format(directory)445 print('WARNING: Directory {0} already exists!'.format(directory)) 444 446 445 447 return
Note: See TracChangeset
for help on using the changeset viewer.