swmm-pandas 0.6.0__py3-none-any.whl → 0.7.2__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.
- swmm/pandas/__init__.py +1 -1
- swmm/pandas/input/_section_classes.py +68 -1
- {swmm_pandas-0.6.0.dist-info → swmm_pandas-0.7.2.dist-info}/METADATA +20 -6
- {swmm_pandas-0.6.0.dist-info → swmm_pandas-0.7.2.dist-info}/RECORD +7 -8
- {swmm_pandas-0.6.0.dist-info → swmm_pandas-0.7.2.dist-info}/WHEEL +1 -1
- {swmm_pandas-0.6.0.dist-info → swmm_pandas-0.7.2.dist-info}/licenses/LICENSE.md +0 -0
- swmm_pandas-0.6.0.dist-info/entry_points.txt +0 -4
swmm/pandas/__init__.py
CHANGED
|
@@ -1635,9 +1635,76 @@ class Losses(SectionDf):
|
|
|
1635
1635
|
return super(Losses, df).to_swmm_string()
|
|
1636
1636
|
|
|
1637
1637
|
|
|
1638
|
-
class Controls(
|
|
1638
|
+
class Controls(SectionBase):
|
|
1639
1639
|
_section_name = "CONTROLS"
|
|
1640
1640
|
|
|
1641
|
+
@dataclass
|
|
1642
|
+
class Control:
|
|
1643
|
+
name: str
|
|
1644
|
+
control_text: str
|
|
1645
|
+
desc: str
|
|
1646
|
+
|
|
1647
|
+
def __init__(self, controls: dict[str:Control]):
|
|
1648
|
+
self.controls = controls
|
|
1649
|
+
|
|
1650
|
+
@classmethod
|
|
1651
|
+
def from_section_text(cls, text: str, *args, **kwargs) -> Self:
|
|
1652
|
+
# The regex pattern:
|
|
1653
|
+
# (?m) - Enable multiline mode to make ^ match start of each line
|
|
1654
|
+
# ^ - Match start of line
|
|
1655
|
+
# \s* - Match any whitespace at start of line
|
|
1656
|
+
# RULE\s+ - Match "RULE" followed by whitespace
|
|
1657
|
+
# \S+ - Match the rule name (non-whitespace characters)
|
|
1658
|
+
rule_line_pattern = R"(?m)^\s*RULE\s+\S+"
|
|
1659
|
+
rules: dict[str : Controls.Control] = {}
|
|
1660
|
+
rule_start_pattern = R"(?m)(?:^;+.*\n)*^RULE.*"
|
|
1661
|
+
matches = list(re.finditer(rule_start_pattern, text))
|
|
1662
|
+
start_char = 0
|
|
1663
|
+
end_char = 0
|
|
1664
|
+
for imatch in range(len(matches)):
|
|
1665
|
+
if imatch == len(matches) - 1:
|
|
1666
|
+
end_char = -1
|
|
1667
|
+
else:
|
|
1668
|
+
end_char = matches[imatch + 1].start()
|
|
1669
|
+
|
|
1670
|
+
rule_block = text[start_char:end_char]
|
|
1671
|
+
mat = re.search(rule_line_pattern, rule_block)
|
|
1672
|
+
if mat is None:
|
|
1673
|
+
raise Exception(f"Error parsing rule\n{rule_block}")
|
|
1674
|
+
else:
|
|
1675
|
+
desc, rule = re.split(rule_line_pattern, rule_block)
|
|
1676
|
+
rule = f"{mat.group()}{rule}"
|
|
1677
|
+
rule_name = mat.group().split()[1]
|
|
1678
|
+
rules[rule_name] = Controls.Control(
|
|
1679
|
+
name=rule_name, control_text=rule, desc=desc
|
|
1680
|
+
)
|
|
1681
|
+
|
|
1682
|
+
start_char = end_char
|
|
1683
|
+
|
|
1684
|
+
return cls(rules)
|
|
1685
|
+
|
|
1686
|
+
@classmethod
|
|
1687
|
+
def _from_section_text(cls, text: str, *args, **kwargs) -> Self: ...
|
|
1688
|
+
|
|
1689
|
+
@classmethod
|
|
1690
|
+
def _new_empty(cls) -> Self:
|
|
1691
|
+
return cls({})
|
|
1692
|
+
|
|
1693
|
+
@classmethod
|
|
1694
|
+
def _newobj(cls, *args, **kwargs) -> Self:
|
|
1695
|
+
return cls(*args, **kwargs)
|
|
1696
|
+
|
|
1697
|
+
def to_swmm_string(self) -> str:
|
|
1698
|
+
out_text = ""
|
|
1699
|
+
for control in self.controls.controls.values():
|
|
1700
|
+
if len(control.desc) > 0:
|
|
1701
|
+
out_text += f"{control.desc.strip('\n')}\n"
|
|
1702
|
+
out_text += f"{control.control_text.strip('\n')}\n\n"
|
|
1703
|
+
return out_text
|
|
1704
|
+
|
|
1705
|
+
def add_control(self, name: str, control_text: str, desc: str):
|
|
1706
|
+
self.controls[name] = Controls.Control(name, control_text, desc)
|
|
1707
|
+
|
|
1641
1708
|
|
|
1642
1709
|
class Pollutants(SectionDf):
|
|
1643
1710
|
_section_name = "POLLUTANTS"
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: swmm-pandas
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: SWMM binary outputfile reader and API
|
|
5
|
-
|
|
5
|
+
Project-URL: Homepage, https://github.com/karosc/swmm-pandas
|
|
6
6
|
Author: See README.md
|
|
7
|
-
Author-
|
|
8
|
-
Maintainer-
|
|
7
|
+
Author-email: Constantine Karos <ckaros@outlook.com>
|
|
8
|
+
Maintainer-email: ckaros@outlook.com
|
|
9
9
|
License: CC BY 4.0
|
|
10
|
+
License-File: LICENSE.md
|
|
11
|
+
Keywords: ,hydraulics,hydrology,stormwater,swmm,swmm5
|
|
10
12
|
Classifier: Development Status :: 4 - Beta
|
|
11
13
|
Classifier: License :: Other/Proprietary License
|
|
12
14
|
Classifier: Operating System :: MacOS
|
|
@@ -18,11 +20,23 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
18
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
21
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
22
|
Classifier: Topic :: Scientific/Engineering
|
|
21
|
-
Project-URL: Homepage, https://github.com/karosc/swmm-pandas
|
|
22
23
|
Requires-Python: >=3.9
|
|
23
24
|
Requires-Dist: julian
|
|
24
25
|
Requires-Dist: pandas>=2.1
|
|
25
26
|
Requires-Dist: swmm-toolkit>=0.8.1
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: coverage; extra == 'dev'
|
|
29
|
+
Requires-Dist: furo; extra == 'dev'
|
|
30
|
+
Requires-Dist: ipython; extra == 'dev'
|
|
31
|
+
Requires-Dist: matplotlib; extra == 'dev'
|
|
32
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
33
|
+
Requires-Dist: myst-parser; extra == 'dev'
|
|
34
|
+
Requires-Dist: nbsphinx; extra == 'dev'
|
|
35
|
+
Requires-Dist: numpydoc; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
37
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
38
|
+
Requires-Dist: sphinx; extra == 'dev'
|
|
39
|
+
Requires-Dist: sphinx-autobuild; extra == 'dev'
|
|
26
40
|
Description-Content-Type: text/markdown
|
|
27
41
|
|
|
28
42
|

|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
swmm/pandas/__init__.py,sha256=
|
|
1
|
+
swmm/pandas/__init__.py,sha256=i4rwvkEEnNJDxKeI7ju_BvDnPCS_8ZmqUeheU0_evGI,187
|
|
2
2
|
swmm/pandas/constants.py,sha256=qa1tT8Fk1Fwx7WW1snRVQdsJqNvMppXGdOEvqS5pCL0,818
|
|
3
|
+
swmm/pandas/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
4
|
swmm/pandas/input/README.md,sha256=WYfDQZk4MLoog0DbJapj3A-nJ5Oymet87bTZctigTJ0,9061
|
|
4
5
|
swmm/pandas/input/__init__.py,sha256=kMclaDYaxKPslYApMP288JJ0q9OPukneMtxIM-XX2PE,88
|
|
5
|
-
swmm/pandas/input/_section_classes.py,sha256=
|
|
6
|
+
swmm/pandas/input/_section_classes.py,sha256=1Qg3EsxFaZWeLYmeOnsCz2DTzENkQzYoCT9riRkesGM,68272
|
|
6
7
|
swmm/pandas/input/input.py,sha256=a9zTmQnE-pUa9aspVnnoQ48Uol3O--BmY2bE8p3Ejl8,26834
|
|
7
8
|
swmm/pandas/input/model.py,sha256=g6rQaJU5YPTxWyU6guBzD-uS-EDO4Yhl6hnbyDerAAY,12503
|
|
8
9
|
swmm/pandas/output/__init__.py,sha256=SiYg_7jCB8jXIW6-3eKDSG6f4Svx7MfG6oSTSlYXhlg,96
|
|
9
10
|
swmm/pandas/output/output.py,sha256=UnCzG2qIjoSRfkXbYNbSydlJz-GVyuZAkDLZCxFbQwY,94946
|
|
10
11
|
swmm/pandas/output/structure.py,sha256=S4YkJxsNH5NypBsnHkCWTQRwV4SJPgMKemJTlfuur9U,11407
|
|
11
12
|
swmm/pandas/output/tools.py,sha256=s3zYKCQuSdf5knxMR8tWhXrzBIwO-z3Eyu_5E5lHUzw,909
|
|
12
|
-
swmm/pandas/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
swmm/pandas/report/__init__.py,sha256=0bPum2ycAhrk4BSM1_vScTH27btxhTPcvE2eRjVYaYg,45
|
|
14
14
|
swmm/pandas/report/report.py,sha256=WESMhm4DcfAkfLWgqxg5Sf1KWTUKbXlHMK9DXPKyy34,27012
|
|
15
|
-
swmm_pandas-0.
|
|
16
|
-
swmm_pandas-0.
|
|
17
|
-
swmm_pandas-0.
|
|
18
|
-
swmm_pandas-0.
|
|
19
|
-
swmm_pandas-0.6.0.dist-info/RECORD,,
|
|
15
|
+
swmm_pandas-0.7.2.dist-info/METADATA,sha256=8POmPvQKvG1-Xw1WR1e0F_IULFTk51_UkGriRCVUmSA,2945
|
|
16
|
+
swmm_pandas-0.7.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
17
|
+
swmm_pandas-0.7.2.dist-info/licenses/LICENSE.md,sha256=GVMQw_tyDr-ISCPZ4D5GuS2n_L9CQeZacvo9H3sQ-HU,17068
|
|
18
|
+
swmm_pandas-0.7.2.dist-info/RECORD,,
|
|
File without changes
|