https://travis-ci.org/timcera/swmmtoolbox.svg?branch=master https://coveralls.io/repos/timcera/swmmtoolbox/badge.png?branch=master Latest release BSD-3 clause license swmmtoolbox downloads

Usage

Just run “swmmtoolbox –help” from a command line to get a list of subcommands:

swmmtoolbox --help
usage: swmmtoolbox [-h]
                   {about,catalog,listdetail,listvariables,stdtoswmm5,getdata,extract}
                   ...

positional arguments:
  {about,catalog,listdetail,listvariables,stdtoswmm5,getdata,extract}
    about               Display version number and system information.
    catalog             List the catalog of objects in output file.
    listdetail          List nodes and metadata in output file.
    listvariables       List variables available for each type.
    stdtoswmm5          Take the toolbox standard format and return SWMM5
                        format.
    getdata             DEPRECATED: Use 'extract' instead.
    extract             Get the time series data for a particular object and
                        variable.

optional arguments:
  -h, --help            show this help message and exit

Sub-command Detail

extract

usage: swmmtoolbox extract [-h] filename [labels [labels ...]]

Get the time series data for a particular object and variable.

positional arguments:
  filename    Filename of SWMM output file.  The SWMM model must complete
    successfully for "swmmtoolbox" to correctly read it.

  labels      The remaining arguments uniquely identify a time-series
    in the binary file. The format is:
    'TYPE,NAME,VAR'

    For example: 'link,41a,Flow_rate node,C63,1 ...'
    The VAR part of the label can be the name of the variable or the index. The
    available variables and their indices can be found using:
    'swmmtoolbox listvariables filename.out'

    All of the available labels can be listed with:
    'swmmtoolbox catalog filename.out'

    There is a wild card feature for the labels, where leaving the part out will
    return all labels that match all other parts. For example,
    ┌─────────────────┬─────────────────────────────────────┐
    │ link,b52,       │ Return all variables for link "b52" │
    ├─────────────────┼─────────────────────────────────────┤
    │ link,,Flow_rate │ Return "Flow_rate" for all links    │
    ╘═════════════════╧═════════════════════════════════════╛

    Note that all labels require two commas and no spaces.


optional arguments:
  -h | --help
      show this help message and exit

list

usage: swmmtoolbox catalog [-h] [--itemtype ITEMTYPE] [--tablefmt TABLEFMT]
  [--header HEADER] filename

This catalog list is all of the labels that can be used in the extract routine.

positional arguments:
  filename             Filename of SWMM output file.  The SWMM model must complete
    successfully for "swmmtoolbox" to correctly read it.


optional arguments:
  -h | --help
      show this help message and exit
  --itemtype ITEMTYPE
      One of 'system', 'node', 'link', or 'pollutant' to identify the type of
      data you want to extract.
  --tablefmt TABLEFMT
      [optional, default is 'csv', output format]
      The table format. Can be one of 'csv', 'tsv', 'plain', 'simple', 'grid',
      'pipe', 'orgtbl', 'rst', 'mediawiki', 'latex', 'latex_raw' and
      'latex_booktabs'.
  --header HEADER
      [optional, default is 'default', output format]
      This is if you want a different header than is the default for this output
      table. Pass a list of strings for each column in the table.

listdetail

usage: swmmtoolbox listdetail [-h] [--name NAME] [--tablefmt TABLEFMT]
  [--header HEADER] filename itemtype

List nodes and metadata in output file.

positional arguments:
  filename             Filename of SWMM output file.  The SWMM model must complete
    successfully for "swmmtoolbox" to correctly read it.

  itemtype             One of 'system', 'node', 'link', or 'pollutant' to identify the
    type of data you want to extract.


optional arguments:
  -h | --help
      show this help message and exit
  --name NAME
      [optional, default is '']
      Specific name to print only that entry. This can be looked up using
      'listvariables'.
  --tablefmt TABLEFMT
      [optional, default is 'csv', output format]
      The table format. Can be one of 'csv', 'tsv', 'plain', 'simple', 'grid',
      'pipe', 'orgtbl', 'rst', 'mediawiki', 'latex', 'latex_raw' and
      'latex_booktabs'.
  --header HEADER
      [optional, default is 'default', output format]
      This is if you want a different header than is the default for this output
      table. Pass a list of strings for each column in the table.

listvariables

usage: swmmtoolbox listvariables [-h] [--tablefmt TABLEFMT] [--header HEADER]
  filename

The type are "subcatchment", "node", "link", "pollutant", "system".

positional arguments:
  filename             Filename of SWMM output file.  The SWMM model must complete
    successfully for "swmmtoolbox" to correctly read it.


optional arguments:
  -h | --help
      show this help message and exit
  --tablefmt TABLEFMT
      [optional, default is 'csv', output format]
      The table format. Can be one of 'csv', 'tsv', 'plain', 'simple', 'grid',
      'pipe', 'orgtbl', 'rst', 'mediawiki', 'latex', 'latex_raw' and
      'latex_booktabs'.
  --header HEADER
      [optional, default is 'default', output format]
      This is if you want a different header than is the default for this output
      table. Pass a list of strings for each column in the table.

stdtoswmm5

usage: swmmtoolbox stdtoswmm5 [-h] [--start_date START_DATE]
  [--end_date END_DATE] [--input_ts INPUT_TS]

Toolbox standard:

Datetime, Column_Name
2000-01-01 00:00:00 ,  45.6
2000-01-01 01:00:00 ,  45.2
...

SWMM5 format:

; comment line
01/01/2000 00:00, 45.6
01/01/2000 01:00, 45.2
...

optional arguments:
  -h | --help
      show this help message and exit
  --start_date START_DATE
      [optional, defaults to first date in time-series, input filter]
      The start_date of the series in ISOdatetime format, or 'None' for
      beginning.
  --end_date END_DATE
      [optional, defaults to last date in time-series, input filter]
      The end_date of the series in ISOdatetime format, or 'None' for end.
  --input_ts INPUT_TS
      [optional, required if using Python API, default is '-' (stdin)]
      Whether from a file or standard input, data requires a header of column
      names. The default header is the first line of the input, but this
      can be changed using the 'skiprows' option.
      Most separators will be automatically detected. Most common date formats
      can be used, but the closer to ISO 8601 date/time standard the
      better.
      Command line:
      +-------------------------+------------------------+
      | --input_ts=filename.csv | to read 'filename.csv' |
      +-------------------------+------------------------+
      | --input_ts='-'          | to read from standard  |
      |                         | input (stdin).         |
      +-------------------------+------------------------+
      
      In many cases it is better to use redirection rather that use
      `--input_ts=filename.csv`.  The following are identical:
      
      From a file:
      
          command subcmd --input_ts=filename.csv
      
      From standard input:
      
          command subcmd --input_ts=- < filename.csv
      
      The BEST way since you don't have to include `--input_ts=-` because
      that is the default:
      
          command subcmd < filename.csv
      
      Can also combine commands by piping:
      
          command subcmd < filename.csv | command subcmd1 > fileout.csv

      As Python Library:
      You MUST use the `input_ts=...` option where `input_ts` can be one
      of a [pandas DataFrame, pandas Series, dict, tuple,
      list, StringIO, or file name].
      
      If result is a time series, returns a pandas DataFrame.