Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions python/exercise2/time_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be good to clarify what TIEGCM means


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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a typo in inital (should be initial)

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.
Expand All @@ -20,12 +20,20 @@ def __init__(self, start_time, end_time, delta):

"""

# Error checking of delta input
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be good to add documentation indicating why these numbers were added for the conditions

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
Expand All @@ -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:
Expand Down