Changeset 2fb99de in flex_extract.git for python/get_mars_data.py


Ignore:
Timestamp:
Sep 20, 2018, 11:56:37 AM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
5d42acd
Parents:
3232589
Message:

introduced config with path definitions and changed py files accordingly; Installation works; some tests were added for tarball making; Problems in submission to ecgate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/get_mars_data.py

    r54a8a01 r2fb99de  
    5757
    5858# software specific classes and modules from flex_extract
     59import _config
    5960from tools import my_error, normal_exit, get_cmdline_arguments, read_ecenv
    6061from EcFlexpart import EcFlexpart
    6162from 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 
    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)
     
    137128        os.makedirs(c.inputdir)
    138129
    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))
    142137
    143138    if ecapi:
     
    147142
    148143    c.ecapi = ecapi
    149     print 'ecapi: ', c.ecapi
     144    print('Using ECMWF WebAPI: ' + str(c.ecapi))
    150145
    151146    # basetime geht rückwärts
     
    192187
    193188    # --------------  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()
    198194
    199195    # if forecast for maximum one day (upto 24h) are to be retrieved,
     
    213209
    214210    # --------------  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()
    219216
    220217    do_retrievement(c, server, start, end, datechunk, fluxes=False)
     
    280277                    end.strftime("%Y%m%d")
    281278
    282         print "retrieve " + dates + " in dir " + c.inputdir
     279        print("... retrieve " + dates + " in dir " + c.inputdir)
    283280
    284281        try:
    285             flexpart.retrieve(server, dates, c.inputdir)
     282            flexpart.retrieve(server, dates, c.request, c.inputdir)
    286283        except IOError:
    287284            my_error(c.mailfail, 'MARS request failed')
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG