dleutnant / swmmr

R Interface for US EPA's SWMM
https://cran.r-project.org/package=swmmr
39 stars 15 forks source link

`into` must be a character vector #73

Closed NTIF closed 1 year ago

NTIF commented 2 years ago

this is my code: inp<-read_inp("D:/1.inp",rm.comment = TRUE)

then , this is the problem: Error in str_separate(): ! into must be a character vector

the file is exported from swmm5.1.0.14 I want to know the reason, thank you

dleutnant commented 2 years ago

Can you share your input file? Otherwise it's hardly reproducible.

joelnc commented 2 years ago

I hit on this recently and it was due to a non-included infiltration model in the .inp. I believe Modified GA and Modified Horton are not supported by read_inp at this time. If the .inp uses one of those, maybe try toggling the infiltration method to see if that resolves it.

lassiterdc commented 2 years ago

I am running into this same exact issue. I changing my infiltration model from Modified Green Ampt to Green Ampt then to Horton but continued getting the error. I've attached my .inp (just change the extension from .txt to .inp). model.txt

joelnc commented 2 years ago

EDIT: Weird, none of this changes that I can run your model with minimal modification. But, I just looked at your file and see that in addition to the infiltration model spec'd in the header, it has HORTON on every line in the infiltration parameter section starting at line 177. None of my models have that, and when I open my models in the GUI, per subcatchment infiltration models are not selectable, whereas in your model it is toggleable per subcatchment. Regardless, I can run your model with GA in the header and HORTON printed on every line as sits. But maybe worth looking into.

Hi Daniel,

I was just able to run your model and read in the file with read_inp() after opening it in the SWMM GUI and toggling to regular GA for the infiltration model. I caught the into error when trying to run it as provided with Modified GA. Are you able to execute read_inp without error for any input files you have on hand?

I'll admit I don't have great notes on all this, but at various times I have had to troubleshoot my swmmr workflow to a maddening extent. But at least right now I can confirm that I can run/read_inp fine on an example model with Horton, but get the error with Modified Horton. Same with your model toggling between GA and Modified GA. So that suggests nothing inherently wrong with your .inp file, but some other config issue which I don't have any good leads on. Very basic / probably not the issue, but I would be sure to close out of your R session / clear memory in between toggling model settings, make sure you run the edited model through run_swmm before invoking read_inp. Minimal working code below.

inp_file <- "C://Users/xxxxx/R/swmmr-workingFiles/oneOffs/model_lassiter.inp"

tmp_rpt_file <- tempfile()
tmp_out_file <- tempfile()

swmm_files <- run_swmm(inp=inp_file, rpt=tmp_rpt_file, out=tmp_out_file)

inp <- read_inp(swmm_files$inp) 
lassiterdc commented 2 years ago

Thanks for looking into this! I bet it has something to do with the fact that I'm using PCSWMM to set things up which does allow the user to select a different infiltration model for each subcatchment (though why anyone would want to do that is beyond me).

I had only been looking at the infiltration models applied by subcatchment starting on line 177 like you pointed out and your suggestion to fix it in the header worked for me too. Thank you so much for catching that!

hsonne commented 1 year ago

Hello @NTIF, @joelnc, @lassiterdc. I was asked by @dleutnant to help him maintain the swmmr package. Could you please try to install swmmr from the dev branch of this repository by running

remotes::install_github("dleutnant/swmmr@dev")

and confirm that the error reported here does not occur any more in that version? I will then close this issue.

joelnc commented 1 year ago

@hsonne. Sure. What exactly am I testing? From above, looks like I'd initially encountered this error when using Modified Horton as the infiltration model. Is that now supported? Happy to test if so. If not, not sure what I'm supposed to test.

Edit: Is the request to check if Modified Horton tirggers the following?

clean_warning( "Function is only running with Horton or Green_Ampt infiltration." )

hsonne commented 1 year ago

Hi @joelnc, the Modified GA and Modified Horton infiltration models should now be supported by the read_inp() function. I was just able to read the file model.txt uploaded by @lassiterdc with the dev version of this package without any error.

joelnc commented 9 months ago

@hsonne, probably not needed at this point, but I finally got around to install dev-branch and everything runs fine with Modified Horton. Appreciate your efforts on this.