22library(qsimVis )
33
44project_path <-
5- " Y:/iGB/Projects/IMPETUS/"
6- # "C:/Users/dwicke/Documents/work/IMPETUS"
5+ # "Y:/iGB/Projects/IMPETUS/"
6+ " C:/Users/dwicke/Documents/work/IMPETUS"
77 # "C:/Users/dwicke/Documents/R/Github"
88
9- data_path <- " Work-packages/WP4_Demonstration_KWB/CS-Berlin/04_Modelling/OGewaesser/BerlinWaterModel/Ergebnisse"
9+ data_path <- " Work-packages/WP4_Demonstration_KWB/CS-Berlin/04_Modelling/OGewaesser/BerlinWaterModel/Ergebnisse/MapPlots "
1010# file_name <- "qsimVis_input_days_test_250905.csv"
1111# data_path <- "kwb.BerlinWaterModel"
12- file_name <- " qsimVis_input_days_2002-2022_Valsartansäure_Ozonung_SCH .csv"
12+ file_name <- " qsimVis_input_days_2002-2022_Valsartansäure-Äq_no-OWA_ohne_Ozonung_mit-Zuflusskonz-OSK_V4 .csv"
1313
1414# find out about column names --------------------------------------------------
1515colNames <- read.csv(
@@ -20,7 +20,7 @@ print(colNames)
2020# load and prepare qsim data
2121df_in <- qsimVis :: QSIM_prepare(
2222 qsim_output_file = file.path(project_path , data_path , file_name ),
23- parameter_name = " Valsartan .mg.m3" , # "Valsartan.mg.m3" "tracer.wwtp", "tracer.rain"
23+ parameter_name = " ValsartansaeureAeq .mg.m3" , # "Fluoranthen.mg.m3", "ValsartansaeureAeq.mg.m3", "Valsartan.mg.m3" "tracer.wwtp", "tracer.rain"
2424 date_column_name = " Datum" ,
2525 id_column_name = " GewaesserId" ,
2626 km_column_name = " Km" ,
@@ -52,9 +52,11 @@ output <- list(
5252 " crit_events" = qsimVis :: critical_events(
5353 dataFrame = df_pro ,
5454 dev_type = " egt" , # auch "elt" = equal or lower than möglich
55- deficiency_hours = 24 ,
56- separating_hours = 0 ,
57- threshold = 0.6 ,
55+ # deficiency_hours = 24,
56+ # separating_hours = 0,
57+ deficiency_hours = 1 ,
58+ separating_hours = 6 ,
59+ threshold = 0.12 ,
5860 recovery_value = NULL ,
5961 return_event_positions = FALSE ),
6062 " stats" = qsimVis :: stats(
@@ -69,11 +71,13 @@ output_table <-
6971 # "adv_deviation"
7072 " stats"
7173 # "def_hours"
74+ # "crit_events"
7275
7376if (FALSE ) {
7477head(output $ adv_deviation )
7578head(output $ def_hours )
7679head(output $ stats )
80+ head(output $ crit_events )
7781head(output $ flow_mean )
7882}
7983
@@ -117,9 +121,10 @@ if(output_table == "def_hours"){
117121# Valsartansäure
118122if (output_table == " stats" ){
119123 output_column <- " mean"
120- classBreaks <- c(0 , 0.15 , 0.3 , 0.5 , 1 , 2 , 3 , 4 , 6 )
124+ # classBreaks <- c(0, 0.15, 0.3, 0.5, 1, 2, 3, 4, 6)
125+ classBreaks <- c(0 , 0.25 , 0.5 , 1 , 2 , 3 , 4 , 6 , 10 , 20 )
121126 colorVector <- NULL
122- LegendTitle <- " Konzentration Valsartansäure [µg/L]"
127+ LegendTitle <- " Konzentration Valsartansäure-äq (2002-2022) \n [µg/L]"
123128}
124129
125130# Fluoranthen
@@ -130,6 +135,14 @@ if(output_table == "stats"){
130135 LegendTitle <- " Konzentration Fluoranthen 2017-2022, Mittelwert [µg/L]"
131136}
132137
138+ # Fluoranthen - Anzahl krit. events
139+ if (output_table == " crit_events" ){
140+ output_column <- " events"
141+ classBreaks <- c(0 , 0.5 , 5 , 20 , 100 , 500 )
142+ colorVector <- c(" seagreen" , " gold" , " orange" , " red" , " darkred" ) # "darkgreen"
143+ LegendTitle <- " Anzahl Ereignisse >0.12 µg/L \n (ZHK-UQN)"
144+ }
145+
133146# #########################################################################################################
134147# Create map #############################################################################################
135148# #########################################################################################################
@@ -165,17 +178,58 @@ qsimVis::plot_empty_map(
165178)
166179
167180# Add Shape Background
168- qsimVis :: Berlin_add_boarder()
181+ qsimVis :: Berlin_add_boarder(
182+ bg_color = " gray90" ,
183+ frame = NA )
169184qsimVis :: Berlin_add_waterbodies()
170185
171186# Add Title
172- mtext(text = " Mittlere Konzentration Valsartansäure (2002-2022), Ozonung Schönerlinde" , side = 3 , line = 1 , cex = 1.2 , font = 1 )
187+ # mtext(text = "Relative Überschreitungsdauer der ZHK-UQN für Fluoranthen (2017-2022)", side = 3, line = 0.6, cex = 1.2, font = 1)
188+ # mtext(text = "Anzahl Überschreitungen der ZHK-UQN für Fluoranthen (2017-2022)", side = 3, line = 0.6, cex = 1.2, font = 1)
189+ # mtext(text = "Mittlere Konzentrationen für Fluoranthen (2017-2022)", side = 3, line = 0.6, cex = 1.2, font = 1)
190+ mtext(text = " Mittlere Konzentration Valsartansäure-äq, ohne Ozonung\n (Zufluss [µg/L]: Spree & OSK=0.46, Dahme=0.36, Havel=0.24, OWA=0)" , side = 3 , line = 0.6 , cex = 1.19 , font = 1 )
191+ # mtext(text = "Ozonung in allen 5 Berliner Klärwerken und Reduktion Zuflusskonzentrationen", side = 3, line = 0.6, cex = 1.19, font = 1)
173192
174193# Add colored Rivers
175194qsimVis :: add_coloredRivers(
176195 ext_rivers = rivers
177196)
178197
198+ qsimVis :: Berlin_add_poi(
199+ poiType = " wwtp" ,
200+ poiTitle = " Kläranlagen" ,
201+ fillColor = " sienna3" ,
202+ lineColor = " #6B3E3A" , # "#FF796D"
203+ plotNames = FALSE ,
204+ sw_connection = TRUE ,
205+ rivers = rivers ,
206+ pCex = 1.8 ,
207+ legendPosition = " topright" ,
208+ dashed_connection = FALSE )
209+
210+ qsimVis :: Berlin_add_poi(
211+ poiType = " dwtp" ,
212+ poiTitle = " Wasserwerke" ,
213+ fillColor = " steelblue3" , # "skyblue3" "steelblue2"
214+ lineColor = " #25496B" , # #9DD0FF",
215+ plotNames = FALSE ,
216+ sw_connection = FALSE ,
217+ rivers = rivers ,
218+ pCex = 1.8 ,
219+ legendPosition = " topright" )
220+
221+ # one single POI (--> KWB)
222+ # qsimVis::add_POI(
223+ # lat = 52.488674,
224+ # lon = 13.342737,
225+ # lineColor = "black",
226+ # fillColor = "black",
227+ # pch = 20,
228+ # cex = 1,
229+ # textbg = "orange",
230+ # title = "KWB"
231+ # )
232+
179233# Add Logos
180234qsimVis :: add_logo(
181235 logo_filename = " KWB_Logo.png" ,
@@ -202,7 +256,7 @@ qsimVis::add_river_legend(
202256
203257# Save as png
204258qsimVis :: saveActiveDevice(
205- filename = " WaterModelPlot_Valsartansäure_2002-2022_Ozonung_alle_KW_2 " ,
259+ filename = " WaterModelPlot_Valsartansäure_2002-2022_ohne_Ozonung_mit-POI2 " ,
206260 path = file.path(project_path , data_path ),
207261 type = " png" , # "vector" = svg-file
208262 resolution = " medium"
@@ -215,9 +269,17 @@ qsimVis::saveActiveDevice(
215269 type = " vector"
216270)
217271
272+
273+ output_clean <- output $ stats %> %
274+ dplyr :: select(" section_id" , " section_name" , " mean" , " sd" , " median" , " q90" ) %> %
275+ dplyr :: mutate(dplyr :: across(where(is.numeric ), \(x ) round(x , 3 ))) %> %
276+ dplyr :: arrange(section_id ) %> %
277+ dplyr :: group_by(section_id , section_name ) %> %
278+ dplyr :: summarize(dplyr :: across(where(is.numeric ), \(x ) mean(x )))
279+
218280# Write output table
281+ openxlsx :: write.xlsx(x = output_clean , " results_sections_2002-2022_Valsartansäure-Äq_no-OWA_Ozonung-alle-KW_mit-Zuflusskonz-OSK.xlsx" )
219282# writexl::write_xlsx(x = output, path = file.path(path, "Viewer_Skript", "output_table.xlsx"))
220283
221284
222285
223-
0 commit comments