-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_model.py
62 lines (53 loc) · 1.56 KB
/
simple_model.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
51
52
53
54
55
56
57
58
59
60
61
62
import logging
import pandas as pd
from datetime import date
from gr6j import (
X1,
X2,
X3,
X4,
X5,
X6,
GR6JModelInputs,
CatchmentData,
ModelPeriod,
RunOffUnit,
GR6JModel,
)
# Enable module logging
logging.basicConfig(format="[%(asctime)-15s] %(levelname)s %(message)s")
logging.getLogger().setLevel(logging.INFO)
# Read the input data
data = pd.read_csv(
r"../../gr6j-core/src/test_data/airGR_L0123001_dataset.csv",
index_col=[0],
parse_dates=True,
dayfirst=True,
)
# Configure the model
start = date(1990, 1, 1)
end = date(1994, 12, 31)
# Define the catchment data
catchment = CatchmentData(
area=1.0, x1=X1(31), x2=X2(3.47), x3=X3(32), x4=X4(2.1), x5=X5(0.55), x6=X6(5.3)
)
# you can also access the unit and range of each parameter using
print(f"Allowed range for {X1.description()}: {X1.min()}-{X1.max()} ({X1.unit()})")
inputs = GR6JModelInputs(
time=data.index.tolist(),
precipitation=data["P"].tolist(),
evapotranspiration=data["E"].tolist(),
catchment=catchment,
run_period=ModelPeriod(start=start, end=end),
# simulated run off and FDC will be exported as CSV files and figures
destination=".",
observed_runoff=data["Qmm"].tolist(),
run_off_unit=RunOffUnit.NO_CONVERSION,
)
# Load the model and run it
model = GR6JModel(inputs)
results = model.run()
# Get the time and run-off vector as Pandas DataFrame
print(results.to_dataframe())
# Get the exchange from routing store for the only catchment and third time step
print(results.catchment_outputs[0][2].exchange_from_routing_store)