BinFile#
module wntr.epanet.io
- class BinFile[source]#
Bases:
object
EPANET binary output file reader.
This class provides read functionality for EPANET binary output files.
- Parameters:
results_type (list of ResultType, optional) – This parameter is only active when using a subclass of the BinFile that implements a custom reader or writer, by default None. If None, then all results will be saved (node quality, demand, link flow, etc.). Otherwise, a list of result types can be passed to limit the memory used.
network (bool, optional) – Save a new WaterNetworkModel from the description in the output binary file, by default None. Certain elements may be missing, such as patterns and curves, if this is done.
energy (bool, optional) – Save the pump energy results, by default False.
statistics (bool, optional) – Save the statistics lines (different from the stats flag in the inp file) that are automatically calculated regarding hydraulic conditions, by default False.
convert_status (bool, optional) – Convert the EPANET link status (8 values) to simpler WNTR status (3 values), by default True. When this is done, the encoded-cause status values are converted simple stat values, instead.
- Returns:
A WNTR results object will be created and added to the instance after read.
- Return type:
- __init__(result_types=None, network=False, energy=False, statistics=False, convert_status=True)[source]#
- finalize_save(good_read, sim_warnings)[source]#
Post-process data before writing results.
This method, by default, does nothing. It is available to be overloaded in order to post process data.
- read(filename, convergence_error=False, darcy_weisbach=False, convert=True)[source]#
Read a binary file and create a results object.
- Parameters:
filename (str) – An EPANET BIN output file
convergence_error (bool (optional)) – If convergence_error is True, an error will be raised if the simulation does not converge. If convergence_error is False, partial results are returned, a warning will be issued, and results.error_code will be set to 0 if the simulation does not converge. Default = False.
- Returns:
returns a WaterNetworkResults object
- Return type:
- save_energy_line(pump_idx, pump_name, values)[source]#
Save pump energy from the output file.
This method, by default, does nothing. It is available to be overloaded in order to save information for pump energy calculations.
- save_network_desc_line(element, values)[source]#
Save network description meta-data and element characteristics.
This method, by default, does nothing. It is available to be overloaded, but the core implementation assumes that an INP file exists that will have a better, human readable network description.
- Parameters:
element (str) – The information being saved
values (numpy.array) – The values that go with the information