Changeset f20af73 in flex_extract.git for source/python/classes/EcFlexpart.py


Ignore:
Timestamp:
Mar 8, 2019, 10:05:20 AM (5 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
82c2959
Parents:
b4a4777
Message:

added CDS API support for ERA5 instead of ECMWFAPI / refactored setup of CONTROL parameter because for local version it wanted to use not installed ECMWF_ENV file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/python/classes/EcFlexpart.py

    re446e85 rf20af73  
    7373sys.path.append('../')
    7474import _config
    75 from GribUtil import GribUtil
     75from .GribUtil import GribUtil
    7676from mods.tools import (init128, to_param_id, silent_remove, product,
    7777                        my_error, make_dir, get_informations, get_dimensions,
    78                         execute_subprocess)
    79 from MarsRetrieval import MarsRetrieval
    80 from UioFiles import UioFiles
     78                        execute_subprocess, to_param_id_with_tablenumber)
     79from .MarsRetrieval import MarsRetrieval
     80from .UioFiles import UioFiles
    8181import mods.disaggregation as disaggregation
    8282
     
    403403        elif not gauss and not eta:
    404404            self.params['OG__ML'][0] += '/U/V'
    405         else:
    406             print('Warning: Collecting etadot and parameters for gaussian grid \
    407                             is a very costly parameter combination, \
    408                             use this combination only for debugging!')
    409             self.params['GG__SL'] = ['Q', 'ML', '1', \
     405        else:  # GAUSS and ETA
     406            print('Warning: Collecting etadot and parameters for gaussian grid '
     407                           'is a very costly parameter combination, '
     408                           'use this combination only for debugging!')
     409            self.params['GG__SL'] = ['Q', 'ML', '1',
    410410                                     '{}'.format((int(self.resol) + 1) / 2)]
    411             self.params['GG__ML'] = ['U/V/D/77', 'ML', self.glevelist, \
     411            self.params['GG__ML'] = ['U/V/D/ETADOT', 'ML', self.glevelist,
    412412                                     '{}'.format((int(self.resol) + 1) / 2)]
    413413
     
    419419
    420420        # ADDITIONAL FIELDS FOR FLEXPART-WRF MODEL (IF QUESTIONED)
    421         #-----------------------------------------------------------------------
     421        # -----------------------------------------------------------------------
    422422        if wrf:
    423423            self.params['OG__ML'][0] += '/Z/VO'
    424424            if '/D' not in self.params['OG__ML'][0]:
    425425                self.params['OG__ML'][0] += '/D'
     426
    426427            wrf_sfc = ['SP','SKT','SST','CI','STL1','STL2', 'STL3','STL4',
    427428                       'SWVL1','SWVL2','SWVL3','SWVL4']
     
    452453
    453454        '''
    454         self.params['OG_acc_SL'] = ["LSP/CP/SSHF/EWSS/NSSS/SSR", \
     455        self.params['OG_acc_SL'] = ["LSP/CP/SSHF/EWSS/NSSS/SSR",
    455456                                    'SFC', '1', self.grid]
    456457        return
     
    684685                                        pk,
    685686                                        retr_param_dict['date'].split('/')[0])
    686                 retr_param_dict['param'] = pv[0]
     687                table128 = init128(_config.PATH_GRIBTABLE)
     688                ids = to_param_id_with_tablenumber(pv[0], table128)
     689                retr_param_dict['param'] = ids
    687690                retr_param_dict['levtype'] = pv[1]
    688691                retr_param_dict['levelist'] = pv[2]
     
    12381241
    12391242        '''
    1240         print('... disaggregation or precipitation with new method.')
     1243        print('... disaggregation of precipitation with new method.')
    12411244        lsp_new_np = np.zeros((ni * nj, nt * 3), dtype=np.float64)
    12421245        cp_new_np = np.zeros((ni * nj, nt * 3), dtype=np.float64)
     
    12681271                    filename1 = c.prefix + date.strftime('%y%m%d%H') + '_1'
    12691272                    filename2 = c.prefix + date.strftime('%y%m%d%H') + '_2'
    1270 
    1271                 # collect for final processing
    1272                 self.outputfilelist.append(os.path.basename(fluxfilename))
    1273                 self.outputfilelist.append(os.path.basename(filename1))
    1274                 self.outputfilelist.append(os.path.basename(filename2))
    12751273
    12761274                # write original time step to flux file as usual
     
    14491447            cdate_hour = datetime.strftime(timestamp, '%Y%m%d%H')
    14501448
    1451             # eliminate all temporary times
     1449            # skip all temporary times
    14521450            # which are outside the retrieval period
    14531451            if timestamp < start_period or \
     
    15451543            os.chdir(c.inputdir)
    15461544            if os.stat('fort.21').st_size == 0 and c.eta:
    1547                 print('Parameter 77 (etadot) is missing, most likely it is \
    1548                        not available for this type or date/time\n')
     1545                print('Parameter 77 (etadot) is missing, most likely it is '
     1546                      'not available for this type or date / time\n')
    15491547                print('Check parameters CLASS, TYPE, STREAM, START_DATE\n')
    1550                 my_error(c.mailfail, 'fort.21 is empty while parameter eta \
    1551                          is set to 1 in CONTROL file')
    1552 #============================================================================================
     1548                my_error('fort.21 is empty while parameter eta '
     1549                         'is set to 1 in CONTROL file')
     1550# ============================================================================================
    15531551            # write out all output to log file before starting fortran programm
    15541552            sys.stdout.flush()
     
    15601558
    15611559            os.chdir(pwd)
    1562 #============================================================================================
     1560# ============================================================================================
    15631561            # create name of final output file, e.g. EN13040500 (ENYYMMDDHH)
    15641562            if c.purefc:
     
    15771575            # collect for final processing
    15781576            self.outputfilelist.append(os.path.basename(fnout))
    1579 #============================================================================================
     1577            # get additional precipitation subgrid data if available
     1578            if c.rrint:
     1579                self.outputfilelist.append(os.path.basename(fnout + '_1'))
     1580                self.outputfilelist.append(os.path.basename(fnout + '_2'))
     1581# ============================================================================================
    15801582            # create outputfile and copy all data from intermediate files
    15811583            # to the outputfile (final GRIB input files for FLEXPART)
     
    15971599                    shutil.copyfileobj(open(os.path.join(c.inputdir, 'fort.25'),
    15981600                                            'rb'), fout)
    1599 #============================================================================================
     1601# ============================================================================================
    16001602        if c.wrf:
    16011603            fwrf.close()
     
    16921694        print('\n\nPostprocessing:\n Format: {}\n'.format(c.format))
    16931695
    1694         if not c.ecapi:
     1696        if _config.FLAG_ON_ECMWFSERVER:
    16951697            print('ecstorage: {}\n ecfsdir: {}\n'.
    16961698                  format(c.ecstorage, c.ecfsdir))
     
    17141716                                   'FILES FAILED!')
    17151717
    1716             if c.ectrans and not c.ecapi:
     1718            if c.ectrans and _config.FLAG_ON_ECMWFSERVER:
    17171719                execute_subprocess(['ectrans', '-overwrite', '-gateway',
    17181720                                    c.gateway, '-remote', c.destination,
     
    17201722                                   error_msg='TRANSFER TO LOCAL SERVER FAILED!')
    17211723
    1722             if c.ecstorage and not c.ecapi:
     1724            if c.ecstorage and _config.FLAG_ON_ECMWFSERVER:
    17231725                execute_subprocess(['ecp', '-o', ofile,
    17241726                                    os.path.expandvars(c.ecfsdir)],
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG