diff --git a/python/exercise2/time_window.py b/python/exercise2/time_window.py index 0d0ba82..c928950 100644 --- a/python/exercise2/time_window.py +++ b/python/exercise2/time_window.py @@ -4,10 +4,10 @@ class TimeWindow: """ Observations for a TIEGCM experiment """ def __init__(self, start_time, end_time, delta): - """ Initializes the observations associated with a TIEGCM experiment + """ Initialize the window and model times associated with a TIEGCM experiment - start_time - string '%Y-%m-%d %H:%M:%S' model start time of experiment - end_time - string '%Y-%m-%d %H:%M:%S' model end time of experiment + start_time - string '%Y-%m-%d %H:%M:%S' model inital time + end_time - string '%Y-%m-%d %H:%M:%S' model end time delta - integer assimilation window time in hours model_time is the center of the window. @@ -20,12 +20,20 @@ def __init__(self, start_time, end_time, delta): """ + # Error checking of delta input if delta > 23: raise ValueError("invalid delta {} should be [0-23] hours".format(delta)) - + + if delta < 0: + raise ValueError("invalid delta {} should be [0-23] hours".format(delta)) + + if delta == 0: + raise ValueError("invalid delta {} cannot be exactly 0 hours".format(delta)) + + self.start_time = datetime.strptime(start_time, '%Y-%m-%d %H:%M:%S') self.end_time = datetime.strptime(end_time, '%Y-%m-%d %H:%M:%S') - self.delta = abs(delta) + self.delta = delta self.delta_half = delta / 2 # create a list of times for the experiment @@ -44,6 +52,8 @@ def __init__(self, start_time, end_time, delta): def info(self): + """ prints first and last window times """ + print("win num_cycles", self.num_cycles) if self.num_cycles > 0: