epyt-flow 0.8.1__py3-none-any.whl → 0.10.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. epyt_flow/VERSION +1 -1
  2. epyt_flow/__init__.py +1 -0
  3. epyt_flow/data/benchmarks/batadal.py +1 -1
  4. epyt_flow/data/benchmarks/battledim.py +4 -3
  5. epyt_flow/data/benchmarks/gecco_water_quality.py +4 -4
  6. epyt_flow/data/benchmarks/leakdb.py +7 -7
  7. epyt_flow/data/benchmarks/water_usage.py +2 -2
  8. epyt_flow/data/networks.py +1 -1
  9. epyt_flow/gym/control_gyms.py +2 -2
  10. epyt_flow/gym/scenario_control_env.py +9 -1
  11. epyt_flow/metrics.py +28 -28
  12. epyt_flow/models/sensor_interpolation_detector.py +3 -3
  13. epyt_flow/rest_api/base_handler.py +4 -4
  14. epyt_flow/rest_api/scada_data/data_handlers.py +11 -11
  15. epyt_flow/rest_api/scada_data/export_handlers.py +2 -2
  16. epyt_flow/rest_api/scada_data/handlers.py +9 -9
  17. epyt_flow/rest_api/scenario/event_handlers.py +6 -6
  18. epyt_flow/rest_api/scenario/handlers.py +15 -15
  19. epyt_flow/rest_api/scenario/simulation_handlers.py +7 -7
  20. epyt_flow/rest_api/scenario/uncertainty_handlers.py +6 -6
  21. epyt_flow/serialization.py +8 -2
  22. epyt_flow/simulation/events/actuator_events.py +1 -1
  23. epyt_flow/simulation/events/leakages.py +1 -1
  24. epyt_flow/simulation/events/quality_events.py +16 -5
  25. epyt_flow/simulation/events/sensor_reading_attack.py +17 -4
  26. epyt_flow/simulation/events/sensor_reading_event.py +21 -6
  27. epyt_flow/simulation/events/system_event.py +1 -1
  28. epyt_flow/simulation/parallel_simulation.py +1 -1
  29. epyt_flow/simulation/scada/__init__.py +3 -1
  30. epyt_flow/simulation/scada/advanced_control.py +8 -4
  31. epyt_flow/simulation/scada/complex_control.py +625 -0
  32. epyt_flow/simulation/scada/custom_control.py +134 -0
  33. epyt_flow/simulation/scada/scada_data.py +133 -130
  34. epyt_flow/simulation/scada/scada_data_export.py +1 -1
  35. epyt_flow/simulation/scada/simple_control.py +317 -0
  36. epyt_flow/simulation/scenario_config.py +124 -24
  37. epyt_flow/simulation/scenario_simulator.py +514 -49
  38. epyt_flow/simulation/scenario_visualizer.py +9 -9
  39. epyt_flow/simulation/sensor_config.py +38 -28
  40. epyt_flow/topology.py +2 -2
  41. epyt_flow/uncertainty/model_uncertainty.py +624 -147
  42. epyt_flow/uncertainty/sensor_noise.py +94 -19
  43. epyt_flow/uncertainty/uncertainties.py +4 -4
  44. epyt_flow/uncertainty/utils.py +7 -7
  45. epyt_flow/utils.py +9 -8
  46. {epyt_flow-0.8.1.dist-info → epyt_flow-0.10.0.dist-info}/LICENSE +1 -1
  47. {epyt_flow-0.8.1.dist-info → epyt_flow-0.10.0.dist-info}/METADATA +7 -6
  48. {epyt_flow-0.8.1.dist-info → epyt_flow-0.10.0.dist-info}/RECORD +50 -47
  49. {epyt_flow-0.8.1.dist-info → epyt_flow-0.10.0.dist-info}/WHEEL +1 -1
  50. {epyt_flow-0.8.1.dist-info → epyt_flow-0.10.0.dist-info}/top_level.txt +0 -0
