Closed thwald closed 2 years ago
Hello @thwald,
I tried to reproduce your examle. The function run_swmm()
returns without giving an error. However, when running swmm from the command line I got the following output
... EPA SWMM 5.2 (Build 5.2.0)
o Retrieving project data
... EPA SWMM completed in 0.00 seconds. There are errors.
In the created report file Kelze_with_groundwater.rpt
I found:
*********************
Rainfall File Summary
*********************
Station First Last Recording Periods Periods Periods
ID Date Date Frequency w/Precip Missing Malfunc.
-------------------------------------------------------------------------------
ERROR 317: cannot open rainfall data file C:\Users\hsonne\Documents\github-repos\S\swmmr\rain_5min.dat.
.rpt
file?.rpt
file?rain_5min.dat
?Hint: You may look for error messages in the report file from within the script like that:
grep("ERROR", readLines(tmp_rpt_file, warn = FALSE), value = TRUE)
Hello @hsonne, thank you for your response.
When running the model via SWMM interface, I cannot find the same or any error in the created .rpt
file.
Reading the tmp_rpt_file created via swmmr, I found this:
$raingage_summary
# A tibble: 1 × 4
Name Data_Source Data_Type Recording_Interval
<chr> <chr> <lgl> <lgl>
1 RG1 D:/Studenten_Innen/MA_Theresa/SWMM/Kelze_with_groundwater.inprain_5min.dat NA NA
Plus, searching for error messages as suggested by you gives me the same error:
> grep("ERROR", readLines(tmp_rpt_file, warn = FALSE), value = TRUE)
[1] " ERROR 317: cannot open rainfall data file D:/Studenten_Innen/MA_Theresa/SWMM/Kelze_with_groundwater.inprain_5min.dat."
The path to the rain file doesn't look right to me, it should be just "D:\Studenten_Innen\MA_Theresa\SWMM\rain_5min.dat". It is not clear to me why the path is set like that. Do I have to specify the right path somewhere in the script?
You can find the file rain_5min.dat
attached.
rain_5min.txt
Hello @thwald,
please try the following:
swmm_files <- run_swmm(
inp = normalizePath(inp_file), # convert slashes to backslashes on Windows
rpt = tmp_rpt_file,
out = tmp_out_file,
exec = exec # you should use the variable that you defined above ;)
)
I hope that this works for you. I was able to make the simulation run.
Background:
It seems that SWMM creates the full path to the rain data file from the path to the input_file inp_file
. To get the path to the parent folder in which the input file resides (in your case D:\Studenten_Innen\MA_Theresa\SWMM
), SWMM seems to split the path at backslashes "\"
and removes the last part, i.e. the name of the file, in your case Kelze_with_groundwater.inp
. Unfortunately, you gave the path with forward slashes "/"
(which is normally a good thing when working in R). SWMM could not determine the path to the parent folder correctly. By passing inp_file
to normalizePath()
the forward slashes in the path are converted to backslashes and SWMM (hopefully) correctly determines the path to your raindata file.
This should be handled by the function run_swmm()
. For now, I hope you can life with this workaround (given that it works for you).
Running the simulation works now - Thank you very much for your help and the explanation!
Welcome!
My aim is to autocalibrate my model using swmmr, according to the available vignette. Following the example shipped, everything works fine. (Because of using Modified Green-Ampt as infiltration model, I installed swmmr from GitHub, using changes made by @hsonne. However, I had the same issue before, using the CRAN-package.)
Changing the script according to my model, I receive the following error when starting run_swmm. (for complete script see the end) I have seen similar questions in issues #37 and #17, but it appears as if they were not really solved. Running the model in SWMM works fine.
Checking file.exists() gives me the following output:
Works for the tmp_rpt_file. Seems to me as if the temporary out-file is not being created/not available. I couldn't figure out why it works for the rpt-file, but not for the out-file. Does anybody have an idea what the explanation / a solution could be or if it is a bug?
Thank you.
Complete script: