class InpFile[source]#

Bases: object

EPANET INP file reader and writer class.

This class provides read and write functionality for EPANET INP files. The EPANET Users Manual provides full documentation for the INP file format.

read(inp_files, wn=None)[source]#

Read an EPANET INP file and load data into a water network model object. Both EPANET 2.0 and EPANET 2.2 INP file options are recognized and handled.

  • inp_files (str or list) – An EPANET INP input file or list of INP files to be combined

  • wn (WaterNetworkModel, optional) – An optional network model to append onto; by default a new model is created.


A water network model object

Return type:


write(filename, wn, units=None, version=2.2, force_coordinates=False)[source]#

Write a water network model into an EPANET INP file.


Please note that by default, an EPANET 2.2 formatted file is written by WNTR. An INP file with version 2.2 options will not work with EPANET 2.0 (neither command line nor GUI). By default, WNTR will use the EPANET 2.2 toolkit.

  • filename (str) – Name of the EPANET INP file.

  • units (str, int or FlowUnits) – Name of the units for the EPANET INP file to be written in.

  • version (float, {2.0, 2.2}) – Defaults to 2.2; use 2.0 to guarantee backward compatability, but this will turn off PDD mode and supress the writing of other EPANET 2.2-specific options. If PDD mode is specified, a warning will be issued.

  • force_coordinates (bool) – This only applies if is not None, and will force the COORDINATES section to be written even if a MAP file is provided. False by default, but coordinates are written by default since the MAP file is None by default.