forked from kettner/hydrotrend
-
Notifications
You must be signed in to change notification settings - Fork 1
/
hydrotrend.py
37 lines (28 loc) · 1.01 KB
/
hydrotrend.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
#! /usr/bin/env python
import hydrotrend_mod
class HydrotrendError (Exception):
pass
class NotInitializedError (Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr (self.value)
class Hydrotrend (object):
def __init__ (self, in_dir=".", data_prefix='HYDRO', out_dir="."):
self._in_dir = in_dir
self._out_dir = out_dir
self._data_prefix = data_prefix
self._state = hydrotrend_mod.ht_initialize (in_dir, data_prefix, out_dir)
def init (self):
if self._state is None:
self._state = hydrotrend_mod.ht_initialize (in_dir, data_prefix, out_dir)
def run (self, time):
if self._state is not None:
hydrotrend_mod.BMI_Update_until (self._state, time)
else:
raise NotInitializedError ('Trying to run uninitialized model')
def finalize (self):
if self._state is not None:
self._state = hydrotrend_mod.BMI_Finalize (self._state)
else:
raise NotInitializedError ('Trying to finalize uninitialized model')