Changeset efdb01a in flex_extract.git for python/submit.py
- Timestamp:
- May 9, 2018, 12:15:00 PM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 991df6a
- Parents:
- 02c8c50
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/submit.py
- Property mode changed from 100644 to 100755
r02c8c50 refdb01a 3 3 #************************************************************************ 4 4 # TODO AP 5 # AP5 # 6 6 # - Change History ist nicht angepasst ans File! Original geben lassen 7 7 # - dead code ? what to do? 8 8 # - seperate operational and reanlysis for clarification 9 # - add correct file description 10 # - divide in two submits , ondemand und operational 11 # - 9 12 #************************************************************************ 10 13 """ … … 15 18 @ChangeHistory: 16 19 November 2015 - Leopold Haimberger (University of Vienna): 17 - using the WebAPI also for general MARS retrievals18 20 - job submission on ecgate and cca 19 21 - job templates suitable for twice daily operational dissemination 20 - dividing retrievals of longer periods into digestable chunks21 - retrieve also longer term forecasts, not only analyses and22 short term forecast data23 - conversion into GRIB224 - conversion into .fp format for faster execution of FLEXPART25 22 26 23 February 2018 - Anne Philipp (University of Vienna): 27 24 - applied PEP8 style guide 28 25 - added documentation 29 - minor changes in programming style for consistence26 - minor changes in programming style (for consistence) 30 27 31 28 @License: 32 (C) Copyright 2014 UIO.29 (C) Copyright 2014-2018. 33 30 34 31 This software is licensed under the terms of the Apache Licence Version 2.0 … … 37 34 @Requirements: 38 35 - A standard python 2.6 or 2.7 installation 39 - dateutils40 - matplotlib (optional, for debugging)41 - ECMWF specific packages, all available from https://software.ecmwf.int/42 ECMWF WebMARS, gribAPI with python enabled, emoslib and43 ecaccess web toolkit44 36 45 37 @Description: 46 38 Further documentation may be obtained from www.flexpart.eu. 47 39 48 Functionality provided: 49 Prepare input 3D-wind fields in hybrid coordinates + 50 surface fields for FLEXPART runs 40 51 41 """ 52 42 # ------------------------------------------------------------------------------ 53 43 # MODULES 54 44 # ------------------------------------------------------------------------------ 55 import calendar 56 import shutil 57 import datetime 58 import time 59 import os, sys, glob 45 import os 46 import sys 47 import glob 60 48 import subprocess 61 49 import inspect 62 # add path to submit.py to pythonpath so that python finds its buddies50 # add the pythondir path so that python finds its buddies (from flex_extract) 63 51 localpythonpath = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) 64 52 sys.path.append(localpythonpath) 65 from UIOTools import UIOFiles 66 from string import strip 67 from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter 68 from GribTools import GribTools 69 from FlexpartTools import ECFlexpart, Control, interpret_args_and_control, normalexit, myerror 53 54 # software specific classes and modules from flex_extract 55 from Tools import interpret_args_and_control, normalexit 70 56 from getMARSdata import getMARSdata 71 57 from prepareFLEXPART import prepareFLEXPART … … 76 62 ''' 77 63 @Description: 78 Get the arguments from script call and initialize an object from 79 Control class. Decides from the argument "queue" if the local version 80 is done "queue=None" or the gateway version "queue=ecgate". 64 Get the arguments from script call and from Control file. 65 Decides from the argument "queue" if the local version 66 is done "queue=None" or the gateway version with "queue=ecgate" 67 or "queue=cca". 81 68 82 69 @Input: … … 88 75 calledfromdir = os.getcwd() 89 76 args, c = interpret_args_and_control() 77 # on local side 90 78 if args.queue is None: 91 79 if c.inputdir[0] != '/': … … 96 84 prepareFLEXPART(args, c) 97 85 normalexit(c) 86 # on ECMWF server 98 87 else: 99 88 submit(args.job_template, c, args.queue) … … 102 91 103 92 def submit(jtemplate, c, queue): 104 #AP divide in two submits , ondemand und operational105 93 ''' 106 94 @Description: … … 138 126 lftext = f.read().split('\n') 139 127 insert_point = lftext.index('EOF') 140 #AP es gibt mehrere EOFs überprüfen!141 128 142 129 # put all parameters of control instance into a list 143 clist = c.tolist() # reanalysis (EI)130 clist = c.tolist() 144 131 colist = [] # operational 145 132 mt = 0 146 133 147 134 #AP wieso 2 for loops? 148 #AP dieser part ist für die CTBTO Operational retrieves bis zum aktuellen Tag.149 135 for elem in clist: 150 136 if 'maxstep' in elem: … … 162 148 elem = 'time ' + '${MSJ_BASETIME} {MSJ_BASETIME}' 163 149 colist.append(elem) 164 #AP end165 166 #AP whats the difference between clist and colist ?! What is MSJ?167 150 168 151 lftextondemand = lftext[:insert_point] + clist + lftext[insert_point + 2:] … … 172 155 h.write('\n'.join(lftextondemand)) 173 156 174 #AP this is not used ?! what is it for? 175 #maybe a differentiation is needed 176 h = open('joboper.ksh', 'w') 177 h.write('\n'.join(lftextoper)) 178 h.close() 179 #AP end 157 with open('joboper.ksh', 'w') as h: 158 h.write('\n'.join(lftextoper)) 180 159 181 160 # submit job script to queue 182 161 try: 183 162 p = subprocess.check_call(['ecaccess-job-submit', '-queueName', 184 queue, 'job.ksh'])163 queue, 'job.ksh']) 185 164 except: 186 165 print('ecaccess-job-submit failed, probably eccert has expired')
Note: See TracChangeset
for help on using the changeset viewer.