Changeset efdb01a in flex_extract.git for python/prepareFLEXPART.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/prepareFLEXPART.py
- Property mode changed from 100644 to 100755
r02c8c50 refdb01a 30 30 - added documentation 31 31 - minor changes in programming style for consistence 32 - BUG: removed call of cleanup-Function after call of prepareFlexpart 33 since it is already called in prepareFlexpart at the end! 32 34 33 35 @License: 34 (C) Copyright 2014 .36 (C) Copyright 2014-2018. 35 37 36 38 This software is licensed under the terms of the Apache Licence Version 2.0 … … 40 42 - A standard python 2.6 or 2.7 installation 41 43 - dateutils 42 - matplotlib (optional, for debugging)43 44 - ECMWF specific packages, all available from https://software.ecmwf.int/ 44 45 ECMWF WebMARS, gribAPI with python enabled, emoslib and … … 52 53 surface fields for FLEXPART runs 53 54 """ 54 55 # ------------------------------------------------------------------------------ 56 # MODULES 57 # ------------------------------------------------------------------------------ 55 58 import calendar 56 59 import shutil 57 60 import datetime 58 61 import time 59 import os,inspect,sys 62 import os 63 import inspect 64 import sys 60 65 import socket 61 66 from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter 62 # add path to submit.py to pythonpath so that python finds its buddies 63 localpythonpath=os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) 64 if localpythonpath not in sys.path: 65 sys.path.append(localpythonpath) 66 from UIOTools import UIOFiles 67 #from string import strip 68 from GribTools import GribTools 69 from FlexpartTools import ECFlexpart, Control, interpret_args_and_control, cleanup 67 import UIOFiles 68 import Control 69 import Tools 70 import ECFlexpart 70 71 71 hostname=socket.gethostname() 72 ecapi= 'ecmwf' not in hostname 73 72 hostname = socket.gethostname() 73 ecapi = 'ecmwf' not in hostname 74 74 try: 75 75 if ecapi: … … 78 78 ecapi = False 79 79 80 80 # add path to submit.py to pythonpath so that python finds its buddies 81 localpythonpath=os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) 82 if localpythonpath not in sys.path: 83 sys.path.append(localpythonpath) 84 # ------------------------------------------------------------------------------ 85 # FUNCTION 86 # ------------------------------------------------------------------------------ 81 87 def prepareFLEXPART(args, c): 82 88 ''' … … 121 127 day=int(c.end_date[6:])) 122 128 123 # to deaccumulate dthe fluxes correctly129 # to deaccumulate the fluxes correctly 124 130 # one day ahead of the start date and 125 131 # one day after the end date is needed … … 128 134 129 135 # get all files with flux data to be deaccumulated 130 inputfiles = UIOFiles (['.grib', '.grb', '.grib1',136 inputfiles = UIOFiles.UIOFiles(['.grib', '.grb', '.grib1', 131 137 '.grib2', '.grb1', '.grb2']) 132 138 … … 138 144 139 145 # deaccumulate the flux data 140 flexpart = ECFlexpart (c, fluxes=True)146 flexpart = ECFlexpart.ECFlexpart(c, fluxes=True) 141 147 flexpart.write_namelist(c, 'fort.4') 142 148 flexpart.deacc_fluxes(inputfiles, c) … … 146 152 147 153 # get a list of all files from the root inputdir 148 inputfiles = UIOFiles (['.grib', '.grb', '.grib1',154 inputfiles = UIOFiles.UIOFiles(['.grib', '.grb', '.grib1', 149 155 '.grib2', '.grb1', '.grb2']) 150 156 … … 157 163 start = startm1 158 164 159 flexpart = ECFlexpart (c, fluxes=False)165 flexpart = ECFlexpart.ECFlexpart(c, fluxes=False) 160 166 flexpart.create(inputfiles, c) 161 167 flexpart.process_output(c) 162 168 163 169 # check if in debugging mode, then store all files 170 # otherwise delete temporary files 164 171 if int(c.debug) != 0: 165 172 print('Temporary files left intact') 166 173 else: 167 cleanup(c)174 Tools.cleanup(c) 168 175 169 176 return 170 177 171 178 if __name__ == "__main__": 172 args, c = interpret_args_and_control()179 args, c = Tools.interpret_args_and_control() 173 180 prepareFLEXPART(args, c) 174 cleanup(c)175
Note: See TracChangeset
for help on using the changeset viewer.