Changeset ff99eae in flex_extract.git for python/prepare_flexpart.py
- Timestamp:
- Jun 1, 2018, 8:34:59 PM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- e1228f3
- Parents:
- ccab809
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
python/prepare_flexpart.py
r991df6a rff99eae 2 2 # -*- coding: utf-8 -*- 3 3 #************************************************************************ 4 # TODO AP 5 # - wieso cleanup in main wenn es in prepareflexpart bereits abgefragt wurde? 6 # doppelt gemoppelt? 4 # ToDo AP 7 5 # - wieso start=startm1 wenn basetime = 0 ? wenn die fluxes nicht mehr 8 6 # relevant sind? verstehe ich nicht … … 29 27 # - added documentation 30 28 # - minor changes in programming style for consistence 31 # - BUG: removed call of clean up-Function after call of29 # - BUG: removed call of clean_up-Function after call of 32 30 # prepareFlexpart in main since it is already called in 33 31 # prepareFlexpart at the end! 34 32 # - created function main and moved the two function calls for 35 # arguments and prepare FLEXPARTinto it33 # arguments and prepare_flexpart into it 36 34 # 37 35 # @License: … … 44 42 # This program prepares the final version of the grib files which are 45 43 # then used by FLEXPART. It converts the bunch of grib files extracted 46 # via get MARSdata by doing for example the necessary conversion to get44 # via get_mars_data by doing for example the necessary conversion to get 47 45 # consistent grids or the disaggregation of flux data. Finally, the 48 46 # program combines the data fields in files per available hour with the … … 52 50 # @Program Content: 53 51 # - main 54 # - prepare FLEXPART52 # - prepare_flexpart 55 53 # 56 54 #******************************************************************************* … … 59 57 # MODULES 60 58 # ------------------------------------------------------------------------------ 61 import shutil62 59 import datetime 63 #import time64 60 import os 65 61 import inspect 66 62 import sys 67 63 import socket 68 from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter69 64 70 hostname = socket.gethostname() 71 ecapi = 'ecmwf' not in hostname 65 # software specific classes and modules from flex_extract 66 from UioFiles import UioFiles 67 from tools import interpret_args_and_control, clean_up 68 from EcFlexpart import EcFlexpart 69 70 ecapi = 'ecmwf' not in socket.gethostname() 72 71 try: 73 72 if ecapi: … … 77 76 78 77 # add path to pythonpath so that python finds its buddies 79 localpythonpath= os.path.dirname(os.path.abspath(78 LOCAL_PYTHON_PATH = os.path.dirname(os.path.abspath( 80 79 inspect.getfile(inspect.currentframe()))) 81 if localpythonpathnot in sys.path:82 sys.path.append( localpythonpath)80 if LOCAL_PYTHON_PATH not in sys.path: 81 sys.path.append(LOCAL_PYTHON_PATH) 83 82 84 # software specific classes and modules from flex_extract85 from UIOFiles import UIOFiles86 from Tools import interpret_args_and_control, cleanup87 from ECFlexpart import ECFlexpart88 83 # ------------------------------------------------------------------------------ 89 84 # FUNCTION … … 92 87 ''' 93 88 @Description: 94 If prepare FLEXPARTis called from command line, this function controls89 If prepare_flexpart is called from command line, this function controls 95 90 the program flow and calls the argumentparser function and 96 the prepare FLEXPARTfunction for preparation of GRIB data for FLEXPART.91 the prepare_flexpart function for preparation of GRIB data for FLEXPART. 97 92 98 93 @Input: … … 103 98 ''' 104 99 args, c = interpret_args_and_control() 105 prepare FLEXPART(args, c)100 prepare_flexpart(args, c) 106 101 107 102 return 108 103 109 def prepare FLEXPART(args, c):104 def prepare_flexpart(args, c): 110 105 ''' 111 106 @Description: 112 Lists all grib files retrieved from MARS with get MARSdata and107 Lists all grib files retrieved from MARS with get_mars_data and 113 108 uses prepares data for the use in FLEXPART. Specific data fields 114 109 are converted to a different grid and the flux data are going to be … … 157 152 # one day after the end date is needed 158 153 startm1 = start - datetime.timedelta(days=1) 159 endp1 = end + datetime.timedelta(days=1)154 # endp1 = end + datetime.timedelta(days=1) 160 155 161 156 # get all files with flux data to be deaccumulated 162 inputfiles = U IOFiles('*OG_acc_SL*.' + c.ppid + '.*')163 inputfiles.list Files(c.inputdir)157 inputfiles = UioFiles('*OG_acc_SL*.' + c.ppid + '.*') 158 inputfiles.list_files(c.inputdir) 164 159 165 160 # create output dir if necessary … … 168 163 169 164 # deaccumulate the flux data 170 flexpart = E CFlexpart(c, fluxes=True)165 flexpart = EcFlexpart(c, fluxes=True) 171 166 flexpart.write_namelist(c, 'fort.4') 172 167 flexpart.deacc_fluxes(inputfiles, c) 173 168 174 print ('Prepare ' + start.strftime("%Y%m%d") +175 "/to/" + end.strftime("%Y%m%d") )169 print 'Prepare ' + start.strftime("%Y%m%d") + \ 170 "/to/" + end.strftime("%Y%m%d") 176 171 177 172 # get a list of all files from the root inputdir 178 inputfiles = U IOFiles('????__??.*' + c.ppid + '.*')179 inputfiles.list Files(c.inputdir)173 inputfiles = UioFiles('????__??.*' + c.ppid + '.*') 174 inputfiles.list_files(c.inputdir) 180 175 181 176 # produce FLEXPART-ready GRIB files and … … 185 180 start = startm1 186 181 187 flexpart = E CFlexpart(c, fluxes=False)182 flexpart = EcFlexpart(c, fluxes=False) 188 183 flexpart.create(inputfiles, c) 189 184 flexpart.process_output(c) … … 192 187 # otherwise delete temporary files 193 188 if int(c.debug) != 0: 194 print ('Temporary files left intact')189 print 'Temporary files left intact' 195 190 else: 196 clean up(c)191 clean_up(c) 197 192 198 193 return
Note: See TracChangeset
for help on using the changeset viewer.