epyt_flow
- epyt_flow.data
- epyt_flow.data.benchmarks
- epyt_flow.data.networks
create_empty_sensor_config()get_default_hydraulic_options()load_anytown()load_balerma()load_bwsn1()load_bwsn2()load_ctown()load_dtown()load_hanoi()load_inp()load_kentucky()load_ltown()load_ltown_a()load_micropolis()load_net1()load_net2()load_net3()load_net6()load_richmond()load_rural()
- epyt_flow.gym
- epyt_flow.gym.scenario_control_env
ScenarioControlEnvScenarioControlEnv._scenario_simScenarioControlEnv._scenario_configScenarioControlEnv._sim_generatorScenarioControlEnv._hydraulic_scada_dataScenarioControlEnv.autoresetScenarioControlEnv.close()ScenarioControlEnv.contains_events()ScenarioControlEnv.reapply_uncertainties_at_resetScenarioControlEnv.reset()ScenarioControlEnv.set_node_quality_source_value()ScenarioControlEnv.set_node_species_source_value()ScenarioControlEnv.set_pump_speed()ScenarioControlEnv.set_pump_status()ScenarioControlEnv.set_valve_status()ScenarioControlEnv.step()
- epyt_flow.gym.scenario_control_env
- epyt_flow.simulation
- epyt_flow.simulation.scada
- epyt_flow.simulation.scada.scada_data
ScadaDataScadaData.bulk_species_link_concentration_rawScadaData.bulk_species_node_concentration_rawScadaData.change_sensor_config()ScadaData.change_sensor_faults()ScadaData.change_sensor_noise()ScadaData.change_sensor_reading_attacks()ScadaData.change_sensor_reading_events()ScadaData.concatenate()ScadaData.convert_units()ScadaData.demand_data_rawScadaData.extract_time_window()ScadaData.file_ext()ScadaData.flow_data_rawScadaData.frozen_sensor_configScadaData.get_attributes()ScadaData.get_data()ScadaData.get_data_bulk_species_concentrations_as_edge_features()ScadaData.get_data_bulk_species_concentrations_as_node_features()ScadaData.get_data_bulk_species_link_concentration()ScadaData.get_data_bulk_species_node_concentration()ScadaData.get_data_demands()ScadaData.get_data_demands_as_node_features()ScadaData.get_data_edge_features()ScadaData.get_data_flows()ScadaData.get_data_flows_as_edge_features()ScadaData.get_data_links_quality()ScadaData.get_data_links_quality_as_edge_features()ScadaData.get_data_node_features()ScadaData.get_data_nodes_quality()ScadaData.get_data_nodes_quality_as_node_features()ScadaData.get_data_pressures()ScadaData.get_data_pressures_as_node_features()ScadaData.get_data_pumps_efficiency()ScadaData.get_data_pumps_efficiency_as_node_features()ScadaData.get_data_pumps_energyconsumption()ScadaData.get_data_pumps_energyconsumption_as_node_features()ScadaData.get_data_pumps_state()ScadaData.get_data_pumps_state_as_node_features()ScadaData.get_data_surface_species_concentration()ScadaData.get_data_surface_species_concentrations_as_edge_features()ScadaData.get_data_tanks_water_volume()ScadaData.get_data_tanks_water_volume_as_node_features()ScadaData.get_data_valves_state()ScadaData.get_data_valves_state_as_node_features()ScadaData.get_topo_edge_indices()ScadaData.join()ScadaData.link_quality_data_rawScadaData.map_link_id_to_edge_idx()ScadaData.network_topoScadaData.node_quality_data_rawScadaData.plot_bulk_species_link_concentration()ScadaData.plot_bulk_species_node_concentration()ScadaData.plot_demands()ScadaData.plot_flows()ScadaData.plot_links_quality()ScadaData.plot_nodes_quality()ScadaData.plot_pressures()ScadaData.plot_pumps_efficiency()ScadaData.plot_pumps_energyconsumption()ScadaData.plot_pumps_state()ScadaData.plot_surface_species_concentration()ScadaData.plot_tanks_water_volume()ScadaData.plot_valves_state()ScadaData.pressure_data_rawScadaData.pumps_efficiency_data_rawScadaData.pumps_energyconsumption_data_rawScadaData.pumps_state_data_rawScadaData.sensor_configScadaData.sensor_faultsScadaData.sensor_noiseScadaData.sensor_reading_attacksScadaData.sensor_reading_eventsScadaData.sensor_readings_timeScadaData.surface_species_concentration_rawScadaData.tanks_volume_data_rawScadaData.to_excel_file()ScadaData.to_matlab_file()ScadaData.to_numpy_file()ScadaData.to_pandas_dataframe()ScadaData.topo_adj_matrix()ScadaData.valves_state_data_rawScadaData.warnings_code
- epyt_flow.simulation.scada.scada_data_export
- epyt_flow.simulation.scada.custom_control
- epyt_flow.simulation.scada.simple_control
- epyt_flow.simulation.scada.complex_control
- epyt_flow.simulation.scada.scada_data
- epyt_flow.simulation.events
- epyt_flow.simulation.events.event
- epyt_flow.simulation.events.system_event
- epyt_flow.simulation.events.leakages
- epyt_flow.simulation.events.quality_events
- epyt_flow.simulation.events.actuator_events
- epyt_flow.simulation.events.sensor_reading_event
- epyt_flow.simulation.events.sensor_faults
- epyt_flow.simulation.events.sensor_reading_attack
- epyt_flow.simulation.scenario_config
ScenarioConfigScenarioConfig.complex_controlsScenarioConfig.custom_controlsScenarioConfig.f_inp_inScenarioConfig.f_msx_inScenarioConfig.file_ext()ScenarioConfig.general_paramsScenarioConfig.get_attributes()ScenarioConfig.load_from_json()ScenarioConfig.load_from_json_file()ScenarioConfig.memory_consumption_estimateScenarioConfig.model_uncertaintyScenarioConfig.network_topologyScenarioConfig.sensor_configScenarioConfig.sensor_noiseScenarioConfig.sensor_reading_eventsScenarioConfig.simple_controlsScenarioConfig.system_events
- epyt_flow.simulation.simulator
ScenarioSimulatorScenarioSimulator.epanet_apiScenarioSimulator._model_uncertaintyScenarioSimulator._sensor_noiseScenarioSimulator._sensor_configScenarioSimulator._custom_controlsScenarioSimulator._simple_controlsScenarioSimulator._complex_controlsScenarioSimulator._system_eventsScenarioSimulator._sensor_reading_eventsScenarioSimulator.actuator_eventsScenarioSimulator.add_actuator_event()ScenarioSimulator.add_complex_control()ScenarioSimulator.add_custom_control()ScenarioSimulator.add_leakage()ScenarioSimulator.add_pattern()ScenarioSimulator.add_quality_source()ScenarioSimulator.add_sensor_fault()ScenarioSimulator.add_sensor_reading_attack()ScenarioSimulator.add_sensor_reading_event()ScenarioSimulator.add_simple_control()ScenarioSimulator.add_species_injection_source()ScenarioSimulator.add_system_event()ScenarioSimulator.close()ScenarioSimulator.complex_controlsScenarioSimulator.custom_controlsScenarioSimulator.enable_chemical_analysis()ScenarioSimulator.enable_sourcetracing_analysis()ScenarioSimulator.enable_waterage_analysis()ScenarioSimulator.estimate_memory_consumption()ScenarioSimulator.f_inp_inScenarioSimulator.f_msx_inScenarioSimulator.get_demand_model()ScenarioSimulator.get_events_active_time_points()ScenarioSimulator.get_flow_units()ScenarioSimulator.get_hydraulic_time_step()ScenarioSimulator.get_node_base_demand()ScenarioSimulator.get_node_demand_pattern()ScenarioSimulator.get_pattern()ScenarioSimulator.get_pressure_units()ScenarioSimulator.get_pump_energy_price()ScenarioSimulator.get_pump_energy_price_pattern()ScenarioSimulator.get_quality_model()ScenarioSimulator.get_quality_time_step()ScenarioSimulator.get_reporting_time_step()ScenarioSimulator.get_scenario_config()ScenarioSimulator.get_simulation_duration()ScenarioSimulator.get_topology()ScenarioSimulator.get_units_category()ScenarioSimulator.leakagesScenarioSimulator.model_uncertaintyScenarioSimulator.place_bulk_species_link_sensors_everywhere()ScenarioSimulator.place_bulk_species_node_sensors_everywhere()ScenarioSimulator.place_demand_sensors_everywhere()ScenarioSimulator.place_flow_sensors_everywhere()ScenarioSimulator.place_link_quality_sensors_everywhere()ScenarioSimulator.place_node_quality_sensors_everywhere()ScenarioSimulator.place_pressure_sensors_everywhere()ScenarioSimulator.place_pump_efficiency_sensors_everywhere()ScenarioSimulator.place_pump_energyconsumption_sensors_everywhere()ScenarioSimulator.place_pump_sensors_everywhere()ScenarioSimulator.place_pump_state_sensors_everywhere()ScenarioSimulator.place_sensors_everywhere()ScenarioSimulator.place_surface_species_sensors_everywhere()ScenarioSimulator.place_tank_sensors_everywhere()ScenarioSimulator.place_valve_sensors_everywhere()ScenarioSimulator.plot_topology()ScenarioSimulator.randomize_demands()ScenarioSimulator.remove_all_complex_controls()ScenarioSimulator.remove_all_simple_controls()ScenarioSimulator.remove_complex_control()ScenarioSimulator.remove_simple_control()ScenarioSimulator.run_advanced_quality_simulation()ScenarioSimulator.run_advanced_quality_simulation_as_generator()ScenarioSimulator.run_basic_quality_simulation()ScenarioSimulator.run_basic_quality_simulation_as_generator()ScenarioSimulator.run_hydraulic_simulation()ScenarioSimulator.run_hydraulic_simulation_as_generator()ScenarioSimulator.run_simulation()ScenarioSimulator.save_to_epanet_file()ScenarioSimulator.sensor_configScenarioSimulator.sensor_faultsScenarioSimulator.sensor_noiseScenarioSimulator.sensor_reading_attacksScenarioSimulator.sensor_reading_eventsScenarioSimulator.set_bulk_species_link_sensors()ScenarioSimulator.set_bulk_species_node_initial_concentrations()ScenarioSimulator.set_bulk_species_node_sensors()ScenarioSimulator.set_demand_sensors()ScenarioSimulator.set_flow_sensors()ScenarioSimulator.set_general_parameters()ScenarioSimulator.set_initial_link_status()ScenarioSimulator.set_initial_node_quality()ScenarioSimulator.set_initial_pump_speed()ScenarioSimulator.set_initial_tank_level()ScenarioSimulator.set_link_quality_sensors()ScenarioSimulator.set_model_uncertainty()ScenarioSimulator.set_node_demand_pattern()ScenarioSimulator.set_node_quality_sensors()ScenarioSimulator.set_pressure_sensors()ScenarioSimulator.set_pump_efficiency_sensors()ScenarioSimulator.set_pump_energy_price()ScenarioSimulator.set_pump_energy_price_pattern()ScenarioSimulator.set_pump_energyconsumption_sensors()ScenarioSimulator.set_pump_sensors()ScenarioSimulator.set_pump_state_sensors()ScenarioSimulator.set_quality_parameters()ScenarioSimulator.set_sensor_noise()ScenarioSimulator.set_sensors()ScenarioSimulator.set_species_link_initial_concentrations()ScenarioSimulator.set_surface_species_sensors()ScenarioSimulator.set_tank_sensors()ScenarioSimulator.set_valve_sensors()ScenarioSimulator.simple_controlsScenarioSimulator.system_events
- epyt_flow.simulation.parallel_simulation
- epyt_flow.simulation.sensor_config
SensorConfigSensorConfig.bulk_speciesSensorConfig.bulk_species_link_sensorsSensorConfig.bulk_species_mass_unitSensorConfig.bulk_species_node_sensorsSensorConfig.bulkspecies_id_to_idxSensorConfig.compute_readings()SensorConfig.create_empty_sensor_config()SensorConfig.demand_sensorsSensorConfig.file_ext()SensorConfig.flow_sensorsSensorConfig.flow_unitSensorConfig.get_as_dict()SensorConfig.get_attributes()SensorConfig.get_bulk_species_mass_unit_id()SensorConfig.get_index_of_reading()SensorConfig.get_surface_species_mass_unit_id()SensorConfig.is_empty()SensorConfig.junctionsSensorConfig.link_id_to_idxSensorConfig.linksSensorConfig.map_bulkspecies_id_to_idx()SensorConfig.map_link_id_to_idx()SensorConfig.map_node_id_to_idx()SensorConfig.map_pump_id_to_idx()SensorConfig.map_surfacespecies_id_to_idx()SensorConfig.map_tank_id_to_idx()SensorConfig.map_valve_id_to_idx()SensorConfig.node_id_to_idxSensorConfig.nodesSensorConfig.place_sensors_everywhere()SensorConfig.pressure_sensorsSensorConfig.pressure_unitSensorConfig.pump_efficiency_sensorsSensorConfig.pump_energyconsumption_sensorsSensorConfig.pump_id_to_idxSensorConfig.pump_state_sensorsSensorConfig.pumpsSensorConfig.quality_link_sensorsSensorConfig.quality_node_sensorsSensorConfig.quality_unitSensorConfig.sensor_orderingSensorConfig.sensors_id_to_idxSensorConfig.surface_speciesSensorConfig.surface_species_area_unitSensorConfig.surface_species_mass_unitSensorConfig.surface_species_sensorsSensorConfig.surfacespecies_id_to_idxSensorConfig.tank_id_to_idxSensorConfig.tank_volume_sensorsSensorConfig.tanksSensorConfig.validate()SensorConfig.valve_id_to_idxSensorConfig.valve_state_sensorsSensorConfig.valves
valid_sensor_types()
- epyt_flow.simulation.scada
- epyt_flow.visualization
- epyt_flow.visualization.scenario_visualizer
MarkerScenarioVisualizerScenarioVisualizer.__scenarioScenarioVisualizer.figScenarioVisualizer.axScenarioVisualizer.scada_dataScenarioVisualizer.topologyScenarioVisualizer.color_schemeScenarioVisualizer.pipe_parametersScenarioVisualizer.junction_parametersScenarioVisualizer.tank_parametersScenarioVisualizer.reservoir_parametersScenarioVisualizer.valve_parametersScenarioVisualizer.pump_parametersScenarioVisualizer.colorbarsScenarioVisualizer.labelsScenarioVisualizer.add_labels()ScenarioVisualizer.color_links()ScenarioVisualizer.color_nodes()ScenarioVisualizer.color_pumps()ScenarioVisualizer.color_tanks()ScenarioVisualizer.color_valves()ScenarioVisualizer.hide_nodes()ScenarioVisualizer.highlight_sensor_config()ScenarioVisualizer.resize_links()ScenarioVisualizer.show_animation()ScenarioVisualizer.show_plot()
- epyt_flow.visualization.visualization_utils
- epyt_flow.visualization.scenario_visualizer
- epyt_flow.uncertainty
- epyt_flow.uncertainty.model_uncertainty
ModelUncertaintyModelUncertainty.apply()ModelUncertainty.file_ext()ModelUncertainty.get_attributes()ModelUncertainty.global_base_demandModelUncertainty.global_constantsModelUncertainty.global_demand_patternModelUncertainty.global_elevationModelUncertainty.global_parametersModelUncertainty.global_pipe_diameterModelUncertainty.global_pipe_lengthModelUncertainty.global_pipe_roughnessModelUncertainty.local_base_demandModelUncertainty.local_constantsModelUncertainty.local_demand_patternModelUncertainty.local_elevationModelUncertainty.local_msx_patternsModelUncertainty.local_parametersModelUncertainty.local_patternsModelUncertainty.local_pipe_diameterModelUncertainty.local_pipe_lengthModelUncertainty.local_pipe_roughnessModelUncertainty.seedModelUncertainty.undo()
- epyt_flow.uncertainty.sensor_noise
- epyt_flow.uncertainty.uncertainties
AbsoluteDeepGaussianUncertaintyAbsoluteDeepUncertaintyAbsoluteDeepUniformUncertaintyAbsoluteGaussianUncertaintyAbsoluteUniformUncertaintyDeepGaussianUncertaintyDeepUncertaintyDeepUniformUncertaintyGaussianUncertaintyPercentageDeviationUncertaintyRelativeDeepGaussianUncertaintyRelativeDeepUncertaintyRelativeDeepUniformUncertaintyRelativeGaussianUncertaintyRelativeUniformUncertaintyUncertaintyUniformUncertainty
- epyt_flow.uncertainty.utils
- epyt_flow.uncertainty.model_uncertainty
- epyt_flow.rest_api
- epyt_flow.rest_api.scada_data
- epyt_flow.rest_api.scada_data.handlers
- epyt_flow.rest_api.scada_data.data_handlers
ScadaDataDemandsHandlerScadaDataFlowsHandlerScadaDataLinkBulkSpeciesHandlerScadaDataLinksQualityHandlerScadaDataNodeBulkSpeciesHandlerScadaDataNodesQualityHandlerScadaDataPressuresHandlerScadaDataPumpStatesHandlerScadaDataSurfaceSpeciesHandlerScadaDataTankVolumesHandlerScadaDataValveStatesHandler
- epyt_flow.rest_api.scada_data.export_handlers
- epyt_flow.rest_api.scenario
- epyt_flow.rest_api.scenario.handlers
- epyt_flow.rest_api.scenario.simulation_handlers
- epyt_flow.rest_api.scenario.control_handlers
- epyt_flow.rest_api.scenario.event_handlers
- epyt_flow.rest_api.scenario.uncertainty_handlers
- epyt_flow.rest_api.server
- epyt_flow.rest_api.res_manager
- epyt_flow.rest_api.base_handler
- epyt_flow.rest_api.scada_data
epyt_flow.serialization
Module provides functions and classes for serialization.
- class epyt_flow.serialization.JsonSerializable(_parent_path: str = '', **kwds)[source]
Bases:
SerializableBase class for JSON serializable classes. Inherits from
Serializable.- static load_from_json(data: str) Any[source]
Loads (i.e. deserializes) an instance of this class from given JSON data.
- Parameters:
data (str) – JSON data.
- Returns:
Deserialized instance of this class.
- Return type:
Any
- static load_from_json_file(f_in: str) Any[source]
Deserializes an instance of this class from a JSON file.
- Parameters:
f_in (str) – Path to the JSON file from which to deserialize the object.
- Returns:
Deserialized object.
- Return type:
Any
- class epyt_flow.serialization.Serializable(_parent_path: str = '', **kwds)[source]
Bases:
ABCBase class for a serializable class – must be used in conjunction with the
serializable()decorator.- dump(stream_out: BufferedIOBase | None = None) Any[source]
Serializes this object to a byte array.
- Parameters:
stream_out (io.BufferedIOBase, optional) –
Stream to which the serialized object is written. If None, the serialized object is returned as a bytes array.
The default is None.
- Returns:
If stream_out is None, the serialized object is returned as a bytes array.
- Return type:
bytes
- file_ext() str[source]
Returns the file extension of this class.
This function is automatically implemented by applying the
serializable()decorator.- Returns:
File extension.
- Return type:
str
- abstract get_attributes() dict[source]
Gets all attributes to be serialized – these attributes are passed to the constructor when the object is deserialized.
- Returns:
Dictionary of attributes – i.e. pairs of attribute name + value.
- Return type:
dict
- static load(data: bytes | BufferedIOBase) Any[source]
Deserializes an instance of this class.
- Parameters:
data (bytes or io.BufferedIOBase) – Serialized data or stream from which serialized data can be read.
- Returns:
Deserialized object.
- Return type:
Any
- static load_from_file(f_in: str, use_zip: bool = True) Any[source]
Deserializes an instance of this class from a (compressed) file.
- Parameters:
f_in (str) – Path to the file from which to deserialize the object.
use_zip (bool, optional) –
If True, the file f_in is supposed to be zip compressed – False, if no compression was used when serializing the object.
The default is True.
- Returns:
Deserialized object.
- Return type:
Any
- packb() bytes[source]
Serializes the attributes of this object.
- Returns:
Serialized object.
- Return type:
bytes
- save_to_file(f_out: str, use_zip: bool = True) None[source]
Serializes this instance and stores it in a (compressed) file.
- Parameters:
f_in (str) – Path to the file where this serialized object will be stored.
use_zip (bool, optional) –
If True, the file f_in will be zip compressed – False, if no compression is wanted.
The default is True.
- epyt_flow.serialization.dump(data: Any, stream_out: BufferedIOBase | None = None) bytes | None[source]
Serializes some given data to a byte array.
- Parameters:
stream_out (io.BufferedIOBase, optional) –
Stream to which the serialized object is written. If None, the serialized object is returned as a bytes array.
The default is None.
- Returns:
Serialized data if stream_out is None – otherwise, nothing is returned.
- Return type:
bytes
- epyt_flow.serialization.load(data: bytes | BufferedIOBase) Any[source]
Deserializes data.
- Parameters:
data (bytes or io.BufferedIOBase) – Serialized data or stream from which serialized data can be read.
- Returns:
Deserialized data.
- Return type:
Any
- epyt_flow.serialization.load_from_file(f_in: str, use_compression: bool = True) Any[source]
Deserializes data from a (compressed) file.
- Parameters:
f_in (str) – Path to the file from which to deserialize the data.
use_compression (bool, optional) –
If True, the file f_in is supposed to be gzip compressed – False, if no compression was used when serializing the data.
The default is True.
- Returns:
Deserialized data.
- Return type:
Any
- epyt_flow.serialization.my_load_from_json(data: str) Any[source]
Loads (i.e. deserializes) an object from given JSON data.
- Parameters:
data (str) – JSON data.
- Returns:
Deserialized object.
- Return type:
Any
- epyt_flow.serialization.my_packb(data: Any) bytes[source]
Overriden umsgpack.packb method to support custom serialization handlers.
- epyt_flow.serialization.my_to_json(obj: Any) str[source]
Serializes a given object to JSON.
- Parameters:
obj (Any) – Object to be serialized.
- Returns:
JSON data.
- Return type:
str
- epyt_flow.serialization.my_unpackb(data: Any) Any[source]
Overriden umsgpack.unpackb method to support custom serialization handlers.
- epyt_flow.serialization.save_to_file(f_out: str, data: Any, use_compression: bool = True) None[source]
Serializes data and stores it in a (compressed) file.
- Parameters:
f_in (str) – Path to the file where the serialized data will be stored.
use_compression (bool, optional) –
If True, the file f_in will be gzip compressed – False, if no compression is wanted.
The default is True.
- epyt_flow.serialization.serializable(my_id: int, my_file_ext: str) Any[source]
Decorator for a serializable class – i.e. subclass of
Serializable.This decorator registers a new class as a serializable class.
- Parameters:
my_id (int) – ID of the class.
my_file_ext (str) – File extension.
epyt_flow.topology
Module provides a class for representing the topology of WDN.
- class epyt_flow.topology.NetworkTopology(f_inp: str, nodes: list[tuple[str, dict]], links: list[tuple[str, tuple[str, str], dict]], pumps: dict, valves: dict, curves: dict[str, tuple[int, list[tuple[float, float]]]], patterns: dict[str, list[float]], flow_units: int, pressure_units: int, **kwds)[source]
Bases:
Graph,JsonSerializableClass representing the topology of a WDN.
- Parameters:
f_inp (str) – Path to .inp file to which this topology belongs.
nodes (list[tuple[str, dict]]) – List of all nodes – i.e. node ID and node information such as type and elevation.
links (list[tuple[str, tuple[str, str], dict]]) – List of all links/pipes – i.e. link ID, ID of connecting nodes, and link information such as pipe diameter, length, etc.
pumps (dict) – List of all pumps – i.e. valve ID, and information such as pump type and connecting nodes.
valves (dict) – List of all valves – i.e. valve ID, and information such as valve type and connecting nodes.
curves (dict[str, tuple[int, list[tuple[float, float]]]]) – All curves – i.e. curve ID, and list of points.
patterns (dict[str, list[float]]) – All time patterns – i.e., pattern ID and list of multipliers.
flow_units (int) –
Flow units ID.
Must be one of the following EPANET constants:
EN_CFS = 0 (cubic foot/sec)
EN_GPM = 1 (gal/min)
EN_MGD = 2 (Million gal/day)
EN_IMGD = 3 (Imperial MGD)
EN_AFD = 4 (ac-foot/day)
EN_LPS = 5 (liter/sec)
EN_LPM = 6 (liter/min)
EN_MLD = 7 (Megaliter/day)
EN_CMH = 8 (cubic meter/hr)
EN_CMD = 9 (cubic meter/day)
EN_CMS = 10 (cubic meter/sec)
pressure_units (int) –
Pressue unit ID.
Must be one of the following EPANET constants:
EN_PSI = 0 (Pounds per square inch)
EN_KPA = 1 (Kilopascals)
EN_METERS = 2 (Meters)
EN_BAR = 3 (Bar)
EN_FEET = 4 (Feet)
- convert_units(flow_units: int, pressure_units: int) Any[source]
Converts this instance to a
NetworkTopologyinstance where everything is measured in given flow and pressure units.- Parameters:
flow_units (int) –
Flow unit ID.
Must be one of the following EPANET constants:
EN_CFS = 0 (cubic foot/sec)
EN_GPM = 1 (gal/min)
EN_MGD = 2 (Million gal/day)
EN_IMGD = 3 (Imperial MGD)
EN_AFD = 4 (ac-foot/day)
EN_LPS = 5 (liter/sec)
EN_LPM = 6 (liter/min)
EN_MLD = 7 (Megaliter/day)
EN_CMH = 8 (cubic meter/hr)
EN_CMD = 9 (cubic meter/day)
EN_CMS = 10 (cubic meter/sec)
pressure_units (int) –
Pressure unit ID.
Must be one of the following EPANET constants:
EN_PSI = 0 (Pounds per square inch)
EN_KPA = 1 (Kilopascals)
EN_METERS = 2 (Meters)
EN_BAR = 3 (Bar)
EN_FEET = 4 (Feet)
- Returns:
Network topology with the new measurements units.
- Return type:
- property curves: dict[str, tuple[int, list[tuple[float, float]]]]
Gets all curves – i.e., ID and list of points.
- Returns:
All curves.
- Return type:
dict[str, tuple[int, list[tuple[float, float]]]]
- static file_ext() str
Returns the file extension of this class.
This function is automatically implemented by applying the
serializable()decorator.- Returns:
File extension.
- Return type:
str
- property flow_units: int
Return the flow unit ID.
Will be one of the following EPANET constants:
EN_CFS = 0 (cubic foot/sec)
EN_GPM = 1 (gal/min)
EN_MGD = 2 (Million gal/day)
EN_IMGD = 3 (Imperial MGD)
EN_AFD = 4 (ac-foot/day)
EN_LPS = 5 (liter/sec)
EN_LPM = 6 (liter/min)
EN_MLD = 7 (Megaliter/day)
EN_CMH = 8 (cubic meter/hr)
EN_CMD = 9 (cubic meter/day)
EN_CMS = 10 (cubic meter/sec)
- Returns:
Flow unit ID.
- Return type:
int
- get_adj_list() dict[str, list[str]][source]
Returns the connectivity of the nodes (node IDs) as an adjacency list.
- Returns:
Adjacency list as a dictionary.
- Return type:
dict[str, list[str]]
- get_adj_matrix() scipy.sparse.bsr_array[source]
Gets the adjacency matrix of this graph.
- Returns:
Adjacency matrix as a sparse array.
- Return type:
- get_adjacent_links(node_id: str) list[tuple[str, tuple[str, str]]][source]
Gets all adjacent links/pipes of a given node.
- Parameters:
node_id (str) – ID of the node.
- Returns:
Adjacent links – i.e. (link ID, IDs of node end points).
- Return type:
list[tuple[str, tuple[str, str]]]
- get_all_junctions() list[str][source]
Gets all junctions – i.e. nodes that are not tanks or reservoirs.
- Returns:
List of all junctions.
- Return type:
list[str]
- get_all_links() list[tuple[str, tuple[str, str]]][source]
Gets a list of all links/pipes (incl. their end points).
- Returns:
List of links – (link ID, (left node ID, right node ID)).
- Return type:
list[tuple[str, tuple[str, str]]]
- get_all_nodes() list[str][source]
Gets a list of all nodes.
- Returns:
List of all nodes ID.
- Return type:
list[str]
- get_all_pairs_shortest_path(use_pipe_length_as_weight: bool = True) dict[source]
Computes the shortest path between all pairs of nodes in this graph.
- Parameters:
use_pipe_length_as_weight (bool, optional) –
If True, pipe lengths are used for the edge weights – otherwise, each edge weight is set to one.
The default is True.
- Returns:
Shortest paths between all pairs of nodes as nested dictionaries – first key is the start node, second key is the end node.
- Return type:
dict
- get_all_pairs_shortest_path_length(use_pipe_length_as_weight: bool = True) dict[source]
Computes the shortest path length between all pairs of nodes in this graph.
- Parameters:
use_pipe_length_as_weight (bool, optional) –
If True, pipe lengths are used for the edge weights – otherwise, each edge weight is set to one.
The default is True.
- Returns:
Shortest paths between all pairs of nodes as nested dictionaries – first key is the start node, second key is the end node.
- Return type:
dict
- get_all_pipes() list[tuple[str, tuple[str, str]]][source]
Gets all pipes – i.e. links that not valves or pumps.
- Returns:
List of all pipes – (link ID, (left node ID, right node ID)).
- Return type:
list[tuple[str, tuple[str, str]]]
- get_all_pumps() list[str][source]
Gets the IDs of all pumps.
- Returns:
Pump IDs.
- Return type:
list[str]
- get_all_reservoirs() list[str][source]
Gets all reservoirs – i.e. nodes that are not junctions or tanks.
- Returns:
List of all reservoirs.
- Return type:
list[str]
- get_all_tanks() list[str][source]
Gets all tanks – i.e. nodes that are not junctions or reservoirs.
- Returns:
List of all tanks.
- Return type:
list[str]
- get_all_valves() list[str][source]
Gets the IDs of all valves.
- Returns:
Valve IDs.
- Return type:
list[str]
- get_attributes() dict[source]
Gets all attributes to be serialized – these attributes are passed to the constructor when the object is deserialized.
- Returns:
Dictionary of attributes – i.e. pairs of attribute name + value.
- Return type:
dict
- get_link_info(link_id: str) dict[source]
Gets all information (e.g. diameter, length, etc.) associated with a given link.
Note that links can be pipes, pumps, or valves.
- Parameters:
link_id (str) – ID of the link.
- Returns:
Information associated with the given link.
- Return type:
dict
- get_neighbors(node_id: str) list[str][source]
Gets all neighboring nodes of a given node.
- Parameters:
node_id (str) – ID of the node.
- Returns:
IDs of neighboring nodes.
- Return type:
list[str]
- get_node_info(node_id: str) dict[source]
Gets all information (e.g. elevation, type, etc.) associated with a given node.
- Parameters:
node_id (str) – ID of the node.
- Returns:
Information associated with the given node.
- Return type:
dict
- get_number_of_junctions() int[source]
Returns the number of junctions.
- Returns:
Number of junctions.
- Return type:
int
- get_number_of_links() int[source]
Returns the number of links.
- Returns:
Number of links.
- Return type:
int
- get_number_of_nodes() int[source]
Returns the number of nodes.
- Returns:
Number of nodes.
- Return type:
int
- get_number_of_pipes() int[source]
Returns the number of pipes.
- Returns:
Number of pipes.
- Return type:
int
- get_number_of_pumps() int[source]
Returns the number of pumps.
- Returns:
Number of pumps.
- Return type:
int
- get_number_of_reservoirs() int[source]
Returns the number of reservoirs.
- Returns:
Number of reservoirs.
- Return type:
int
- get_number_of_tanks() int[source]
Returns the number of tanks.
- Returns:
Number of tanks.
- Return type:
int
- get_number_of_valves() int[source]
Returns the number of valves.
- Returns:
Number of valves.
- Return type:
int
- get_pump_info(pump_id: str) dict[source]
Gets all information associated with a given pump.
- Parameters:
pump_id (str) – ID of the pump.
- Returns:
Pump information.
- Return type:
dict
- get_shortest_path(start_node_id: str, end_node_id: str, use_pipe_length_as_weight: bool = True) list[str][source]
Computes the shortest path between two nodes in this graph.
- Parameters:
start_node_id (str) – ID of start node.
end_node_id (str) – ID of end node.
use_pipe_length_as_weight (bool, optional) –
If True, pipe lengths are used for the edge weights – otherwise, each edge weight is set to one.
The default is True.
- get_shortest_path_length(start_node_id: str, end_node_id: str, use_pipe_length_as_weight: bool = True) list[str][source]
Computes the shortest path length between two nodes in this graph.
- Parameters:
start_node_id (str) – ID of start node.
end_node_id (str) – ID of end node.
use_pipe_length_as_weight (bool, optional) –
If True, pipe lengths are used for the edge weights – otherwise, each edge weight is set to one.
The default is True.
- get_valve_info(valve_id: str) dict[source]
Gets all information associated with a given valve.
- Parameters:
valve_id (str) – ID of the valve.
- Returns:
Valve information.
- Return type:
dict
- property patterns: dict[str, list[float]]
Returns all time patterns – i.e., ID and list of multipliers.
- Returns:
All time patterns.
- Return type:
dict[str, list[float]]
- property pressure_units: int
Returns the pressure unit ID.
Will be one of the following EPANET constants:
EN_PSI = 0 (Pounds per square inch)
EN_KPA = 1 (Kilopascals)
EN_METERS = 2 (Meters)
EN_BAR = 3 (Bar)
EN_FEET = 4 (Feet)
- Returns:
Pressure unit ID.
- Return type:
int
- property pumps: dict
Gets all pumps – i.e. ID and associated information such as the pump type.
- Returns:
All pumps and their associated information.
- Return type:
dict
- to_gis(coord_reference_system: str | None = None, pumps_as_points: bool = False, valves_as_points: bool = False) dict[source]
Gets the network topology as a dictionary of geopandas.GeoDataFrames instances – i.e. each quantity (nodes, links/pipes, valves, etc.) is represented by a geopandas.GeoDataFrames instance.
- Parameters:
coord_reference_system (str, optional) –
Coordinate reference system.
The default is None.
pumps_as_points (bool, optional) –
If True, pumps are represented by points, otherwise by lines.
The default is False.
valves_as_points (bool, optional) –
If True, valves are represented by points, otherwise by lines.
The default is False.
- Returns:
Network topology as a dictionary of geopandas.GeoDataFrames instances. If a quantity does not exist, the data frame will be None.
- Return type:
dict
- to_inp_file(inp_file_out: str) None[source]
Creates an .inp file with the network layout and parameters as specified in this instance. Note that no control rules are set!
- Parameters:
inp_file_out (str) – Path to the .inp file.
- property valves: dict
Gets all valves – i.e. ID and associated information such as the valve type.
- Returns:
All valves and their associated information.
- Return type:
dict
- epyt_flow.topology.unitscategoryid_to_str(unit_category_id: int) str[source]
Converts a given units category ID to the corresponding description.
- Parameters:
unit_category_id (int) –
ID of the units category.
Must be one of the following constants:
UNITS_USCUSTOM = 0
UNITS_SIMETRIC = 1
- Returns:
Units category description.
- Return type:
str
epyt_flow.utils
Module provides helper functions.
- epyt_flow.utils.areaunit_to_id(unit_desc: str) int[source]
Converts a given area units string to the corresponding ID.
- Parameters:
unit_desc (str) – Area units string.
- Returns:
Corresponding area unit ID.
- Return type:
int
- epyt_flow.utils.areaunit_to_str(unit_id: int) str[source]
Converts a given area measurement unit ID to the corresponding description.
- Parameters:
unit_id (int) –
ID of the area unit.
Must be one of the following constants:
AREA_UNIT_FT2 = 1
AREA_UNIT_M2 = 2
AREA_UNIT_CM2 = 3
- Returns:
Area unit description.
- Return type:
str
- epyt_flow.utils.create_path_if_not_exist(path_in: str) None[source]
Creates a directory and all its parent directories if they do not already exist.
- Parameters:
path_in (str) – Path to be created.
- epyt_flow.utils.download_from_gdrive_if_necessary(download_path: str, url: str, verbose: bool = True) None[source]
Downloads a file from a google drive repository if it does not already exist in a given path.
Note that if the path (folder) does not already exist, it will be created.
- Parameters:
download_path (str) – Local path to the file – if this path does not exist, the file will be downloaded from the provided ‘url’ and stored in ‘download_dir’.
url (str) – Web-URL of the google drive repository.
verbose (bool, optional) –
If True, a progress bar is shown while downloading the file.
The default is True.
- epyt_flow.utils.download_if_necessary(download_path: str, url: str, verbose: bool = True, backup_urls: list[str] = [], timeout: int = 30) None[source]
Downloads a file from a given URL if it does not already exist in a given path. This function is deprecated, please use robust_download instead.
Note that if the path (folder) does not already exist, it will be created.
- Parameters:
download_path (str) – Local path to the file – if this path does not exist, the file will be downloaded from the provided ‘url’ and stored in ‘download_dir’.
url (str) – Web-URL.
verbose (bool, optional) –
If True, a progress bar is shown while downloading the file.
The default is True.
backup_urls (list[str], optional) –
List of alternative URLs that are being tried in the case that downloading from ‘url’ fails.
The default is an empty list.
timeout (int, optional) –
Allowed download inactivity in seconds. After this time passed without an update, the donwload is considered failed.
The default is 30 seconds.
- epyt_flow.utils.flowunit_to_str(unit_id: int) str[source]
Converts a given flow unit ID to the corresponding description.
- Parameters:
unit_id (int) –
Flow unit ID.
Must be one of the following EPANET constants:
EN_CFS = 0 (cubic foot/sec)
EN_GPM = 1 (gal/min)
EN_MGD = 2 (Million gal/day)
EN_IMGD = 3 (Imperial MGD)
EN_AFD = 4 (ac-foot/day)
EN_LPS = 5 (liter/sec)
EN_LPM = 6 (liter/min)
EN_MLD = 7 (Megaliter/day)
EN_CMH = 8 (cubic meter/hr)
EN_CMD = 9 (cubic meter/day)
EN_CMS = 10 (cubic meter/sec)
- Returns:
Flow unit description.
- Return type:
str
- epyt_flow.utils.get_temp_folder() str[source]
Gets a path to a temporary folder – i.e. a folder for storing temporary files.
- Returns:
Path to a temporary folder.
- Return type:
str
- epyt_flow.utils.is_flowunit_simetric(unit_id: int) bool[source]
Checks if a given flow unit belongs to SI metric units.
- Parameters:
unit_id (int) –
ID of the flow unit.
Must be one of the following EPANET constants:
EN_CFS = 0 (cubic foot/sec)
EN_GPM = 1 (gal/min)
EN_MGD = 2 (Million gal/day)
EN_IMGD = 3 (Imperial MGD)
EN_AFD = 4 (ac-foot/day)
EN_LPS = 5 (liter/sec)
EN_LPM = 6 (liter/min)
EN_MLD = 7 (Megaliter/day)
EN_CMH = 8 (cubic meter/hr)
EN_CMD = 9 (cubic meter/day)
EN_CMS = 10 (cubic meter/sec)
- Returns:
True if the fiven unit is a SI metric unit, False otherwise.
- Return type:
bool
- epyt_flow.utils.level_to_volume(tank_level: float, tank_diameter: float) float[source]
Computes the volume of water in a tank given the water level in the tank.
- Parameters:
tank_level (float) – Water level in the tank.
tank_diameter (float) – Diameter of the tank.
- Returns:
Water volume in tank.
- Return type:
float
- epyt_flow.utils.massunit_to_id(unit_desc: str) int[source]
Converts a given mass units string to the corresponding ID.
- Parameters:
unit_desc (str) – Mass units string.
- Returns:
Corresponding mass unit ID.
- Return type:
int
- epyt_flow.utils.massunit_to_str(unit_id: int) str[source]
Converts a given mass unit ID to the corresponding description.
- Parameters:
unit_id (int) –
ID of the mass unit.
Must be one of the following constant:
MASS_UNIT_MG = 4
MASS_UNIT_UG = 5
MASS_UNIT_MOL = 6
MASS_UNIT_MMOL = 7
MASS_UNIT_CUSTOM = 9
- Returns:
Mass unit description.
- Return type:
str
- epyt_flow.utils.pack_zip_archive(f_in: list[str], f_out: str) None[source]
Compresses a given list of files into a .zip archive.
- Parameters:
f_in (list[str]) – List of files to be compressed into the .zip archive.
f_out (str) – Path to the final .zip file.
- epyt_flow.utils.plot_timeseries_data(data: numpy.ndarray, labels: list[str] | None = None, x_axis_label: str | None = None, y_axis_label: str | None = None, y_ticks: tuple[list[float], list[str]] | None = None, show: bool = True, save_to_file: str | None = None, ax: matplotlib.axes.Axes | None = None) matplotlib.axes.Axes[source]
Plots a single or multiple time series.
- Parameters:
data (numpy.ndarray) – Time series data – each row in data corresponds to a complete time series.
labels (list[str], optional) –
Labels for each time series in data. If None, no labels are shown.
The default is None.
x_axis_label (str, optional) –
X axis label.
The default is None.
y_axis_label (str, optional) –
Y axis label.
The default is None.
y_ticks ((list[float], list[str]), optional) –
Tuple of ticks (numbers) and labels (strings) for the y-axis.
The default is None.
show (bool, optional) –
If True, the plot/figure is shown in a window.
Only considered when ‘ax’ is None.
The default is True.
save_to_file (str, optional) –
File to which the plot is saved.
If specified, ‘show’ must be set to False – i.e. a plot can not be shown and saved to a file at the same time!
The default is None.
ax (matplotlib.axes.Axes, optional) –
If not None, ‘ax’ is used for plotting.
The default is None.
- Returns:
Plot.
- Return type:
- epyt_flow.utils.plot_timeseries_prediction(y: numpy.ndarray, y_pred: numpy.ndarray, confidence_interval: numpy.ndarray | None = None, x_axis_label: str | None = None, y_axis_label: str | None = None, y_ticks: tuple[list[float], list[str]] | None = None, show: bool = True, save_to_file: str | None = None, ax: matplotlib.axes.Axes | None = None) matplotlib.axes.Axes[source]
Plots the prediction (e.g. forecast) of single time series together with the ground truth time series. In addition, confidence intervals can be plotted as well.
- Parameters:
y – Ground truth values.
y_pred – Predicted values.
confidence_interval –
Confidence interval (upper and lower value) for each prediction in y_pred. If not None, the confidence interval is plotted as well.
The default is None.
x_axis_label (str, optional) –
X axis label.
The default is None.
y_axis_label (str, optional) –
Y axis label.
The default is None.
y_ticks ((list[float], list[str]), optional) –
Tuple of ticks (numbers) and labels (strings) for the y-axis.
The default is None.
show (bool, optional) –
If True, the plot/figure is shown in a window.
Only considered when ‘ax’ is None.
The default is True.
save_to_file (str, optional) –
File to which the plot is saved.
If specified, ‘show’ must be set to False – i.e. a plot can not be shown and saved to a file at the same time!
The default is None.
ax –
If not None, ‘axes’ is used for plotting.
The default is None.
- Returns:
Plot.
- Return type:
- epyt_flow.utils.pressureunit_to_str(unit_id: int) str[source]
Converts a given pressure unit ID to the corresponding description.
- Parameters:
unit_id (int) –
Pressure unit ID.
Must be one of the following EPANET constants:
EN_PSI = 0 (Pounds per square inch)
EN_KPA = 1 (Kilopascals)
EN_METERS = 2 (Meters)
EN_BAR = 3 (Bar)
EN_FEET = 4 (Feet)
- Returns:
Pressure unit description.
- Return type:
str
- epyt_flow.utils.qualityunit_to_id(unit_desc: str) int[source]
Converts a given measurement unit description to the corresponding mass unit ID.
- Parameters:
unit_desc (str) – Mass unit.
- Returns:
Mass unit ID.
Will be either None (if no water quality analysis was set up) or one of the following constants:
MASS_UNIT_MG = 4 (mg/L)
MASS_UNIT_UG = 5 (ug/L)
TIME_UNIT_HRS = 8 (hrs)
- Return type:
int
- epyt_flow.utils.qualityunit_to_str(unit_id: int) str[source]
Converts a given quality measurement unit ID to the corresponding description.
- Parameters:
unit_id (int) –
ID of the quality unit.
Must be one of the following constants:
MASS_UNIT_MG = 4 (mg/L)
MASS_UNIT_UG = 5 (ug/L)
TIME_UNIT_HRS = 8 (hrs)
- Returns:
Mass unit description.
- Return type:
str
- epyt_flow.utils.robust_download(download_path: str, urls: str | list, verbose: bool = True, timeout: int = 30) None[source]
Downloads a file from the given urls if it does not already exist in the given path. The urls are tried in order. If a download stops or stalls, the next url is tried until one succeeds or all urls have failed.
- Parameters:
download_path (str) – Local path to the file – if this path does not exist, the file will be downloaded from the provided ‘urls’ and stored there.
urls (list or str) – One url or a list of urls (where additional urls function as backup) to download the file from.
verbose (bool, optional) –
If True, a progress bar is shown while downloading the file.
The default is True.
timeout (int) –
If this time passed without progress while downloading, the download is considered failed.
The default is 30 seconds.
- epyt_flow.utils.time_points_to_one_hot_encoding(time_points: list[int], total_length: int) list[int][source]
Converts a list of time points into a one-hot-encoding.
- Parameters:
time_points (list[int]) – Time points to be one-hot-encoded.
total_length (int) – Length of final one-hot-encoding.
- Returns:
One-hot-encoded time points.
- Return type:
list[int]
- epyt_flow.utils.to_seconds(days: int | None = None, hours: int | None = None, minutes: int | None = None) int[source]
Converts a timestamp (i.e. days, hours, minutes) into seconds.
- Parameters:
days (int, optional) – Days.
hours (int, optional) – Hours.
minutes (int, optional) – Minutes.
- Returns:
Timestamp in seconds.
- Return type:
int
- epyt_flow.utils.unpack_zip_archive(f_in: str, folder_out: str) None[source]
Unpacks a .zip archive.
- Parameters:
f_in (str) – Path to the .zip file.
folder_out (str) – Path to the folder where the unpacked files will be stored.
- epyt_flow.utils.volume_to_level(tank_volume: float, tank_diameter: float) float[source]
Computes the water level in a tank containing a given volume of water.
- Parameters:
tank_volume (float) – Water volume in the tank.
tank_diameter (float) – Diameter of the tank.
- Returns:
Water level in tank.
- Return type:
float