@@ -147,7 +147,7 @@ class ScenarioVisualizer:
147
147
 
148
148
  Parameters
149
149
  ----------
150
- scenario : :class:`epyt_flow.simulation.scenario_simulator.ScenarioSimulator`
150
+ scenario : :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`
151
151
  An instance of the `ScenarioSimulator` class, used to simulate and
152
152
  retrieve the system topology.
153
153
 
@@ -155,7 +155,7 @@ class ScenarioVisualizer:
155
155
  ------
156
156
  TypeError
157
157
  If `scenario` is not an instance of
158
- :class:`epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
158
+ :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
159
159
 
160
160
  """
161
161
  if not isinstance(scenario, ScenarioSimulator):
@@ -303,7 +303,7 @@ class ScenarioVisualizer:
303
303
 
304
304
  Parameters
305
305
  ----------
306
- scada_data : :class:`~epyt_flow.scada.scada_data.ScadaData`, optional
306
+ scada_data : :class:`~epyt_flow.simulation.scada.scada_data.ScadaData`, optional
307
307
  The SCADA data object to retrieve link data from. If `None`, a
308
308
  simulation is run to generate the SCADA data. Default is `None`.
309
309
  parameter : `str`, optional
@@ -644,7 +644,7 @@ class ScenarioVisualizer:
644
644
 
645
645
  Parameters
646
646
  ----------
647
- scada_data : :class:`~epyt_flow.scada.scad_data.ScadaData`, optional
647
+ scada_data : :class:`~epyt_flow.simulation.scada.scada_data.ScadaData`, optional
648
648
  The SCADA data object containing node data. If `None`, a simulation
649
649
  will be run to generate SCADA data. Default is `None`.
650
650
  parameter : `str`, optional
@@ -761,7 +761,7 @@ class ScenarioVisualizer:
761
761
 
762
762
  Parameters
763
763
  ----------
764
- scada_data : :class:`~epyt_flow.scada.scada_data.ScadaData`, optional
764
+ scada_data : :class:`~epyt_flow.simulation.scada.scada_data.ScadaData`, optional
765
765
  The SCADA data object. If `None`, the method will run a simulation.
766
766
  Default is `None`.
767
767
  parameter : `str`, optional
@@ -861,7 +861,7 @@ class ScenarioVisualizer:
861
861
 
862
862
  Parameters
863
863
  ----------
864
- scada_data : :class:`~epyt_flow.scada.scada_data.ScadaData`, optional
864
+ scada_data : :class:`~epyt_flow.simulation.scada.scada_data.ScadaData`, optional
865
865
  The SCADA data object containing the pump data. If `None`, a
866
866
  simulation will be run to generate SCADA data. Default is `None`.
867
867
  parameter : `str`, optional
@@ -971,7 +971,7 @@ class ScenarioVisualizer:
971
971
 
972
972
  Parameters
973
973
  ----------
974
- scada_data : :class:`~epyt_flow.scada.scada_data.ScadaData`, optional
974
+ scada_data : :class:`~epyt_flow.simulation.scada.scada_data.ScadaData`, optional
975
975
  The SCADA data object containing tank volume data.
976
976
  If `None`, a simulation will be run to generate it.
977
977
  Default is `None`.
@@ -1066,7 +1066,7 @@ class ScenarioVisualizer:
1066
1066
 
1067
1067
  Parameters
1068
1068
  ----------
1069
- scada_data : :class:`~epyt_flow.scada.scada_data.ScadaData`, optional
1069
+ scada_data : :class:`~epyt_flow.simulation.scada.scada_data.ScadaData`, optional
1070
1070
  The SCADA data object containing valve state data. If `None`, a
1071
1071
  simulation is run to generate SCADA data. Default is `None`.
1072
1072
  statistic : `str`, optional
@@ -1162,7 +1162,7 @@ class ScenarioVisualizer:
1162
1162
 
1163
1163
  Parameters
1164
1164
  ----------
1165
- scada_data : :class:`~epyt_flow.scada.scada_data.ScadaData`, optional
1165
+ scada_data : :class:`~epyt_flow.simulation.scada.scada_data.ScadaData`, optional
1166
1166
  The SCADA data object. If `None`, a simulation will be run to
1167
1167
  generate it. Default is `None`.
1168
1168
  parameter : `str`, optional
@@ -2,7 +2,6 @@
2
2
  Module provides a class for implementing sensor configurations.
3
3
  """
