Changeset ae2756e in flex_extract.git


Ignore:
Timestamp:
Feb 15, 2019, 3:46:45 PM (3 months ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
dev
Children:
45b99e6
Parents:
5364d08
Message:

added a check for the number parameter

Location:
source/python
Files:
2 edited

Legend:

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

    rd4696e0 rae2756e  
    5959                         check_acctime, check_accmaxstep, check_time,
    6060                         check_logicals_type, check_len_type_time_step,
    61                          check_addpar, check_job_chunk)
     61                         check_addpar, check_job_chunk, check_number)
    6262
    6363# ------------------------------------------------------------------------------
     
    646646        self.job_chunk = check_job_chunk(self.job_chunk)
    647647
     648        self.number = check_number(self.number, self.mailfail)
     649
    648650        return
    649651
  • source/python/mods/checks.py

    r4c1d7de rae2756e  
    3030from tools import my_error, silent_remove
    3131from datetime import datetime
     32import numpy as np
    3233# ------------------------------------------------------------------------------
    3334# FUNCTIONS
     
    825826
    826827    return job_chunk
     828
     829
     830def check_number(number, mailfail):
     831    '''Check for correct string format of ensemble member numbers.
     832
     833    Parameters
     834    ----------
     835    number : str
     836        List of ensemble member forecast runs.
     837
     838    mailfail : list of str
     839        Contains all email addresses which should be notified.
     840        It might also contain just the ecmwf user name which will trigger
     841        mailing to the associated email address for this user.
     842
     843    Return
     844    ------
     845    number : str
     846        String with list of ensemble member forecast runs. E.g. '01/02/03/04'
     847    '''
     848
     849    if '/' in number:
     850        numbers = number.split('/')
     851        if 'to' in number.lower() and 'by' in number.lower():
     852            number = '{:0>3}'.format(int(numbers[0])) + '/TO/' + \
     853                     '{:0>3}'.format(int(numbers[2])) + '/BY/' + \
     854                     '{:0>3}'.format(int(numbers[4]))
     855        elif 'to' in number.lower() and 'by' not in number.lower():
     856            number = '{:0>3}'.format(int(numbers[0])) + '/TO/' + \
     857                     '{:0>3}'.format(int(numbers[2]))
     858        else:
     859            numbers = ['{:0>3}'.format(i) for i in numbers]
     860            number = '{:0>3}/'.join(numbers)
     861    elif number.isdigit():
     862        number = '{:0>3}'.format(int(number))
     863    else:
     864        pass
     865
     866    return number
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG