Skip to content

Commit

Permalink
add inp coverage for LABELS
Browse files Browse the repository at this point in the history
  • Loading branch information
aerispaha committed Feb 11, 2025
1 parent b07e1dd commit 2dfbab9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions swmmio/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ def __init__(self, file_path):
self._inlet_usage_df = None
self._patterns_df = None
self._controls_df = None
self._labels_df = None

SWMMIOFile.__init__(self, file_path) # run the superclass init

Expand Down Expand Up @@ -687,6 +688,7 @@ def __init__(self, file_path):
'[INLET_USAGE]',
'[PATTERNS]',
'[CONTROLS]',
'[LABELS]',
]

def save(self, target_path=None):
Expand Down Expand Up @@ -1782,6 +1784,43 @@ def inlet_usage(self, df):
"""Set inp.inlet_usage DataFrame."""
self._inlet_usage_df = df

@property
def labels(self):
"""
Get/set labels section of the INP file.
Returns
-------
pandas.DataFrame
Examples
--------
Access the labels section of the inp file
>>> from swmmio.examples import streets
>>> streets.inp.labels #doctest: +NORMALIZE_WHITESPACE
Ycoord Label ... Size Bold
Xcoord ...
145.274 1129.896 S1 ... 0 0
758.404 969.723 S2 ... 0 0
247.369 666.226 S3 ... 0 0
628.971 458.688 S4 ... 0 0
952.552 257.845 S5 ... 0 0
827.947 56.930 S6 ... 0 0
1073.058 780.037 S7 ... 0 0
1385.481 454.225 Outfall ... 1 0
<BLANKLINE>
[8 rows x 6 columns]
"""
if self._labels_df is None:
self._labels_df = dataframe_from_inp(self.path, "[LABELS]")
return self._labels_df

@labels.setter
def labels(self, df):
"""Set inp.labels DataFrame."""
self._labels_df = df


def drop_invalid_model_elements(inp):
"""
Expand Down
1 change: 1 addition & 0 deletions swmmio/defs/inp_sections.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ inp_file_objects:
INLET_USAGE: [Link, Inlet, Node, Number, "%Clogged", Qmax, aLocal, wLocal, Placement]
PATTERNS: [Name, Type, Factors]
CONTROLS: [blob]
LABELS: [Xcoord, Ycoord, Label, Anchor, Font, Size, Bold, Italic]

inp_section_tags:
['[TITLE', '[OPTION', '[FILE', '[RAINGAGES', '[TEMPERATURE', '[EVAP',
Expand Down

0 comments on commit 2dfbab9

Please sign in to comment.