Ignore:
Timestamp:
Sep 23, 2018, 11:40:28 AM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
4971f63
Parents:
5d42acd
Message:

changed whole tree structure of flex_extract to have better overview

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  
    5757
    5858# software specific classes and modules from flex_extract
     59import _config
    5960from 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 
     61from classes.EcFlexpart import EcFlexpart
     62from classes.UioFiles import UioFiles
    6963# ------------------------------------------------------------------------------
    7064# FUNCTION
     
    8983        c = ControlFile(args.controlfile)
    9084    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)
    10192    c.assign_args_to_control(args, env_parameter)
    10293    c.assign_envs_to_control(env_parameter)
    103     c.check_conditions()
     94    c.check_conditions(args.queue)
    10495
    10596    get_mars_data(c)
     
    286277                    end.strftime("%Y%m%d")
    287278
    288 
    289279        print("... retrieve " + dates + " in dir " + c.inputdir)
    290280
  • source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/mods/plot_retrieved.py

    r2fb99de r25b14be  
    5353
    5454# 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)
     55import _config
     56from classes.ControlFile import ControlFile
     57from classes.UioFiles import UioFiles
    6358
    6459font = {'family': 'monospace', 'size': 12}
  • source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/mods/prepare_flexpart.py

    r2fb99de r25b14be  
    5757import sys
    5858import socket
    59 import _config
    6059
    6160# software specific classes and modules from flex_extract
    62 from UioFiles import UioFiles
     61import _config
     62from classes.UioFiles import UioFiles
    6363from tools import clean_up, get_cmdline_arguments, read_ecenv
    64 from EcFlexpart import EcFlexpart
     64from classes.EcFlexpart import EcFlexpart
    6565
    6666ecapi = 'ecmwf' not in socket.gethostname()
     
    7070except ImportError:
    7171    ecapi = False
    72 
    73 # add path to pythonpath so that python finds its buddies
    74 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 
    7972
    8073# ------------------------------------------------------------------------------
     
    10093        c = ControlFile(args.controlfile)
    10194    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)
    110100
    111     env_parameter = read_ecenv(c.ecmwfdatadir + 'python/ECMWF_ENV')
     101    env_parameter = read_ecenv(_config.PATH_ECMWF_ENV)
    112102    c.assign_args_to_control(args, env_parameter)
    113103    c.assign_envs_to_control(env_parameter)
    114     c.check_conditions()
     104    c.check_conditions(args.queue)
    115105    prepare_flexpart(args.ppid, c)
    116106
     
    170160        start = start - datetime.timedelta(days=1)
    171161
    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"))
    174164
    175165    # create output dir if necessary
     
    182172    # deaccumulate the flux data
    183173    flexpart = EcFlexpart(c, fluxes=True)
    184     flexpart.write_namelist(c, 'fort.4')
     174    flexpart.write_namelist(c, _config.FILE_NAMELIST)
    185175    flexpart.deacc_fluxes(inputfiles, c)
    186176
     
    197187    # otherwise delete temporary files
    198188    if int(c.debug) != 0:
    199         print '\nTemporary files left intact'
     189        print('\nTemporary files left intact')
    200190    else:
    201191        clean_up(c)
  • source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/mods/profiling.py

    r2fb99de r25b14be  
    6666        result = fn(*args, **kwargs)
    6767        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")
    6969
    7070        return result
  • source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/mods/tools.py

    r2fb99de r25b14be  
    140140    @Input:
    141141        filename: string
    142             Name of file where the ECMWV environment parameters are stored.
     142            Path to file where the ECMWV environment parameters are stored.
    143143
    144144    @Return:
    145145        envs: dict
     146            Contains the environment parameter ecuid, ecgid, gateway
     147            and destination for ECMWF server environments.
    146148    '''
    147149    envs= {}
    148     print filename
     150
    149151    with open(filename, 'r') as f:
    150152        for line in f:
     
    178180    '''
    179181
    180     print "clean_up"
     182    print("clean_up")
    181183
    182184    cleanlist = glob.glob(c.inputdir + "/*")
     
    187189            silent_remove(clist)
    188190
    189     print "Done"
     191    print("Done")
    190192
    191193    return
     
    211213    '''
    212214
    213     print message
     215    print(message)
    214216
    215217    # comment if user does not want email notification directly from python
     
    227229            pout = p.communicate(input=message + '\n\n' + trace)[0]
    228230        except ValueError as e:
    229             print 'ERROR: ', e
     231            print('ERROR: ', e)
    230232            sys.exit('Email could not be sent!')
    231233        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())
    234236
    235237    sys.exit(1)
     
    256258
    257259    '''
    258     print message
     260    print(message)
    259261
    260262    # comment if user does not want notification directly from python
     
    271273            pout = p.communicate(input=message+'\n\n')[0]
    272274        except ValueError as e:
    273             print 'ERROR: ', e
    274             print 'Email could not be sent!'
     275            print('ERROR: ', e)
     276            print('Email could not be sent!')
    275277        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())
    278280
    279281    return
     
    395397                break
    396398        else:
    397             print 'Warning: par ' + par + ' not found in table 128'
     399            print('Warning: par ' + par + ' not found in table 128')
    398400
    399401    return ipar
     
    441443            raise # re-raise exception if a different error occured
    442444        else:
    443             print 'WARNING: Directory {0} already exists!'.format(directory)
     445            print('WARNING: Directory {0} already exists!'.format(directory))
    444446
    445447    return
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG