-
Notifications
You must be signed in to change notification settings - Fork 0
/
Clock.py
52 lines (40 loc) · 1.07 KB
/
Clock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
"""author: 周光武、簡子琦"""
from math import isclose
class Clock:
"""
Clock object to coordinate time integration.
Parameters
----------
increment : {time increment, float}
input_time : {input time series, list}
start_time : {start time stamp, float}
Returns
-------
out : Clock obj
"""
def __init__(self, increment, input_time, start_time = 0.0):
self._inc = increment
self._input_time = input_time
self._time = start_time
@property
def current_time(self):
return self._time
@property
def inc(self):
return self._inc
@property
def input_time(self):
return self._input_time
@property
def is_end(self):
inp = self.input_time
if isclose(self.current_time, inp[len(inp)-1]):
return True
else:
return False
@current_time.setter
def current_time(self, value):
self._time = value
def forward(self):
self.current_time += self.inc