Giter VIP home page Giter VIP logo

kwb.swmm's Introduction

R-CMD-check pkgdown codecov Project Status CRAN_Status_Badge DOI

kwb.swmm

R package with functions for working with EPA`s Storm Water Management Model SWMM.

Installation

For details on how to install KWB-R packages checkout our installation tutorial.

### Optionally: specify GitHub Personal Access Token (GITHUB_PAT)
### See here why this might be important for you:
### https://kwb-r.github.io/kwb.pkgbuild/articles/install.html#set-your-github_pat

# Sys.setenv(GITHUB_PAT = "mysecret_access_token")

# Install package "remotes" from CRAN
if (! require("remotes")) {
  install.packages("remotes", repos = "https://cloud.r-project.org")
}

# Install KWB package 'kwb.swmm' from GitHub
remotes::install_github("KWB-R/kwb.swmm")

Documentation

Release: https://kwb-r.github.io/kwb.swmm

Development: https://kwb-r.github.io/kwb.swmm/dev

kwb.swmm's People

Contributors

amatzi avatar mrustl avatar

Watchers

 avatar  avatar  avatar  avatar

kwb.swmm's Issues

bug in swmmr::read_out()

Reproducible example for bug identified with @amatzi in keys.lid (see KWB-R/keys.lid#17). Output files in attachment swmmr_bug_read_outputfile.zip

Needs to be fixed in upstream R package https://github.com/dleutnant/swmmr/ and an issue should be opened....

pkgs_cran <- c("remotes", "sessioninfo")


install.packages(pkgs_cran, repos = "https://cran.rstudio.org")
#> Installiere Pakete nach 'C:/Users/mrustl/Documents/R/win-library/4.1'
#> (da 'lib' nicht spezifiziert)
#> package 'remotes' successfully unpacked and MD5 sums checked
#> package 'sessioninfo' successfully unpacked and MD5 sums checked
#> 
#> The downloaded binary packages are in
#>  C:\Users\mrustl\AppData\Local\Temp\Rtmp6RyiWU\downloaded_packages
remotes::install_github("kwb-r/kwb.swmm")
#> Using github PAT from envvar GITHUB_PAT
#> Skipping install of 'kwb.swmm' from a github remote, the SHA1 (aa5d46ec) has not changed since last install.
#>   Use `force = TRUE` to force installation

model_name <- "zone-1_bioretention_cell.mulde_no-drainage_lidshare-0.00"
path_out_file <- paste0(model_name, ".out")
path_rpt_file <- paste0(model_name, ".rpt")


results_swmmr <- swmmr::read_out(file = path_out_file,
                          iType = 3,
                          vIndex = c(1,4))


results_system <- kwb.swmm::get_results(path_out = path_out_file,
                                        vIndex = c(1,4))

identical(sum(results_system$total_rainfall), 
          sum(results_swmmr$system_variable$total_rainfall)
          )
#> [1] TRUE

identical(sum(results_system$total_runoff), 
          sum(results_swmmr$system_variable$total_runoff)
          )
#> [1] TRUE

rpt_file <- swmmr::read_rpt(x = path_rpt_file)

knitr::kable(rpt_file$subcatchment_runoff_summary)
Subcatchment Total_Precip Total_Runon Total_Evap Total_Infil Total_Runoff_Depth Total_Runoff_Volume Total_Peak_Runoff Total_Runoff_Coeff
S1 6654.46 0 1874.83 0 5140.94 0 5140.94 5.14 5.79 0.773
## Different reporting in .rpt file and .out file ? 
## bug in swmmr ????
rpt_file$subcatchment_runoff_summary$Total_Precip
#> [1] 6654.46
sum(results_swmmr$system_variable$total_rainfall)
#> [1] 6654.46
sum(results_system$total_rainfall)
#> [1] 6654.46

rpt_file$subcatchment_runoff_summary$Total_Runoff_Depth
#> [1] 5140.94
sum(results_swmmr$system_variable$total_runoff)
#> [1] 1426.281
sum(results_system$total_runoff)
#> [1] 1426.281

### Sessioninfo
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.1.0 (2021-05-18)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  German_Germany.1252         
#>  ctype    German_Germany.1252         
#>  tz       Europe/Berlin               
#>  date     2021-06-15                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version    date       lib source                          
#>  cli           2.5.0      2021-04-26 [1] CRAN (R 4.1.0)                  
#>  crayon        1.4.1      2021-02-08 [1] CRAN (R 4.1.0)                  
#>  curl          4.3.1      2021-04-30 [1] CRAN (R 4.1.0)                  
#>  data.table    1.14.0     2021-02-21 [1] CRAN (R 4.1.0)                  
#>  digest        0.6.27     2020-10-24 [1] CRAN (R 4.1.0)                  
#>  dplyr         1.0.6      2021-05-05 [1] CRAN (R 4.1.0)                  
#>  ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.1.0)                  
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.1.0)                  
#>  fansi         0.5.0      2021-05-25 [1] CRAN (R 4.1.0)                  
#>  fs            1.5.0      2020-07-31 [1] CRAN (R 4.1.0)                  
#>  generics      0.1.0      2020-10-31 [1] CRAN (R 4.1.0)                  
#>  glue          1.4.2      2020-08-27 [1] CRAN (R 4.1.0)                  
#>  highr         0.9        2021-04-16 [1] CRAN (R 4.1.0)                  
#>  hms           1.1.0      2021-05-17 [1] CRAN (R 4.1.0)                  
#>  htmltools     0.5.1.1    2021-01-22 [1] CRAN (R 4.1.0)                  
#>  knitr         1.33       2021-04-24 [1] CRAN (R 4.1.0)                  
#>  kwb.event     0.3.0      2021-06-15 [1] Github (kwb-r/kwb.event@90cccfe)
#>  kwb.swmm      0.0.0.9000 2021-06-15 [1] Github (kwb-r/kwb.swmm@aa5d46e) 
#>  kwb.utils     0.7.0      2021-06-14 [1] Github (kwb-r/kwb.utils@c9f447a)
#>  lattice       0.20-44    2021-05-02 [2] CRAN (R 4.1.0)                  
#>  lifecycle     1.0.0      2021-02-15 [1] CRAN (R 4.1.0)                  
#>  magrittr      2.0.1      2020-11-17 [1] CRAN (R 4.1.0)                  
#>  pillar        1.6.1      2021-05-16 [1] CRAN (R 4.1.0)                  
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.1.0)                  
#>  ps            1.6.0      2021-02-28 [1] CRAN (R 4.1.0)                  
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.1.0)                  
#>  R6            2.5.0      2020-10-28 [1] CRAN (R 4.1.0)                  
#>  Rcpp          1.0.6      2021-01-15 [1] CRAN (R 4.1.0)                  
#>  readr         1.4.0      2020-10-05 [1] CRAN (R 4.1.0)                  
#>  remotes       2.4.0      2021-06-02 [1] CRAN (R 4.1.0)                  
#>  reprex        2.0.0      2021-04-02 [1] CRAN (R 4.1.0)                  
#>  rlang         0.4.11     2021-04-30 [1] CRAN (R 4.1.0)                  
#>  rmarkdown     2.8        2021-05-07 [1] CRAN (R 4.1.0)                  
#>  rstudioapi    0.13       2020-11-12 [1] CRAN (R 4.1.0)                  
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.1.0)                  
#>  stringi       1.6.1      2021-05-10 [1] CRAN (R 4.1.0)                  
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 4.1.0)                  
#>  swmmr         0.9.1      2020-03-02 [1] CRAN (R 4.1.0)                  
#>  tibble        3.1.2      2021-05-16 [1] CRAN (R 4.1.0)                  
#>  tidyr         1.1.3      2021-03-03 [1] CRAN (R 4.1.0)                  
#>  tidyselect    1.1.1      2021-04-30 [1] CRAN (R 4.1.0)                  
#>  utf8          1.2.1      2021-03-12 [1] CRAN (R 4.1.0)                  
#>  vctrs         0.3.8      2021-04-29 [1] CRAN (R 4.1.0)                  
#>  withr         2.4.2      2021-04-18 [1] CRAN (R 4.1.0)                  
#>  xfun          0.23       2021-05-15 [1] CRAN (R 4.1.0)                  
#>  xts           0.12.1     2020-09-09 [1] CRAN (R 4.1.0)                  
#>  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.1.0)                  
#>  zoo           1.8-9      2021-03-09 [1] CRAN (R 4.1.0)                  
#> 
#> [1] C:/Users/mrustl/Documents/R/win-library/4.1
#> [2] C:/Program Files/R/R-4.1.0/library

Created on 2021-06-15 by the reprex package (v2.0.0)

get_results is missing flow_rate when getting pump data

pump_names <- inp$pumps$Name

data_pumps <- kwb.swmm::get_results("00_template.out", 
                                    type = "links", 
                                    object_name = pump_names)

Here only the pump parameters average_water_depth, flow_velocity, volume_of_water and capacity gets loaded.

The parameter FLOW_RATE of pump is missing.

feat: check Python package "pyswmm"

More people contribute to pyswmm compared to swmmr, which we currently use in different projects.

However, pyswmm could be also accessed from R via the reticulate R package.

Using pyswmm would improve the readability of the code e.g. for LID definition which is cumbersome with swmmr (e.g. LID parameters defined by their column position instead of their names: https://github.com/KWB-R/LIDsensitivity/blob/master/sensitivityAnalysis.R#L85):
https://pyswmm.readthedocs.io/en/latest/tutorial/tutorial.html#lid-controls

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.