4
4
  from copy import deepcopy
5
- import warnings
6
5
  import itertools
7
6
  import numpy as np
8
7
  import epyt
@@ -465,7 +464,7 @@ class SensorConfig(JsonSerializable):
465
464
  """
466
465
  def __init__(self, nodes: list[str], links: list[str], valves: list[str], pumps: list[str],
467
466
  tanks: list[str], bulk_species: list[str], surface_species: list[str],
468
- flow_unit: int = None,
467
+ flow_unit: int,
469
468
  pressure_sensors: list[str] = [],
470
469
  flow_sensors: list[str] = [],
471
470
  demand_sensors: list[str] = [],
@@ -685,16 +684,11 @@ class SensorConfig(JsonSerializable):
685
684
  if any(s not in surface_species for s in surfacespecies_id_to_idx.keys()):
686
685
  raise ValueError("Unknown surface species ID in 'surfacespecies_id_to_idx'")
687
686
 
688
- if flow_unit is not None:
689
- if not isinstance(flow_unit, int):
690
- raise TypeError("'flow_unit' must be a an instance of 'int' " +
691
- f"but not of '{type(flow_unit)}'")
692
- if flow_unit not in range(10):
693
- raise ValueError("Invalid value of 'flow_unit'")
694
- else:
695
- warnings.warn("Loading a file that was created with an outdated version of EPyT-Flow" +
696
- " -- support of such old files will be removed in the next release!",
697
- DeprecationWarning)
687
+ if not isinstance(flow_unit, int):
688
+ raise TypeError("'flow_unit' must be a an instance of 'int' " +
689
+ f"but not of '{type(flow_unit)}'")
690
+ if flow_unit not in range(10):
691
+ raise ValueError("Invalid value of 'flow_unit'")
698
692
 
699
693
  if quality_unit is not None:
700
694
  if not isinstance(quality_unit, int):
@@ -1282,6 +1276,22 @@ class SensorConfig(JsonSerializable):
1282
1276
  """
1283
1277
  return self.__links.copy()
1284
1278
 
1279
+ @property
1280
+ def junctions(self) -> list[str]:
1281
+ """
1282
+ Returns all junction IDs.
1283
+
1284
+ Returns
1285
+ -------
1286
+ `list[str]`
1287
+ All juncitons IDs.
1288
+ """
1289
+ junctions = self.nodes
1290
+ for tank_id in self.tanks:
1291
+ junctions.remove(tank_id)
1292
+
1293
+ return junctions
1294
+
1285
1295
  @property
1286
1296
  def valves(self) -> list[str]:
1287
1297
  """
@@ -1781,12 +1791,12 @@ class SensorConfig(JsonSerializable):
1781
1791
  @property
1782
1792
  def sensors_id_to_idx(self) -> dict:
1783
1793
  """
