@@ -9,20 +9,20 @@ config <- kwb.BerlinWaterModel.public::add_rain_direct_and_evaporation(config)
99
1010config <- kwb.BerlinWaterModel.public :: add_tracers(config )
1111
12- config <- kwb.BerlinWaterModel.public :: add_substances(config )
12+ # config <- kwb.BerlinWaterModel.public::add_substances(config)
1313
1414network <- kwb.BerlinWaterModel.public :: prepare_network(config )
1515
1616
1717# plot interactive network map ###############################################
1818
1919# ## Network graph
20- # net_complex <- kwb.BerlinWaterModel.public::plot_network_complex(network,
21- # config,
22- # show_labels = TRUE)
20+ net_complex <- kwb.BerlinWaterModel.public :: plot_network_complex(
21+ network ,
22+ config ,
23+ show_labels = TRUE )
2324
24- # htmlwidgets::saveWidget(net_complex, file = "water-cycle_complex.html")
25- # zip(zipfile = "water-cycle_complex.zip", files = "water-cycle_complex.html")
25+ htmlwidgets :: saveWidget(net_complex , file = " water-cycle_complex.html" )
2626
2727
2828# data preparation ###########################################################
@@ -48,30 +48,33 @@ input_list <- kwb.BerlinWaterModel.public::prepare_input(temporal_resolution = t
4848 ww = inputs $ ww ,
4949 wwtp = inputs $ wwtp ,
5050 bfshare_dynamic = FALSE , # use TRUE for dynamic bank filtration share (depending on Q)
51- date_min = " 2002 -01-01" ,
52- date_max = " 2022 -12-31" )
51+ date_min = " 2019 -01-01" ,
52+ date_max = " 2019 -12-31" )
5353
5454# ###############################################################################################
5555# ## Calculate flows ############################################################################
5656# ###############################################################################################
5757
5858system.time(
59- flows_dynamic <- kwb.BerlinWaterModel.public :: calculate_flows_auto(config = config ,
60- input_list = input_list ,
61- network = network ,
62- use_dynamic = TRUE , # FALSE: static values for flow shares at river branchings
63- debug = TRUE )
59+ flows_dynamic <- kwb.BerlinWaterModel.public :: calculate_flows_auto(
60+ config = config ,
61+ input_list = input_list ,
62+ network = network ,
63+ use_dynamic = TRUE , # FALSE: static values for flow shares at river branchings
64+ debug = TRUE )
6465)
6566
66- flows_stats <- kwb.BerlinWaterModel.public :: calculate_flow_stats(flows = flows_dynamic )
67+ flows_stats <- kwb.BerlinWaterModel.public :: calculate_flow_stats(
68+ flows = flows_dynamic )
6769
68- flows_dynamic_neg_flows_stat <- kwb.BerlinWaterModel.public :: get_reverse_flows_per_section(flows = flows_dynamic )
69- # openxlsx::write.xlsx(x = flows_neg_stat_evap_30, file = "flows_neg_stat_evap30_2019.xlsx")
70+ DT :: datatable(flows_stats $ per_section , caption = " Flow stats (per section)" )
71+ DT :: datatable(flows_stats $ per_year , caption = " Flow stats (per year)" )
72+ DT :: datatable(flows_stats $ per_month , caption = " Flow stats (per month)" )
7073
74+ flows_dynamic_neg_flows_stat <- kwb.BerlinWaterModel.public :: get_reverse_flows_per_section(
75+ flows = flows_dynamic )
7176
72- # Save flows of one or all sections to xls
73- openxlsx :: write.xlsx(x = flows_dynamic , file = " flows_days_2019_start-con-2019.xlsx" )
74- # openxlsx::write.xlsx(x = flows_dynamic[c("date", "H03")], file = "flows_H03_days.xlsx")
77+ DT :: datatable(flows_dynamic_neg_flows_stat , caption = " Sections with negative flows in 2019" )
7578
7679
7780# ###############################################################################################
@@ -88,60 +91,13 @@ system.time(
8891 debug = FALSE )
8992)
9093
91- # ## Save qualities for one or all sections in XLSX
92- # openxlsx::write.xlsx(x = qualities$conc$S21, file = "qualities_S21_days_dynamic_branching_fixJOH.xlsx")
93- openxlsx :: write.xlsx(x = qualities_00_dynamic_reverse $ conc , file = " qualities_hours_2017-2022_Fluoranthen_KW-0,0037_RW-0,22_MWÜ-0,2.xlsx" )
94+ # ## Save qualities for all sections in XLSX
95+ openxlsx :: write.xlsx(x = qualities_00_dynamic_reverse $ conc , file = " qualities_00_dynamic_reverse_concentrations.xlsx" )
9496
9597# save RDS for flows and qualities
96- # saveRDS(flows_dynamic, file = "flows_hours_2002-2022.Rds")
97- saveRDS(qualities_00_dynamic_reverse , file = " qualities_hours_2016-2022_Fluoranthen_KW-0,0037_RW-0,22_MWÜ-0,20.Rds" )
98-
99- # Read RDS for flows and qualities
100- qualities_00_dynamic_reverse <- readRDS(file = " qualities_hours_2016-2022_Fluoranthen_KW-0,0037_RW-0,22_MWÜ-0,20.Rds" )
101- flows_dynamic <- readRDS(file = " flows_hours_2002-2022.Rds" )
10298
99+ saveRDS(qualities_00_dynamic_reverse , file = " qualities_00_dynamic_reverse_concentrations.Rds" )
103100
104- # ############################################################################################
105- # ## prepare qsimVis output for map visualisation ############################################
106- # ############################################################################################
107-
108- if (FALSE ) {
109-
110- qsimVis_input <- kwb.BerlinWaterModel.public :: prepare_qsimVis_input(
111- config = config ,
112- flows = flows_dynamic ,
113- qualities = qualities_00_dynamic_reverse ) %> %
114- dplyr :: select(GewaesserId ,
115- Strang = " section_id" ,
116- Km ,
117- tidyselect :: starts_with(" date" ),
118- cbm_per_second ,
119- tracer.cso ,
120- tracer.rain_runoff ,
121- tracer.wwtp
122- # , ValsartansaeureAeq.mg.m3
123- # , Fluoranthen.mg.m3
124- ) %> %
125- dplyr :: rename(Q = cbm_per_second )
126-
127- # add section name
128- for (x in config $ sections $ section_id ){
129- qsimVis_input $ Strang [qsimVis_input $ Strang == x ] <-
130- paste(x ,config $ sections $ section_name [config $ sections $ section_id == x ], sep = " ." )
131- }
132-
133- # qsimVis_input[is.na(qsimVis_input)] <- 0
134-
135- col_date_time_idx <- stringr :: str_detect(names(qsimVis_input ), " ^date" )
136- names(qsimVis_input )[col_date_time_idx ] <- " Datum"
137-
138- qsimVis_input <- qsimVis_input %> %
139- dplyr :: mutate(Datum = format(Datum , format = " %d.%m.%Y %H:%M" , tz = " UTC" ))
140-
141- # readr::write_csv2(qsimVis_input,"qsimVis_input2.csv") takes much longer for big datasets
142- system.time(data.table :: fwrite(qsimVis_input , " qsimVis_input_hours_2017-2022_Fluoranthen_KW-0,0037_RW-0,22_MWÜ-0,20.csv" , sep = " ;" , dec = " ," ))
143-
144- }
145101
146102# ############################################################################################
147103# ## Diverse checks ##########################################################################
0 commit comments