Exemple #1
0
    def __init__(self, network, updated_qs_table):
        """

        :param network:
        :param updated_qs_table:
        """

        self.streams = network
        self.network = gpd.read_file(self.streams)
        table = pd.read_csv(updated_qs_table, sep=',', header=0)
        table = table.dropna(axis='columns')

        # add da values to table and then sort by da so disturbance is accounted for from upstream to downstream
        da_values = []
        for x in table.index:
            da = self.network.loc[table.loc[x, 'Segment ID'], 'Drain_Area']
            da_values.append(da)

        table['DA'] = da_values
        sortedtable = table.sort_values(by='DA')
        self.sortedtable = sortedtable.reset_index(drop=True)
        self.segids = self.sortedtable['Segment ID']
        self.values = self.sortedtable['newQs']

        self.topo = nt.TopologyTools(network)

        self.network['newQs'] = -9999
        self.network['eff_DA'] = -9999
Exemple #2
0
    def __init__(self, network, qs_table):
        """

        :param network: string - path to stream network shapefile with topology attributes
        :param qs_table: string - path to csv with headers 'Segment ID': segment ID for downstream reach that bounds a
        specific value for average annual sediment yield 'Qs': the associated value of sediment yield that applies
        to segments upstream of associated segment ID (tonnes/km2/yr).
        """

        self.streams = network
        self.network = gpd.read_file(network)

        table = pd.read_csv(qs_table, sep=',', header=0)
        table = table.dropna(axis='columns')

        # add da values to table and then sort by da so Qs is attributed from top of network down
        da_values = []
        for x in table.index:
            da = self.network.loc[table.loc[x, 'Segment ID'], 'Drain_Area']
            da_values.append(da)

        table['DA'] = da_values
        sortedtable = table.sort_values(by='DA')
        self.sortedtable = sortedtable.reset_index(drop=True)
        self.segids = self.sortedtable['Segment ID']
        self.values = self.sortedtable['Qs']

        self.topo = nt.TopologyTools(self.streams)

        self.qs_to_network()
Exemple #3
0
    def __init__(
        self,
        hydrograph,
        flow_exp,
        network,
        mannings_n=0.4,
        tl_factor=15
    ):  # should probably make mannnings n and total load factor parameters
        """

        :param hydrograph: table with fields 'Gage', 'segid', 'Easting', 'Northing', 'DA', and 'Day1' ..... 'DayN'
        :param denude_rate:
        :param network:
        """

        self.hydrographs = pd.read_csv(hydrograph, index_col='Gage')
        self.flow_exp = flow_exp  # need the b in the equation for flow~DA so that you can recalculate a at each time step
        self.network = gpd.read_file(network)
        self.mannings_n = mannings_n
        self.tl_factor = tl_factor

        self.nt = nt.TopologyTools(network)

        # subset of hydrographs above dams
        segs_ab_dams = []
        for x in self.hydrographs.index:
            print x
            if self.network.loc[self.hydrographs.loc[x, 'segid'],
                                'Drain_Area'] == self.network.loc[
                                    self.hydrographs.loc[x,
                                                         'segid'], 'eff_DA']:
                segs_ab_dams.append(self.hydrographs.loc[x, 'segid'])

        self.hyd_ab_dams = self.hydrographs[self.hydrographs['segid'].isin(
            segs_ab_dams)]

        # obtain number of time steps for output table
        time = np.arange(1, self.hydrographs.shape[1] - 3, 1, dtype=np.int)

        # build multi-index dataframe for storing data/outputs
        self.network = gpd.read_file(network)
        segments = np.arange(0, len(self.network.index + 1), 1)

        ydim = len(time) * len(segments)
        zeros = np.zeros((ydim, 8))  # where cols is number of attributes

        iterables = [time, segments]
        index = pd.MultiIndex.from_product(iterables,
                                           names=['time', 'segment'])

        self.outdf = pd.DataFrame(zeros,
                                  index=index,
                                  columns=[
                                      'Q', 'Qs', 'Qs_out', 'CSR', 'Store_chan',
                                      'Store_tot', 'Store_delta', 'S*'
                                  ])  # add the names of attributes
Exemple #4
0
    def __init__(self, network, updated_Q2_table, a=None, b=None):
        """
        :param network: stream network shapefile
        :param updated_Q2_table: csv file with stream segment id and new, post-disturbance Q2 value
        """

        self.streams = network
        self.a = a
        self.b = b
        self.network = gpd.read_file(self.streams)
        table = pd.read_csv(updated_Q2_table, sep=',', header=0)
        table = table.dropna(axis=0)
        self.segid = table['Segment ID']
        self.newQ2 = table['Updated Q2 (cms)']

        self.topo = nt.TopologyTools(network)
Exemple #5
0
    def __init__(self, network):
        """
        :param network: drainage network shapefile
        """

        self.streams = network
        self.network = gpd.read_file(network)

        self.topo = nt.TopologyTools(network)

        # add an 'effective drainage area' field, default to actual DA
        if 'eff_DA' in self.network.columns:
            pass
        else:
            for i in self.network.index:
                self.network.loc[i, 'eff_DA'] = self.network.loc[i, 'Drain_Area']

        # add a denudation rate field, default to 0
        if 'denude' in self.network.columns:
            pass
        else:
            for i in self.network.index:
                self.network.loc[i, 'denude'] = -9999