forked from HydrologicEngineeringCenter/hec-dss-python
-
Notifications
You must be signed in to change notification settings - Fork 1
/
timeseries.py
34 lines (28 loc) · 896 Bytes
/
timeseries.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
class TimeSeries:
def __init__(self):
self.times = []
self.values = []
self.units =""
self.dataType =""
self.dsspath = ""
def add_data_point(self, date, value):
self.times.append(date)
self.values.append(value)
def get_value_at(self, date):
if date in self.times:
index = self.times.index(date)
return self.values[index]
else:
return None
def get_values(self):
return self.values
def get_dates(self):
return self.times
def get_length(self):
return len(self.times)
def print_to_console(self):
print("dsspath='"+self.dsspath+"'")
print("units='"+self.units+"'")
print("dataType='"+self.dataType+"'")
for time, value in zip(self.times, self.values):
print(f"Time: {time}, Value: {value}")