- Timestamp:
- Mar 8, 2019, 4:07:28 PM (5 years ago)
- Branches:
- master, ctbto, dev
- Children:
- d727af2
- Parents:
- 82c2959
- Location:
- source/python
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
source/python/__init__.py
r25b14be r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* -
source/python/_config.py
rf20af73 r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* -
source/python/classes/ControlFile.py
rf20af73 r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* … … 553 553 554 554 # assign all passed command line arguments to ControlFile instance 555 for k, v in arguments.ite ritems():555 for k, v in arguments.items(): 556 556 setattr(self, str(k), v) 557 557 … … 573 573 ''' 574 574 575 for k, v in envs.ite ritems():575 for k, v in envs.items(): 576 576 setattr(self, str(k).lower(), str(v)) 577 577 -
source/python/classes/EcFlexpart.py
rf20af73 r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* … … 278 278 i = 0 279 279 for ty, st, ti in zip(ftype, fstep, ftime): 280 btlist = range(len(ftime))280 btlist = list(range(len(ftime))) 281 281 if self.basetime == 12: 282 282 btlist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] … … 398 398 self.params['OG__ML'][0] += '/U/V/ETADOT' 399 399 elif gauss and not eta: 400 self.params['GG__SL'] = ['Q', 'ML', '1', \401 '{}'.format((int(self.resol) + 1) / 2)]400 self.params['GG__SL'] = ['Q', 'ML', '1', 401 '{}'.format((int(self.resol) + 1) // 2)] 402 402 self.params['SH__ML'] = ['U/V/D', 'ML', self.glevelist, 'OFF'] 403 403 elif not gauss and not eta: … … 408 408 'use this combination only for debugging!') 409 409 self.params['GG__SL'] = ['Q', 'ML', '1', 410 '{}'.format((int(self.resol) + 1) / 2)]410 '{}'.format((int(self.resol) + 1) // 2)] 411 411 self.params['GG__ML'] = ['U/V/D/ETADOT', 'ML', self.glevelist, 412 '{}'.format((int(self.resol) + 1) / 2)]412 '{}'.format((int(self.resol) + 1) // 2)] 413 413 414 414 if omega: … … 668 668 # ftype contains field types such as 669 669 # [AN, FC, PF, CV] 670 for pk, pv in self.params.ite ritems():670 for pk, pv in self.params.items(): 671 671 # pk contains one of these keys of params 672 672 # [SH__ML, SH__SL, GG__ML, GG__SL, OG__ML, OG__SL, … … 993 993 # create correct timestamp from the three time informations 994 994 cdate = str(codes_get(gid, 'date')) 995 time = codes_get(gid, 'time') /100# integer995 time = codes_get(gid, 'time') // 100 # integer 996 996 step = codes_get(gid, 'step') # integer 997 997 ctime = '{:0>2}'.format(time) … … 1255 1255 # times into seperate end files) 1256 1256 print('... write disaggregated precipitation to files.') 1257 # index variable of disaggregated fields 1257 1258 it = 0 1259 # loop over times and write original time step and the two newly 1260 # generated sub time steps for each loop 1258 1261 for date in date_list: 1259 1262 for step in step_list: … … 1434 1437 # remove old fort.* files and open new ones 1435 1438 # they are just valid for a single product 1436 for k, f in fdict.ite ritems():1439 for k, f in fdict.items(): 1437 1440 fortfile = os.path.join(c.inputdir, 'fort.' + k) 1438 1441 silent_remove(fortfile) … … 1441 1444 # create correct timestamp from the three time informations 1442 1445 cdate = str(codes_get(gid, 'date')) 1443 ctime = '{:0>2}'.format(codes_get(gid, 'time') /100)1446 ctime = '{:0>2}'.format(codes_get(gid, 'time') // 100) 1444 1447 cstep = '{:0>3}'.format(codes_get(gid, 'step')) 1445 1448 timestamp = datetime.strptime(cdate + ctime, '%Y%m%d%H') -
source/python/classes/GribUtil.py
r268ee86 r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* -
source/python/classes/MarsRetrieval.py
rf20af73 r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* … … 434 434 f.write(str(request_number) + ', ') 435 435 f.write(', '.join(str(attrs[key]) 436 for key in sorted(attrs. iterkeys())))436 for key in sorted(attrs.keys()))) 437 437 f.write('\n') 438 438 … … 474 474 # find all keys without a value and convert all other values to strings 475 475 empty_keys = [] 476 for key, value in attrs.ite ritems():476 for key, value in attrs.items(): 477 477 if value == '': 478 478 empty_keys.append(str(key)) … … 511 511 else: 512 512 request_str = 'ret' 513 for key, value in attrs.ite ritems():513 for key, value in attrs.items(): 514 514 request_str = request_str + ',' + key + '=' + str(value) 515 515 request_str += ',target="' + target + '"' … … 519 519 stderr=subprocess.PIPE, 520 520 bufsize=1) 521 pout = p.communicate(input=request_str )[0]521 pout = p.communicate(input=request_str.encode())[0] 522 522 print(pout.decode()) 523 523 -
source/python/classes/UioFiles.py
r6f951ca r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* -
source/python/classes/__init__.py
r25b14be r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* -
source/python/install.py
r6f951ca r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* … … 367 367 in exclude_files 368 368 else tarinfo) 369 except subprocess.CalledProcessError as e: 370 print('... ERROR CODE:\n ... ' + str(e.returncode)) 371 print('... ERROR MESSAGE:\n ... ' + str(e)) 372 373 sys.exit('\n... could not make installation tar ball!') 374 except OSError as e: 375 print('... ERROR CODE: ' + str(e.errno)) 376 print('... ERROR MESSAGE:\n \t ' + str(e.strerror)) 377 378 sys.exit('\n... error occured while trying to read tar-file ' + 379 str(tarball_path)) 369 except tarfile.TarError as e: 370 sys.exit('\n... error occured while trying to create the tar-file ' + 371 str(tarball_path)) 380 372 381 373 return … … 678 670 bufsize=1) 679 671 pout, perr = p.communicate() 680 print(pout )672 print(pout.decode()) 681 673 if p.returncode != 0: 682 print(perr )674 print(perr.decode()) 683 675 print('Please edit ' + makefile + 684 676 ' or try another Makefile in the src directory.') -
source/python/mods/__init__.py
r25b14be r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* -
source/python/mods/checks.py
rf20af73 r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* … … 31 31 except ImportError: 32 32 import builtins as exceptions 33 from .tools import my_error, silent_remove34 33 from datetime import datetime 35 34 import numpy as np 35 from .tools import my_error, silent_remove 36 36 # ------------------------------------------------------------------------------ 37 37 # FUNCTIONS -
source/python/mods/disaggregation.py
r6f951ca r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* -
source/python/mods/get_mars_data.py
rf20af73 r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* … … 176 176 with open(marsfile, 'w') as f: 177 177 f.write('request_number' + ', ') 178 f.write(', '.join(str(key) for key in sorted(attrs. iterkeys())))178 f.write(', '.join(str(key) for key in sorted(attrs.keys()))) 179 179 f.write('\n') 180 180 -
source/python/mods/prepare_flexpart.py
rf20af73 r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* -
source/python/mods/profiling.py
r25b14be r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #************************************************************************ … … 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.__name__ + " took " + str(t2 - t1) + " seconds") 69 69 70 70 return result -
source/python/mods/tools.py
rf20af73 r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* … … 368 368 stderr=subprocess.PIPE, 369 369 bufsize=1) 370 pout = p.communicate(input=message + '\n\n')[0]370 pout = p.communicate(input=message.encode() + '\n\n')[0] 371 371 except ValueError as e: 372 372 print('... ERROR: ' + str(e)) … … 433 433 ''' 434 434 try: 435 pools = map(tuple, args)* kwds.get('repeat', 1)435 pools = [tuple(arg) for arg in args] * kwds.get('repeat', 1) 436 436 result = [[]] 437 437 for pool in pools: … … 533 533 ipar = [] 534 534 for par in cpar: 535 for k, v in table.ite ritems():535 for k, v in table.items(): 536 536 if par == k or par == v: 537 537 ipar.append(int(k)) … … 574 574 spar = [] 575 575 for par in cpar: 576 for k, v in table.ite ritems():576 for k, v in table.items(): 577 577 if par == k or par == v: 578 578 spar.append(k + '.128') … … 726 726 sys.exit('... ECACCESS-JOB-SUBMIT FAILED!') 727 727 728 return job_id 728 return job_id.decode() 729 729 730 730 … … 827 827 828 828 if not purefc: 829 it = ((end_date - start_date).days + 1) * 24 /int(dtime)829 it = ((end_date - start_date).days + 1) * 24 // int(dtime) 830 830 else: 831 831 # #no of step * #no of times * #no of days -
source/python/submit.py
rf20af73 r79729d5 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 # -*- coding: utf-8 -*- 3 3 #******************************************************************************* … … 68 68 import _config 69 69 from mods.tools import (setup_controldata, normal_exit, get_cmdline_args, 70 submit_job_to_ecserver, read_ecenv)70 submit_job_to_ecserver, read_ecenv) 71 71 from mods.get_mars_data import get_mars_data 72 72 from mods.prepare_flexpart import prepare_flexpart
Note: See TracChangeset
for help on using the changeset viewer.