1784
- Gets a mapping of sensor IDs to indices in the final Numpy array returned by `get_data()`.
1794
+ Gets a mapping of sensor IDs to indices in the final `Numpy array <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_ returned by `get_data()`.
1785
1795
 
1786
1796
  Returns
1787
1797
  -------
1788
1798
  `dict`
1789
- Mapping of sensor IDs to indices in the final Numpy array.
1799
+ Mapping of sensor IDs to indices in the final `Numpy array <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_.
1790
1800
  """
1791
1801
  return deepcopy(self.__sensors_id_to_idx)
1792
1802
 
@@ -1987,39 +1997,39 @@ class SensorConfig(JsonSerializable):
1987
1997
 
1988
1998
  Parameters
1989
1999
  ----------
1990
- pressures : `numpy.ndarray`
2000
+ pressures : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
1991
2001
  Pressure values at all nodes.
1992
- flows : `numpy.ndarray`
2002
+ flows : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
1993
2003
  Flow values at all links/pipes.
1994
- demands : `numpy.ndarray`
2004
+ demands : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
1995
2005
  Demand values at all nodes.
1996
- nodes_quality : `numpy.ndarray`
2006
+ nodes_quality : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
1997
2007
  Quality values at all nodes.
1998
- links_quality : `numpy.ndarray`
2008
+ links_quality : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
1999
2009
  Quality values at all links/pipes.
2000
- pumps_state : `numpy.ndarray`
2010
+ pumps_state : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
2001
2011
  States of all pumps.
2002
- pumps_efficiency : `numpy.ndarray`
2012
+ pumps_efficiency : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
2003
2013
  Efficiency of all pumps.
2004
- pumps_energyconsumption : `numpy.ndarray`
2014
+ pumps_energyconsumption : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
2005
2015
  Energy consumption of all pumps.
2006
- valves_state : `numpy.ndarray`
2016
+ valves_state : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
2007
2017
  States of all valves.
2008
- tanks_volume : `numpy.ndarray`
2018
+ tanks_volume : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
2009
2019
  Water volume in all tanks.
2010
- bulk_species_node_concentrations : `numpy.ndarray`
2020
+ bulk_species_node_concentrations : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
2011
2021
  Bulk species concentrations at all nodes.
2012
2022
 
2013
2023
  Expect a three-dimensional array: First dimension denotes time,
2014
2024
  second dimension corresponds to species ID,
2015
2025
  and third dimension contains the concentration.
2016
- bulk_species_link_concentrations : `numpy.ndarray`
2026
+ bulk_species_link_concentrations : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
2017
2027
  Bulk species concentrations at all links/pipes.
2018
2028
 
2019
2029
  Expect a three-dimensional array: First dimension denotes time,
2020
2030
  second dimension corresponds to species ID,
2021
2031
  and third dimension contains the concentration.
2022
- surface_species_concentrations : `numpy.ndarray`
2032
+ surface_species_concentrations : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
2023
2033
  Surface species concentrations at all links/pipes.
2024
2034
 
2025
2035
  Expect a three-dimensional array: First dimension denotes time,
@@ -2028,7 +2038,7 @@ class SensorConfig(JsonSerializable):
2028
2038
 
2029
2039
  Returns
2030
2040
  -------
2031
- `numpy.ndarray`
2041
+ `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
2032
2042
  Sensor readings.
2033
2043
  """
2034
2044
  data = []
epyt_flow/topology.py CHANGED
@@ -552,7 +552,7 @@ class NetworkTopology(nx.Graph, JsonSerializable):
552
552
  Returns
553
553
  -------
554
554
  `dict`
555
- Network topology as a dictionary of `geopandas.GeoDataFrames` instances.
555
+ Network topology as a dictionary of `geopandas.GeoDataFrames <https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.html>`_ instances.
556
556
  If a quantity does not exist, the data frame will be None.
557
557
  """
558
558
  gis = {"nodes": None, "links": None,
@@ -629,7 +629,7 @@ class NetworkTopology(nx.Graph, JsonSerializable):
629
629
 
630
630
  Returns
631
631
  -------
632
- `scipy.bsr_array`
632
+ `scipy.bsr_array <https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.bsr_array.html>`_
633
633
  Adjacency matrix as a sparse array.
634
634
  """
635
635
  nodes_id = [node_id for node_id, _ in self.__nodes]