Skip to content

Commit e7f7586

Browse files
Update multi-model comparison
Move image
1 parent 10e9209 commit e7f7586

3 files changed

Lines changed: 20 additions & 16 deletions

File tree

84.7 KB
Loading

docs/src/model_comparison.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,32 @@
33
This example showcases a comparison of models using multi-processing.
44

55
```julia
6-
using Distributed, Plots, StatsPlots
6+
using Distributed
7+
using Plots
78

89
N = 4
910
if nworkers() < N
1011
addprocs(N, exeflags="--project=$(Base.active_project())")
1112
end
1213

1314
@everywhere begin
14-
using DataFrames, CSV
15-
using Streamfall, BlackBoxOptim
15+
using CSV, DataFrames
16+
using Streamfall
1617

1718
HERE = @__DIR__
1819
DATA_PATH = joinpath(HERE, "../test/data/cotter/")
1920

2021
# Load observations
21-
date_format = "YYYY-mm-dd"
22-
obs_data = CSV.File(joinpath(DATA_PATH, "climate/CAMELS-AUS_410730.csv"),
23-
comment="#",
24-
dateformat=date_format) |> DataFrame
25-
26-
hist_streamflow = obs_data[:, ["Date", "410730_Q"]]
22+
date_format =
23+
obs_data = CSV.read(
24+
joinpath(DATA_PATH, "climate/CAMELS-AUS_410730.csv"),
25+
DataFrame;
26+
comment="#",
27+
dateformat="YYYY-mm-dd"
28+
)
29+
30+
hist_streamflow = extract_flow(obs_data, "410730")
31+
# hist_streamflow = obs_data[:, ["Date", "410730_Q"]]
2732
climate_data = obs_data[:, ["Date", "410730_P", "410730_PET"]]
2833
climate = Climate(climate_data, "_P", "_PET")
2934

@@ -39,32 +44,31 @@ end
3944
hymod_node = create_node(SimpleHyModNode, "410730", 129.2)
4045
gr4j_node = create_node(GR4JNode, "410730", 129.2)
4146
symhyd_node = create_node(SYMHYDNode, "410730", 129.2)
42-
ihacres_node = create_node(BilinearNode, "410730", 129.2)
47+
ihacres_node = create_node(IHACRESBilinearNode, "410730", 129.2)
4348

4449

4550
# Calibrate each node separately using multiprocessing
46-
node_names = ["HyMod", "GR4J", "SYMHYD", "IHACRES"]
51+
node_types = ["HyMod", "GR4J", "SYMHYD", "IHACRES"]
4752
node_list = [hymod_node, gr4j_node, symhyd_node, ihacres_node]
4853
result = pmap(opt_func, node_list)
4954

50-
5155
# Create comparison plot
52-
Qo = hist_streamflow[:, "410730_Q"]
56+
Qo = hist_streamflow[:, "410730"]
5357
Qo_burn = Qo[burn_in:end]
5458
res_plots = []
5559

56-
for ((res, opt), node, n_name) in zip(result, node_list, node_names)
60+
for ((res, opt), node, n_name) in zip(result, node_list, node_types)
5761
update_params!(node, best_candidate(res)...)
5862
reset!(node)
5963
run_node!(node, climate)
6064

6165
node_burn = node.outflow[burn_in:end]
6266

63-
res_plot = quickplot(Qo, node, climate, n_name; burn_in=366)
67+
# Plot log scale
68+
res_plot = quickplot(Qo, node, climate, n_name, true; burn_in=366)
6469
push!(res_plots, res_plot)
6570
end
6671

67-
6872
combined_plot = plot(
6973
[rplt for rplt in res_plots]...,
7074
layout=(length(node_list),1),
-350 KB
Binary file not shown.

0 commit comments

Comments
 (0)