Skip to content

Commit 6d00695

Browse files
committed
Add feature to read error messages
i.e. number of errors per model run
1 parent 4299aa9 commit 6d00695

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

R/.raindrop.R

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ path_list <- list(
1010
dir_output = "<root_path>/Optimierungsfall/models/output",
1111
dir_target_output = "<dir_output>/<dir_target>",
1212
file_base = "Optimierungsfall_kurz.h5",
13-
file_errors = "Fehlerprotokoll.h5",
13+
file_errors_hdf5 = "Fehlerprotokoll.h5",
1414
file_exe = "Regenwasserbewirtschaftung.exe",
1515
file_results_hdf5 = "Optimierung_MuldenRigole.h5",
1616
file_results_txt = "Optimierung_MuldenRigole_RAINDROP.txt",
1717
file_results_txt_multilayer = "Optimierung_MuldenRigole_RAINDROP_multi_layer.txt",
1818
file_target = "<dir_target>.h5",
1919
path_base = "<dir_base>/<file_base>",
2020
path_exe = "<dir_exe>/<file_exe>",
21+
path_errors_hdf5 = "<dir_target_output>/<file_errors_hdf5>",
2122
path_results_hdf5 = "<dir_target_output>/<file_results_hdf5>",
2223
path_results_txt = "<dir_target_output>/<file_results_txt>",
2324
path_results_txt_multilayer = "<dir_target_output>/<file_results_txt_multilayer>",
@@ -96,6 +97,26 @@ states_long
9697
}
9798

9899

100+
simulation_names <- basename(fs::dir_ls(paths$dir_output))
101+
102+
103+
errors_df <- lapply(simulation_names, function(s_name) {
104+
105+
paths <- kwb.utils::resolve(path_list, dir_target = s_name)
106+
107+
if(fs::file_exists(paths$path_errors_hdf5)) {
108+
error_hdf <- hdf5r::H5File$new(paths$path_errors_hdf5, mode = "r")
109+
110+
tibble::tibble(id = i,
111+
path = paths$path_errors_hdf5,
112+
number_of_errors = error_hdf[["AnzahlFehler"]]$read()
113+
)
114+
}
115+
}) %>%
116+
dplyr::bind_rows()
117+
118+
res_hdf <- hdf5r::H5File$new(paths$path_results_hdf5, mode = "r")
119+
99120
hdf5_results <- list(
100121
rates = read_hdf5_timeseries(ts_groupvariable = res_hdf5[["Raten"]]),
101122
additional_evapotranspiration = read_hdf5_timeseries(ts_groupvariable = res_hdf5[["Zusaetzliche Variablen Evapotranspiration"]]),

0 commit comments

Comments
 (0)