Changeset 54a8a01 in flex_extract.git for python/EcFlexpart.py


Ignore:
Timestamp:
Aug 31, 2018, 7:50:37 AM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
597d4d1
Parents:
e1228f3
Message:

restructuring, documentations and bug fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/EcFlexpart.py

    re1228f3 r54a8a01  
    11#!/usr/bin/env python
    22# -*- coding: utf-8 -*-
    3 #************************************************************************
    4 # ToDo AP
    5 # - specifiy file header documentation
    6 # - add class description in header information
    7 # - apply classtests
    8 # - add references to ECMWF specific software packages
    9 # - add describtion of deacc_fluxes
    10 # - change name of func deacc ( weil disagg )
    11 # - add desc of retrieve function
    12 #************************************************************************
    133#*******************************************************************************
    144# @Author: Anne Fouilloux (University of Oslo)
     
    151141
    152142            fluxes: boolean, optional
    153                 Decides if a the flux parameter settings are stored or
     143                Decides if the flux parameter settings are stored or
    154144                the rest of the parameter list.
    155145                Default value is False.
     
    175165        self.dtime = c.dtime
    176166        i = 0
    177         if fluxes is True and c.maxstep < 24:
     167        if fluxes and c.maxstep <= 24:
    178168            # no forecast beyond one day is needed!
    179169            # Thus, prepare flux data manually as usual
     
    192182                    btlist = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0]
    193183
    194                 if i % int(c.dtime) == 0 and c.maxstep > 24 or i in btlist:
     184                if i % int(c.dtime) == 0 and (i in btlist or c.maxstep > 24):
    195185
    196186                    if ty not in self.types.keys():
     
    207197                        self.types[ty]['steps'] += st
    208198                i += 1
    209 
    210199
    211200        self.marsclass = c.marsclass
     
    304293                                         '{}'.format((int(self.resol) + 1) / 2)]
    305294
    306             if c.omega == '1':
     295            if hasattr(c, 'omega') and c.omega == '1':
    307296                self.params['OG__ML'][0] += '/W'
    308297
    309298            # add cloud water content if necessary
    310             if c.cwc == '1':
     299            if hasattr(c, 'cwc') and c.cwc == '1':
    311300                self.params['OG__ML'][0] += '/CLWC/CIWC'
    312301
    313302            # add vorticity and geopotential height for WRF if necessary
    314             if c.wrf == '1':
     303            if hasattr(c, 'wrf') and c.wrf == '1':
    315304                self.params['OG__ML'][0] += '/Z/VO'
    316305                if '/D' not in self.params['OG__ML'][0]:
     
    740729                                           c.gateway, '-remote', c.destination,
    741730                                           '-source', ofile])
    742                 print('ectrans:', p)
     731                #print('ectrans:', p)
    743732
    744733        if int(c.ecstorage) == 1 and c.ecapi is False:
     
    890879
    891880        for prod in product(*index_vals):
    892             # flag for Fortran program CONVERT2, initially False
     881            # flag for Fortran program CONVERT2 and file merging
    893882            convertFlag = False
    894883            print 'current prod: ', prod
     
    906895            # prepare some date and time parameter before reading the data
    907896            if gid is not None:
    908                 # Fortran program CONVERT2 is only done if gid at this time is
    909                 # not None, therefore save information in convertFlag
     897                # Combine all temporary data files into final grib file if
     898                # gid is at least one time not None. Therefore set convertFlag
     899                # to save information. The fortran program CONVERT2 is also
     900                # only done if convertFlag is True
    910901                convertFlag = True
    911902                # remove old fort.* files and open new ones
     903                # they are just valid for a single product
    912904                for k, f in fdict.iteritems():
    913905                    silent_remove(c.inputdir + "/fort." + k)
     
    922914                                              '%Y%m%d%H')
    923915                timestamp += timedelta(hours=int(step))
    924 
    925916                cdateH = datetime.strftime(timestamp, '%Y%m%d%H')
    926917
     
    966957                levtype = grib_get(gid, 'typeOfLevel')
    967958                if paramId == 133 and gridtype == 'reduced_gg':
    968                 # Relative humidity (Q.grb) is used as a template only
     959                # Specific humidity (Q.grb) is used as a template only
    969960                # so we need the first we "meet"
    970961                    with open(c.inputdir + '/fort.18', 'w') as fout:
     
    10281019                           not available for this type or date/time\n'
    10291020                    print 'Check parameters CLASS, TYPE, STREAM, START_DATE\n'
    1030                     my_error(c, 'fort.21 is empty while parameter eta is set \
    1031                                to 1 in CONTROL file')
     1021                    my_error(c.mailfail, 'fort.21 is empty while parameter eta \
     1022                             is set to 1 in CONTROL file')
    10321023
    10331024                # create the corresponding output file fort.15
     
    10611052                with open(fnout, 'wb') as fout:
    10621053                    for f in flist:
    1063                         shutil.copyfileobj(open(c.inputdir + '/' + f, 'rb'), fout)
     1054                        shutil.copyfileobj(
     1055                            open(c.inputdir + '/' + f, 'rb'), fout)
    10641056
    10651057                if c.omega == '1':
     
    10681060                            open(c.inputdir + '/fort.25', 'rb'), fout)
    10691061
    1070         if c.wrf == '1':
     1062        if hasattr(c, 'wrf') and c.wrf == '1':
    10711063            fwrf.close()
    10721064
     
    13071299        grib_index_release(iid)
    13081300
    1309         exit()
    13101301        return
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG