Changeset 79729d5 in flex_extract.git


Ignore:
Timestamp:
Mar 8, 2019, 4:07:28 PM (7 weeks ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
dev
Children:
d727af2
Parents:
82c2959
Message:

switched from python2 to python3

Files:
20 edited

Legend:

Unmodified
Added
Removed
  • source/python/__init__.py

    r25b14be r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
  • source/python/_config.py

    rf20af73 r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
  • source/python/classes/ControlFile.py

    rf20af73 r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
     
    553553
    554554        # assign all passed command line arguments to ControlFile instance
    555         for k, v in arguments.iteritems():
     555        for k, v in arguments.items():
    556556            setattr(self, str(k), v)
    557557
     
    573573        '''
    574574
    575         for k, v in envs.iteritems():
     575        for k, v in envs.items():
    576576            setattr(self, str(k).lower(), str(v))
    577577
  • source/python/classes/EcFlexpart.py

    rf20af73 r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
     
    278278        i = 0
    279279        for ty, st, ti in zip(ftype, fstep, ftime):
    280             btlist = range(len(ftime))
     280            btlist = list(range(len(ftime)))
    281281            if self.basetime == 12:
    282282                btlist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
     
    398398            self.params['OG__ML'][0] += '/U/V/ETADOT'
    399399        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)]
    402402            self.params['SH__ML'] = ['U/V/D', 'ML', self.glevelist, 'OFF']
    403403        elif not gauss and not eta:
     
    408408                           'use this combination only for debugging!')
    409409            self.params['GG__SL'] = ['Q', 'ML', '1',
    410                                      '{}'.format((int(self.resol) + 1) / 2)]
     410                                     '{}'.format((int(self.resol) + 1) // 2)]
    411411            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)]
    413413
    414414        if omega:
     
    668668            # ftype contains field types such as
    669669            #     [AN, FC, PF, CV]
    670             for pk, pv in self.params.iteritems():
     670            for pk, pv in self.params.items():
    671671                # pk contains one of these keys of params
    672672                #     [SH__ML, SH__SL, GG__ML, GG__SL, OG__ML, OG__SL,
     
    993993            # create correct timestamp from the three time informations
    994994            cdate = str(codes_get(gid, 'date'))
    995             time = codes_get(gid, 'time')/100 # integer
     995            time = codes_get(gid, 'time') // 100 # integer
    996996            step = codes_get(gid, 'step') # integer
    997997            ctime = '{:0>2}'.format(time)
     
    12551255        # times into seperate end files)
    12561256        print('... write disaggregated precipitation to files.')
     1257        # index variable of disaggregated fields
    12571258        it = 0
     1259        # loop over times and write original time step and the two newly
     1260        # generated sub time steps for each loop
    12581261        for date in date_list:
    12591262            for step in step_list:
     
    14341437            # remove old fort.* files and open new ones
    14351438            # they are just valid for a single product
    1436             for k, f in fdict.iteritems():
     1439            for k, f in fdict.items():
    14371440                fortfile = os.path.join(c.inputdir, 'fort.' + k)
    14381441                silent_remove(fortfile)
     
    14411444            # create correct timestamp from the three time informations
    14421445            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)
    14441447            cstep = '{:0>3}'.format(codes_get(gid, 'step'))
    14451448            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
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
  • source/python/classes/MarsRetrieval.py

    rf20af73 r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
     
    434434            f.write(str(request_number) + ', ')
    435435            f.write(', '.join(str(attrs[key])
    436                               for key in sorted(attrs.iterkeys())))
     436                              for key in sorted(attrs.keys())))
    437437            f.write('\n')
    438438
     
    474474        # find all keys without a value and convert all other values to strings
    475475        empty_keys = []
    476         for key, value in attrs.iteritems():
     476        for key, value in attrs.items():
    477477            if value == '':
    478478                empty_keys.append(str(key))
     
    511511        else:
    512512            request_str = 'ret'
    513             for key, value in attrs.iteritems():
     513            for key, value in attrs.items():
    514514                request_str = request_str + ',' + key + '=' + str(value)
    515515            request_str += ',target="' + target + '"'
     
    519519                                 stderr=subprocess.PIPE,
    520520                                 bufsize=1)
    521             pout = p.communicate(input=request_str)[0]
     521            pout = p.communicate(input=request_str.encode())[0]
    522522            print(pout.decode())
    523523
  • source/python/classes/UioFiles.py

    r6f951ca r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
  • source/python/classes/__init__.py

    r25b14be r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
  • source/python/install.py

    r6f951ca r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
     
    367367                                         in exclude_files
    368368                                      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))
    380372
    381373    return
     
    678670                             bufsize=1)
    679671        pout, perr = p.communicate()
    680         print(pout)
     672        print(pout.decode())
    681673        if p.returncode != 0:
    682             print(perr)
     674            print(perr.decode())
    683675            print('Please edit ' + makefile +
    684676                  ' 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
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
  • source/python/mods/checks.py

    rf20af73 r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
     
    3131except ImportError:
    3232    import builtins as exceptions
    33 from .tools import my_error, silent_remove
    3433from datetime import datetime
    3534import numpy as np
     35from .tools import my_error, silent_remove
    3636# ------------------------------------------------------------------------------
    3737# FUNCTIONS
  • source/python/mods/disaggregation.py

    r6f951ca r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
  • source/python/mods/get_mars_data.py

    rf20af73 r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
     
    176176    with open(marsfile, 'w') as f:
    177177        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())))
    179179        f.write('\n')
    180180
  • source/python/mods/prepare_flexpart.py

    rf20af73 r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
  • source/python/mods/profiling.py

    r25b14be r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#************************************************************************
     
    6666        result = fn(*args, **kwargs)
    6767        t2 = time.time()
    68         print("@timefn:" + fn.func_name + " took " + str(t2 - t1) + " seconds")
     68        print("@timefn:" + fn.__name__ + " took " + str(t2 - t1) + " seconds")
    6969
    7070        return result
  • source/python/mods/tools.py

    rf20af73 r79729d5  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
     
    368368                                 stderr=subprocess.PIPE,
    369369                                 bufsize=1)
    370             pout = p.communicate(input=message + '\n\n')[0]
     370            pout = p.communicate(input=message.encode() + '\n\n')[0]
    371371        except ValueError as e:
    372372            print('... ERROR: ' + str(e))
     
    433433    '''
    434434    try:
    435         pools = map(tuple, args) * kwds.get('repeat', 1)
     435        pools = [tuple(arg) for arg in args] * kwds.get('repeat', 1)
    436436        result = [[]]
    437437        for pool in pools:
     
    533533    ipar = []
    534534    for par in cpar:
    535         for k, v in table.iteritems():
     535        for k, v in table.items():
    536536            if par == k or par == v:
    537537                ipar.append(int(k))
     
    574574    spar = []
    575575    for par in cpar:
    576         for k, v in table.iteritems():
     576        for k, v in table.items():
    577577            if par == k or par == v:
    578578                spar.append(k + '.128')
     
    726726        sys.exit('... ECACCESS-JOB-SUBMIT FAILED!')
    727727
    728     return job_id
     728    return job_id.decode()
    729729
    730730
     
    827827
    828828    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)
    830830    else:
    831831        # #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
    22# -*- coding: utf-8 -*-
    33#*******************************************************************************
     
    6868import _config
    6969from mods.tools import (setup_controldata, normal_exit, get_cmdline_args,
    70                         submit_job_to_ecserver, read_ecenv)
     70                         submit_job_to_ecserver, read_ecenv)
    7171from mods.get_mars_data import get_mars_data
    7272from mods.prepare_flexpart import prepare_flexpart
  • templates/compilejob.template

    rb02a07e r79729d5  
    3030  module unload grib_api
    3131  module unload eccodes
    32   module load eccodes
    33   module load python
     32  module unload python
    3433  module unload emos
     34  module load python3
     35  module load eccodes/2.12.0
    3536  module load emos/455-r64
    3637  export FLEXPART_ROOT_SCRIPTS=$fp_root_scripts
     
    3839  ;;
    3940  *cca*)
     41  module unload python
    4042  module switch PrgEnv-cray PrgEnv-intel
    41   module load eccodes
     43  module load python3
     44  module load eccodes/2.12.0
    4245  module load emos
    43   module load python
    4446  echo $${GROUP}
    4547  echo $${HOME}
  • templates/job.temp

    rb02a07e r79729d5  
    2828case $${HOST} in
    2929  *ecg*)
    30   module load python
    3130  module unload grib_api
    3231  module unload eccodes
    33   module load eccodes
     32  module unload python
    3433  module unload emos
     34  module load python3
     35  module load eccodes/2.12.0
    3536  module load emos/455-r64
    3637  export PATH=$${PATH}:$${HOME}/flex_extract_v7.1/source/python
    3738  ;;
    3839  *cca*)
     40  module unload python
    3941  module switch PrgEnv-cray PrgEnv-intel
    40   module load eccodes
     42  module load python3
     43  module load eccodes/2.12.0
    4144  module load emos
    42   module load python
    4345  export SCRATCH=$${TMPDIR}
    4446  export PATH=$${PATH}:$${HOME}/flex_extract_v7.1/source/python
  • templates/job.template

    rb02a07e r79729d5  
    2828case $$$${HOST} in
    2929  *ecg*)
    30   module load python
    3130  module unload grib_api
    3231  module unload eccodes
    33   module load eccodes
     32  module unload python
    3433  module unload emos
     34  module load python3
     35  module load eccodes/2.12.0
    3536  module load emos/455-r64
    3637  export PATH=$$$${PATH}:$fp_root_path
    3738  ;;
    3839  *cca*)
     40  module unload python
    3941  module switch PrgEnv-cray PrgEnv-intel
    40   module load eccodes
     42  module load python3
     43  module load eccodes/2.12.0
    4144  module load emos
    42   module load python
    4345  export SCRATCH=$$$${TMPDIR}
    4446  export PATH=$$$${PATH}:$fp_root_path
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG