Skip to content

Commit f6bb2f2

Browse files
Update example
1 parent 2a261b3 commit f6bb2f2

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

examples/node_comparison.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Distributed, Plots, StatsPlots
1+
using Distributed
2+
using Plots
3+
24

35
N = 4
46
if nworkers() < N
@@ -18,23 +20,23 @@ end
1820
comment="#",
1921
dateformat=date_format) |> DataFrame
2022

21-
hist_streamflow = obs_data[:, ["Date", "410730_Q"]]
23+
hist_streamflow = extract_flow(obs_data, "410730")
2224
climate_data = obs_data[:, ["Date", "410730_P", "410730_PET"]]
2325
climate = Climate(climate_data, "_P", "_PET")
2426

2527
burn_in = 366 # 1 year burn-in period
2628

2729
# Create objective function to minimize (here we use Normalized KGE')
2830
func = (obs, sim) -> 1.0 - Streamfall.NmKGE(obs[burn_in:end], sim[burn_in:end])
29-
opt_func = (node) -> calibrate!(node, climate, hist_streamflow[:, "410730_Q"]; metric=func, MaxTime=900)
31+
opt_func = (node) -> calibrate!(node, climate, hist_streamflow[:, "410730"], func; MaxTime=30)
3032
end
3133

3234

3335
# Create individual nodes
3436
hymod_node = create_node(SimpleHyModNode, "410730", 129.2)
3537
gr4j_node = create_node(GR4JNode, "410730", 129.2)
3638
symhyd_node = create_node(SYMHYDNode, "410730", 129.2)
37-
ihacres_node = create_node(BilinearNode, "410730", 129.2)
39+
ihacres_node = create_node(IHACRESBilinearNode, "410730", 129.2)
3840

3941

4042
# Calibrate each node separately using multiprocessing
@@ -44,14 +46,14 @@ result = pmap(opt_func, node_list)
4446

4547

4648
# Create comparison plot
47-
Qo = hist_streamflow[:, "410730_Q"]
48-
Qo_burn = Qo[burn_in:end]
49+
Qo = hist_streamflow[:, "410730"]
4950
res_plots = []
5051

5152
for ((res, opt), node, n_name) in zip(result, node_list, node_names)
5253
update_params!(node, best_candidate(res)...)
5354
reset!(node)
54-
run_node!(node, climate)
55+
@info typeof(node)
56+
@time run_node!(node, climate)
5557

5658
node_burn = node.outflow[burn_in:end]
5759

@@ -68,4 +70,4 @@ combined_plot = plot(
6870

6971
display(combined_plot)
7072

71-
savefig("multi_model_comparison_updated.png")
73+
# savefig("multi_model_comparison_updated.png")

0 commit comments

Comments
 (0)