Changeset 2fef1f2 in flex_extract.git


Ignore:
Timestamp:
Dec 13, 2018, 11:49:06 PM (9 months ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
dev
Children:
fdfaf00
Parents:
dbf9d89
Message:

modified get_dimension so it can calculate the correct time dimension also for forecast retrievals; changed variable name for flexpart directory; specified the eccodes function in use

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/python/mods/tools.py

    r095dc73 r2fef1f2  
    167167                        type=none_or_str, default=None,
    168168                        help="root directory for storing output files")
    169     parser.add_argument("--flexpart_root_scripts", dest="flexpart_root_scripts",
     169    parser.add_argument("--flexpartdir", dest="flexpartdir",
    170170                        type=none_or_str, default=None,
    171171                        help="FLEXPART root directory (to find grib2flexpart \
     
    659659        'iDirectionIncrementInDegrees', 'missingValue'
    660660    '''
    661     from eccodes import *
     661    from eccodes import codes_grib_new_from_file, codes_get, codes_release
    662662
    663663    data = {}
     
    694694
    695695
    696 def get_dimensions(c, info):
     696def get_dimensions(info, purefc, dtime, index_vals, start_date, end_date):
    697697    '''This function specifies the correct dimensions for x, y and t.
    698698
    699699    Parameters
    700700    ----------
    701     c : :obj:`ControlFile`
    702         Contains all the parameters of CONTROL file and
    703         command line.
    704 
    705701    info : :obj:`dictionary`
    706702        Contains basic informations of the ECMWF grib files, e.g.
     
    710706        'iDirectionIncrementInDegrees', 'missingValue'
    711707
     708    purefc : :obj:`integer`
     709        Switch for definition of pure forecast mode or not.
     710
     711    dtime : :obj:`string`
     712        Time step in hours.
     713
     714    index_vals : :obj:`list`
     715        Contains the values from the keys used for a distinct selection
     716        of grib messages in processing  the grib files.
     717        Content looks like e.g.:
     718        index_vals[0]: ('20171106', '20171107', '20171108') ; date
     719        index_vals[1]: ('0', '1200', '1800', '600') ; time
     720        index_vals[2]: ('0', '12', '3', '6', '9') ; stepRange
     721
     722    start_date : :obj:`string`
     723        The start date of the retrieval job.
     724
     725    end_date : :obj:`string`
     726        The end date of the retrieval job.
     727
    712728    Return
    713729    ------
     
    720736    jy = info['Nj']
    721737
    722     start = datetime.strptime(c.start_date, '%Y%m%d')
    723     end = datetime.strptime(c.end_date, '%Y%m%d')
    724     it = ((end - start).days + 1) * 24/int(c.dtime)
    725     print 'it', it, (end - start).days, 24/int(c.dtime)
     738    if not purefc:
     739        it = ((end_date - start_date).days + 1) * 24/int(dtime)
     740    else:
     741        # #no of step * #no of times * #no of days
     742        it = len(index_vals[2]) * len(index_vals[1]) * len(index_vals[0])
    726743
    727744    return (ix, jy, it)
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG