コード例 #1
0
ファイル: core.py プロジェクト: aerispaha/swmmio
    def weirs(self):
        """
        collect all useful and available data related model weirs and
        organize in one dataframe.
        """

        # check if this has been done already and return that data accordingly
        if self._weirs_df is not None:
            return self._weirs_df

        # parse out the main objects of this model
        inp = self.inp
        rpt = self.rpt

        # create dataframes of relevant sections from the INP
        weirs_df = create_dataframeINP(inp.path, "[WEIRS]")
        if weirs_df.empty:
            return pd.DataFrame()

        weirs_df = weirs_df[['InletNode', 'OutletNode', 'WeirType', 'CrestHeight']]

        # add conduit coordinates
        xys = weirs_df.apply(lambda r: get_link_coords(r, self.inp.coordinates, self.inp.vertices), axis=1)
        df = weirs_df.assign(coords=xys.map(lambda x: x[0]))
        df.InletNode = df.InletNode.astype(str)
        df.OutletNode = df.OutletNode.astype(str)

        self._weirs_df = df

        return df
コード例 #2
0
    def pumps_old_method(model):
        """
        collect all useful and available data related model pumps and
        organize in one dataframe.
        """

        # check if this has been done already and return that data accordingly
        if model._pumps_df is not None:
            return model._pumps_df

        # parse out the main objects of this model
        inp = model.inp

        # create dataframes of relevant sections from the INP
        pumps_df = dataframe_from_inp(inp.path, "[PUMPS]")
        if pumps_df.empty:
            return pd.DataFrame()

        # add conduit coordinates
        xys = pumps_df.apply(
            lambda r: get_link_coords(r, inp.coordinates, inp.vertices),
            axis=1)
        df = pumps_df.assign(coords=xys.map(lambda x: x[0]))
        df.InletNode = df.InletNode.astype(str)
        df.OutletNode = df.OutletNode.astype(str)

        model._pumps_df = df

        return df
コード例 #3
0
ファイル: elements.py プロジェクト: aerispaha/swmmio
    def __call__(self):

        """
        collect all useful and available data related to the conduits and
        organize in one dataframe.
        >>> model = swmmio.Model(MODEL_FULL_FEATURES__NET_PATH)
        >>> conduits_section = ModelSection(model, 'conduits')
        >>> conduits_section()
        """

        # create dataframes of relevant sections from the INP
        for ix, sect in enumerate(self.config['inp_sections']):
            if ix == 0:
                df = create_dataframeINP(self.inp.path, sect, comment_cols=False)
            else:
                df_other = create_dataframeINP(self.inp.path, sect, comment_cols=False)
                df = df.join(df_other)

        if self.rpt:
            for rpt_sect in self.config['rpt_sections']:
                df = df.join(create_dataframeRPT(self.rpt.path, rpt_sect))

        # add conduit coordinates
        xys = df.apply(lambda r: get_link_coords(r, self.inp.coordinates, self.inp.vertices), axis=1)
        df = df.assign(coords=xys.map(lambda x: x[0]))

        # make inlet/outlet node IDs string type
        df.InletNode = df.InletNode.astype(str)
        df.OutletNode = df.OutletNode.astype(str)

        return df
コード例 #4
0
ファイル: core.py プロジェクト: aerispaha/swmmio
    def orifices(self):
        """
        collect all useful and available data related model orifices and
        organize in one dataframe.
        """

        # check if this has been done already and return that data accordingly
        if self._orifices_df is not None:
            return self._orifices_df

        # parse out the main objects of this model
        inp = self.inp
        rpt = self.rpt

        # create dataframes of relevant sections from the INP
        orifices_df = create_dataframeINP(inp.path, "[ORIFICES]", comment_cols=False)
        if orifices_df.empty:
            return pd.DataFrame()

        # add conduit coordinates
        xys = orifices_df.apply(lambda r: get_link_coords(r, self.inp.coordinates, self.inp.vertices), axis=1)
        df = orifices_df.assign(coords=xys.map(lambda x: x[0]))
        df.InletNode = df.InletNode.astype(str)
        df.OutletNode = df.OutletNode.astype(str)
        self._orifices_df = df

        return df
コード例 #5
0
ファイル: core.py プロジェクト: waternk/swmmio
    def weirs(self):
        """
        collect all useful and available data related model weirs and
        organize in one dataframe.
        """

        # check if this has been done already and return that data accordingly
        if self._weirs_df is not None:
            return self._weirs_df

        # parse out the main objects of this model
        inp = self.inp
        rpt = self.rpt

        # create dataframes of relevant sections from the INP
        weirs_df = create_dataframeINP(inp.path, "[WEIRS]")
        if weirs_df.empty:
            return pd.DataFrame()

        weirs_df = weirs_df[[
            'InletNode', 'OutletNode', 'WeirType', 'CrestHeight'
        ]]

        # add conduit coordinates
        xys = weirs_df.apply(lambda r: get_link_coords(r, self.inp.coordinates,
                                                       self.inp.vertices),
                             axis=1)
        df = weirs_df.assign(coords=xys.map(lambda x: x[0]))
        df.InletNode = df.InletNode.astype(str)
        df.OutletNode = df.OutletNode.astype(str)

        self._weirs_df = df

        return df
コード例 #6
0
ファイル: core.py プロジェクト: waternk/swmmio
    def orifices(self):
        """
        collect all useful and available data related model orifices and
        organize in one dataframe.
        """

        # check if this has been done already and return that data accordingly
        if self._orifices_df is not None:
            return self._orifices_df

        # parse out the main objects of this model
        inp = self.inp
        rpt = self.rpt

        # create dataframes of relevant sections from the INP
        orifices_df = create_dataframeINP(inp.path,
                                          "[ORIFICES]",
                                          comment_cols=False)
        if orifices_df.empty:
            return pd.DataFrame()

        # add conduit coordinates
        xys = orifices_df.apply(lambda r: get_link_coords(
            r, self.inp.coordinates, self.inp.vertices),
                                axis=1)
        df = orifices_df.assign(coords=xys.map(lambda x: x[0]))
        df.InletNode = df.InletNode.astype(str)
        df.OutletNode = df.OutletNode.astype(str)
        self._orifices_df = df

        return df
コード例 #7
0
ファイル: elements.py プロジェクト: hitdongfeng/swmmio
    def __call__(self):

        """
        collect all useful and available data related to the conduits and
        organize in one dataframe.
        >>> model = swmmio.Model(MODEL_FULL_FEATURES__NET_PATH)
        >>> conduits_section = ModelSection(model, 'conduits')
        >>> conduits_section()
        """

        # create dataframes of relevant sections from the INP
        for ix, sect in enumerate(self.config['inp_sections']):
            if ix == 0:
                df = create_dataframeINP(self.inp.path, sect, comment_cols=False)
            else:
                df_other = create_dataframeINP(self.inp.path, sect, comment_cols=False)
                df = df.join(df_other)

        if df.empty:
            return df

        # if there is an RPT available, grab relevant sections
        if self.rpt:
            for rpt_sect in self.config['rpt_sections']:
                df = df.join(create_dataframeRPT(self.rpt.path, rpt_sect))

        # add conduit coordinates
        xys = df.apply(lambda r: get_link_coords(r, self.inp.coordinates, self.inp.vertices), axis=1)
        df = df.assign(coords=xys.map(lambda x: x[0]))

        # make inlet/outlet node IDs string type
        df.InletNode = df.InletNode.astype(str)
        df.OutletNode = df.OutletNode.astype(str)

        return df
コード例 #8
0
ファイル: core.py プロジェクト: waternk/swmmio
    def conduits(self):
        """
        collect all useful and available data related model conduits and
        organize in one dataframe.
        """

        # check if this has been done already and return that data accordingly
        if self._conduits_df is not None:
            return self._conduits_df

        # parse out the main objects of this model
        inp = self.inp
        rpt = self.rpt

        # create dataframes of relevant sections from the INP
        conduits_df = create_dataframeINP(inp.path,
                                          "[CONDUITS]",
                                          comment_cols=False)
        xsections_df = create_dataframeINP(inp.path,
                                           "[XSECTIONS]",
                                           comment_cols=False)
        conduits_df = conduits_df.join(xsections_df)

        if rpt:
            # create a dictionary holding data from an rpt file, if provided
            link_flow_df = create_dataframeRPT(rpt.path, "Link Flow Summary")
            conduits_df = conduits_df.join(link_flow_df)

        # add conduit coordinates
        xys = conduits_df.apply(lambda r: get_link_coords(
            r, self.inp.coordinates, self.inp.vertices),
                                axis=1)
        df = conduits_df.assign(coords=xys.map(lambda x: x[0]))

        # add conduit up/down inverts and calculate slope
        elevs = self.nodes()[['InvertElev']]
        df = pd.merge(df,
                      elevs,
                      left_on='InletNode',
                      right_index=True,
                      how='left')
        df = df.rename(index=str, columns={"InvertElev": "InletNodeInvert"})
        df = pd.merge(df,
                      elevs,
                      left_on='OutletNode',
                      right_index=True,
                      how='left')
        df = df.rename(index=str, columns={"InvertElev": "OutletNodeInvert"})
        df['UpstreamInvert'] = df.InletNodeInvert + df.InletOffset
        df['DownstreamInvert'] = df.OutletNodeInvert + df.OutletOffset
        df['SlopeFtPerFt'] = (df.UpstreamInvert -
                              df.DownstreamInvert) / df.Length

        df.InletNode = df.InletNode.astype(str)
        df.OutletNode = df.OutletNode.astype(str)

        self._conduits_df = df

        return df
コード例 #9
0
ファイル: core.py プロジェクト: aerispaha/swmmio
    def conduits(self):
        """
        collect all useful and available data related model conduits and
        organize in one dataframe.
        """

        # check if this has been done already and return that data accordingly
        if self._conduits_df is not None:
            return self._conduits_df

        # parse out the main objects of this model
        inp = self.inp
        rpt = self.rpt

        # create dataframes of relevant sections from the INP
        conduits_df = create_dataframeINP(inp.path, "[CONDUITS]", comment_cols=False)
        xsections_df = create_dataframeINP(inp.path, "[XSECTIONS]", comment_cols=False)
        conduits_df = conduits_df.join(xsections_df)

        if rpt:
            # create a dictionary holding data from an rpt file, if provided
            link_flow_df = create_dataframeRPT(rpt.path, "Link Flow Summary")
            conduits_df = conduits_df.join(link_flow_df)

        # add conduit coordinates
        xys = conduits_df.apply(lambda r: get_link_coords(r, self.inp.coordinates, self.inp.vertices), axis=1)
        df = conduits_df.assign(coords=xys.map(lambda x: x[0]))

        # add conduit up/down inverts and calculate slope
        elevs = self.nodes()[['InvertElev']]
        df = pd.merge(df, elevs, left_on='InletNode', right_index=True, how='left')
        df = df.rename(index=str, columns={"InvertElev": "InletNodeInvert"})
        df = pd.merge(df, elevs, left_on='OutletNode', right_index=True, how='left')
        df = df.rename(index=str, columns={"InvertElev": "OutletNodeInvert"})
        df['UpstreamInvert'] = df.InletNodeInvert + df.InletOffset
        df['DownstreamInvert'] = df.OutletNodeInvert + df.OutletOffset
        df['SlopeFtPerFt'] = (df.UpstreamInvert - df.DownstreamInvert) / df.Length

        df.InletNode = df.InletNode.astype(str)
        df.OutletNode = df.OutletNode.astype(str)

        self._conduits_df = df

        return df
コード例 #10
0
ファイル: elements.py プロジェクト: gitGovea/swmmio
    def __call__(self):
        """
        collect all useful and available data related to the conduits and
        organize in one dataframe.
        >>> model = swmmio.Model(MODEL_FULL_FEATURES__NET_PATH)
        >>> conduits_section = ModelSection(model, 'conduits')
        >>> conduits_section()
        """

        # concat inp sections with unique element IDs
        headers = get_inp_sections_details(self.inp.path)
        dfs = [
            dataframe_from_inp(self.inp.path, sect)
            for sect in self.inp_sections if sect.upper() in headers
        ]

        # return empty df if no inp sections found
        if len(dfs) == 0:
            return pd.DataFrame()

        df = pd.concat(dfs, axis=0, sort=False)

        # join to this any sections with matching IDs (e.g. XSECTIONS)
        for sect in self.join_sections:
            rsuffix = f"_{sect.replace(' ', '_')}"
            df = df.join(dataframe_from_inp(self.inp.path, sect),
                         rsuffix=rsuffix)

        if df.empty:
            return df

        # if there is an RPT available, grab relevant sections
        if self.rpt:
            for rpt_sect in self.rpt_sections:
                df = df.join(dataframe_from_rpt(self.rpt.path, rpt_sect))

        # add coordinates
        if self.geomtype == 'point':
            df = df.join(self.inp.coordinates[['X', 'Y']])
            xys = df.apply(lambda r: nodexy(r), axis=1)
            df = df.assign(coords=xys)

        elif self.geomtype == 'linestring':
            # add conduit coordinates
            xys = df.apply(lambda r: get_link_coords(r, self.inp.coordinates,
                                                     self.inp.vertices),
                           axis=1)
            df = df.assign(coords=xys.map(lambda x: x[0]))

            # make inlet/outlet node IDs string type
            df.InletNode = df.InletNode.astype(str)
            df.OutletNode = df.OutletNode.astype(str)

        elif self.geomtype == 'polygon':
            p = self.inp.polygons

            # take stacked coordinates and orient in list of tuples,
            xys = p.groupby(by=p.index).apply(
                lambda r: [(xy['X'], xy['Y']) for ix, xy in r.iterrows()])
            # copy the first point to the last position
            xys = xys.apply(lambda r: r + [r[0]])
            df = df.assign(coords=xys)

        # confirm index name is string
        df = df.rename(index=str)

        # trim to desired columns
        if self.columns is not None:
            df = df[[c for c in self.columns if c in df.columns]]

        self._df = df
        return df