From 2dfbab9aa0c3705d5f7db2a0478a8d2e72de490e Mon Sep 17 00:00:00 2001 From: Adam Erispaha Date: Mon, 10 Feb 2025 21:32:25 -0500 Subject: [PATCH] add inp coverage for LABELS --- swmmio/core.py | 39 ++++++++++++++++++++++++++++++++++++ swmmio/defs/inp_sections.yml | 1 + 2 files changed, 40 insertions(+) diff --git a/swmmio/core.py b/swmmio/core.py index 2468e52..c8ae9eb 100644 --- a/swmmio/core.py +++ b/swmmio/core.py @@ -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 @@ -687,6 +688,7 @@ def __init__(self, file_path): '[INLET_USAGE]', '[PATTERNS]', '[CONTROLS]', + '[LABELS]', ] def save(self, target_path=None): @@ -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 + + [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): """ diff --git a/swmmio/defs/inp_sections.yml b/swmmio/defs/inp_sections.yml index 715c0a7..2e5b6cc 100644 --- a/swmmio/defs/inp_sections.yml +++ b/swmmio/defs/inp_sections.yml @@ -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',