Skip to main content

SWMMOutputLoader

Read EPA SWMM binary output files (.out) into Apache Arrow tables. SWMM writes this file during a simulation run. It holds the computed results of each reporting period.

SWMMOutputLoader
File extension.out
File typeBinary (little-endian)
OutputNamed Arrow tables (shape: 'tables')
Content checkThe first int32 is the magic number 516114522

Usage​

import { load } from "@loaders.gl/core";
import { getSWMMOutputTable, SWMMOutputLoader } from "@loaders.gl/graphs/swmm";

const results = await load("Example1.out", SWMMOutputLoader, {
"swmm-out": { variables: { link: ["flow"], node: ["depth", "flooding"] } },
});
const links = getSWMMOutputTable(results, "linkResults");
// Each cell is an Arrow Vector with one value per period.
const flowAtPeriod3 = links.getChild("flow")?.get(0)?.get(3);

For synchronous parsing, import SWMMOutputLoaderWithParser from @loaders.gl/graphs/swmm/bundled and pass it to parseSync from @loaders.gl/core. The @loaders.gl/graphs/swmm subpath exports metadata only. Asynchronous core APIs load the parser.

Options​

OptionTypeDefaultDescription
swmm-out.variables.subcatchmentstring[]undefinedSubcatchment variables to read. Omit for all.
swmm-out.variables.nodestring[]undefinedNode variables to read. Omit for all.
swmm-out.variables.linkstring[]undefinedLink variables to read. Omit for all.

An unknown variable name throws an error that names it. The systemResults table always has all system variables.

Errors​

The loader throws an error for these files:

  • The first int32 is not the magic number (magic number).
  • The file has no closing record, or it is shorter than its header specifies (truncated).
  • The closing record has an error code that is not 0 (error code N). SWMM did not complete the run.

Other structural errors throw SWMM output file is corrupt: ....

API​

ExportKind
SWMMOutputLoaderLoader
SWMMOutputLoaderOptionsType
SWMMOutputLoaderWithParserLoader
getSWMMOutputTableFunction
SWMMOutputTablesType
SWMMOutputTableNameType
SWMMOutputOptionsType

getSWMMOutputTable(tables, name) returns the named table, for example nodeResults. It throws an error when the table is absent. Import it from @loaders.gl/graphs/swmm.

Period t of each list is row t of the times table. Join the id column to the id column of the subcatchments, nodes or edges table of the .inp file. The list size is the period count of the run, so tables from runs with different period counts have different Arrow types. See Join results to the input tables.

See SWMM format for the output tables.