Skip to content

Commit 955ec54

Browse files
Update single-node hymod example
1 parent e7f7586 commit 955ec54

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

examples/calibration/single_node_calibration.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,25 @@ network = YAML.load_file(joinpath(DATA_PATH, "hymod_network.yml"))
1111
sn = create_network("HyMod Network", network)
1212

1313
# Load climate data
14-
date_format = "YYYY-mm-dd"
15-
obs_data = CSV.File(joinpath(DATA_PATH, "leaf_river_data.csv"),
16-
comment="#",
17-
dateformat=date_format) |> DataFrame
14+
obs_data = CSV.read(
15+
joinpath(DATA_PATH, "leaf_river_data.csv"),
16+
DataFrame,
17+
comment="#",
18+
dateformat="YYYY-mm-dd"
19+
)
1820

1921
hist_streamflow = obs_data[:, "leaf_river_outflow"]
22+
rename!(obs_data, ["leaf_river_outflow"=>"leaf_river"])
23+
2024
climate_data = obs_data[:, ["Date", "leaf_river_P", "leaf_river_ET"]]
2125
climate = Climate(climate_data, "_P", "_ET")
2226

2327
# This will set node parameters to the optimal values found
2428
metric = (obs, sim) -> 1.0 - Streamfall.NNSE(obs, sim)
25-
calibrate!(sn, climate, hist_streamflow; metric=metric, MaxTime=90.0)
29+
calibrate!(sn, climate, obs_data, metric; MaxTime=180.0)
2630

2731
# Save calibrated network spec to file
28-
Streamfall.save_network_spec(sn, "hymod_example_calibrated.yml")
32+
Streamfall.save_network(sn, "hymod_example_calibrated.yml")
2933

3034
# Run the model as a single system
3135
run_basin!(sn, climate)
@@ -42,4 +46,3 @@ obs = hist_streamflow[:, "leaf_river_outflow"]
4246

4347
plot(obs)
4448
plot!(node.outflow)
45-

0 commit comments

Comments
 (0)