Exemplo n.º 1
0
def find_avulsion(riv_i, riv_j, n, super_ratio, current_SL, ch_depth,
                  short_path, splay_type, splay_dep, dx=1., dy=1.):
    new = riv_i, riv_j
    old = riv_i, riv_j
    avulsion_type = 0

    for a in xrange(1, len(riv_i)):
        if channel_is_superelevated(n, (riv_i[a], riv_j[a]), ch_depth,
                                    super_ratio):

            # if superelevation greater than trigger ratio, determine
            # length of new steepest descent path

            new = steep_desc.find_course(n, riv_i[:a], riv_j[:a],
                                         sea_level=current_SL)

            # if using the shortest path as an avulsion criterion, then
            # the lengths of the previous and newly calculated paths will
            # be compared
            if short_path == 1:
                new_length = find_path_length(new, dx=dx, dy=dy)
                old_length = find_path_length(old, dx=dx, dy=dy)

                if new_length < old_length:
                    # if new river course < length of old
                    # river course, then an avulsion will occur
                    avulsion_type = 1

                    new, avulsion_type = avulse_to_new_path(n,
                                             (riv_i[a - 1:], riv_j[a - 1:]),
                                             (new[0][a - 1:], new[1][a - 1:]),
                                             current_SL, ch_depth, avulsion_type,
                                             dx=dx, dy=dy)

                    new = (np.append(riv_i[:a - 1], new[0]),
                           np.append(riv_j[:a - 1], new[1]))

                    break

                elif splay_type > 0:
                    avulsion_type = 3
                    FP.dep_splay(n, (new[0][a], new[1][a]), (riv_i, riv_j),
                                 splay_dep, splay_type=splay_type)
            # if shortest path is not an avulsion criterion, then the new
            # steepest descent path will become the new course regardless
            # of new course length relative to the old course

    return new, avulsion_type, a
Exemplo n.º 2
0
    def _init_from_dict(self, params):
        # seed random number generator
        np.random.seed(params['rand_seed'])

        # Spatial parameters
        self._dy = params['spacing'][0] * 1000.
        self._dx = params['spacing'][1] * 1000.

        n_rows = int(params['shape'][0])
        n_cols = int(params['shape'][1])

        # Initialize elevation grid
        # transverse and longitudinal space
        self._x, self._y = np.meshgrid(np.arange(n_cols) * self._dx,
                                       np.arange(n_rows) * self._dy)
        # eta, elevation
        n0 = params['n0']
        self._slope = params['nslope']
        self._max_rand = params['max_rand'] * params['nslope']
        self._n = n0 - (self._slope * self._y +
                        np.random.rand(n_rows, n_cols) * self._max_rand)
        self._n -= 0.05

        # self._dn_rc = np.zeros((self._imax))       # change in elevation along river course
        # self._dn_fp = np.zeros_like(self._n)     # change in elevation due to floodplain dep

        self._riv_i = np.zeros(1, dtype=np.int) # defines first x river locations
        self._riv_j = np.zeros(1, dtype=np.int) # defines first y river locations
        self._riv_j[0] = self._n.shape[1] / 2

        # Time parameters
        self._dt = params['dt_day'] * _SECONDS_PER_DAY # convert timestep to seconds
        self._time = 0.

        # Sea level and subsidence parameters
        self._SL = params['Initial_SL'] # starting sea level
        self._SLRR = params['SLRR_m'] / _SECONDS_PER_YEAR * self._dt # sea level rise rate in m (per timestep)
        self._SubRate = params['SubRate_m'] / _SECONDS_PER_YEAR * self._dt # subsidence rate in m (per timestep)
        self._SubStart = params['Sub_Start'] # row where subsidence begins

        # River parameters
        self._nu = ((8. * (params['ch_discharge'] / params['ch_width']) * params['A']
                    * np.sqrt(params['c_f'])) / (params['C_0'] * (params['sed_sg'] - 1)))
        ### NEED TO REDO DIFFUSE.PY TO HAVE SIGN OF NU CORRECT (NEG) ABOVE ###
        init_cut = params['init_cut_frac'] * params['ch_depth']
        self._super_ratio = params['super_ratio']
        self._short_path = params['short_path']
        self._ch_depth = params['ch_depth']

        # Floodplain and wetland characteristics
        self._WL_Z = params['WL_Z']
        self._WL_dist = params['WL_dist']
        self._blanket_rate = (params['blanket_rate_m'] / _SECONDS_PER_YEAR) * self._dt    # blanket deposition in m
        self._splay_type = params['splay_type']
        self._frac_fines = params['fine_dep_frac']

        self._sed_flux = 0.
        self._splay_deposit = np.zeros_like(self._n)

        # Saving information
        self._saveavulsions = params['saveavulsions']
        self._saveupdates = params['savecourseupdates']

        self._riv_i, self._riv_j = steep_desc.find_course(self._n, self._riv_i, self._riv_j,
                                                          len(self._riv_i), self._ch_depth,
                                                          sea_level=self._SL)

        # downcut into new river course by amount determined by init_cut
        downcut.cut_init(self._riv_i, self._riv_j, self._n, init_cut)

        # smooth initial river course elevations using linear diffusion equation
        diffuse.smooth_rc(self._dx, self._dy, self._nu, self._dt, self._ch_depth,
                          self._riv_i, self._riv_j, self._n, self._SL, self._slope)

        # initial profile
        self._profile = self._n[self._riv_i, self._riv_j]
Exemplo n.º 3
0
# Initial elevation grid
# this part sets up the grid for stand-alone module, won't be needed after
# module is coupled to sedfux (grid would be imported instead)
for i in range(imax):
    for j in range(jmax):
        x[i][j] = i * dx
        y[i][j] = j * dy
        if Linear == 1:
            n[i][j] = n0 - (nslope * float(x[i][j]) + max_rand*random())
        elif Concave == 1:
            n[i][j] = n0 - (drop * np.sqrt(x[i][j]) + max_rand*random())
        j += 1
    i += 1

# Determine initial river course
riv_x, riv_y = steep_desc.find_course(dx, dy, imax, jmax, n, riv_x, riv_y)

# downcut into new river course by amount determined by init_cut
n = downcut.cut_init(dx, dy, riv_x, riv_y, n, init_cut, Initial_SL)

# smooth initial river course elevations using linear diffusion equation
n, dn_rc = diffuse.smooth_rc(dx, dy, nu, dt, riv_x, riv_y, n, nslope)

# Determine initial river profile
profile = prof.make_profile(dx, dy, n, riv_x, riv_y, profile)

# make directories and save initial condition files
if savefiles == 1:
    # os.mkdir("run" + str(run_num) + "_out")
    os.mkdir("elev_grid")
    os.mkdir("riv_course")
Exemplo n.º 4
0
def find_avulsion(riv_i, riv_j, n, super_ratio, current_SL, ch_depth,
                  short_path, splay_type, slope, splay_depth, 
                  nu, dt, dx=1., dy=1.):
    new = riv_i, riv_j
    old = riv_i, riv_j
    avulsion_type = 0
    a = 0
    loc = 0
    avulse_length = 0
    new_length = 0
    new_course_length = 0
    avul_locs = np.zeros(0, dtype=np.int)
    path_slopes = np.zeros(0)
    crevasse_locs = np.zeros(3, dtype=np.int)
    path_diff = np.zeros(0)
    path_difference = 0

    old_length = find_riv_path_length(n, old, current_SL, ch_depth,
                                      slope, dx=dx, dy=dy)

    for a in xrange(1, len(riv_i)-1):
        if channel_is_superelevated(n, (riv_i[a], riv_j[a]),
                                    (riv_i[a-1], riv_j[a-1]),
                                    ch_depth, super_ratio, current_SL):

            # if superelevation greater than trigger ratio, determine
            # new steepest descent path
            new = steep_desc.find_course(n, riv_i, riv_j, a, ch_depth,
                                         sea_level=current_SL)

            if n[new[0][-1], new[1][-1]] < current_SL:
                new_length = find_riv_path_length(n, new, current_SL, ch_depth,
                                                  slope, dx=dx, dy=dy)
            else:
                new_length = find_path_length(n, new, current_SL, ch_depth,
                                              slope, dx=dx, dy=dy)

            if new_length < old_length:
                # calculate slope of new path

                if len(new[0][a:]) <= 1:
                    avulsed_length = find_path_length(n, (new[0][a-1:], new[1][a-1:]),
                                                      current_SL, ch_depth, slope,
                                                      dx=dx, dy=dy)
                    slope_new_path = ((n[new[0][-2], new[1][-2]] - n[new[0][-1], new[1][-1]])
                                  / avulsed_length)

                elif n[new[0][-1], new[1][-1]] < current_SL:
                    avulsed_length = find_riv_path_length(n, (new[0][a:], new[1][a:]),
                                                      current_SL, ch_depth,
                                                      slope, dx=dx, dy=dy)
                    slope_new_path = ((n[new[0][a], new[1][a]] - n[new[0][-1], new[1][-1]])
                                      / avulsed_length)

                else:
                    avulsed_length = find_path_length(n, (new[0][a:], new[1][a:]),
                                                      current_SL, ch_depth, slope,
                                                      dx=dx, dy=dy)
                    slope_new_path = ((n[new[0][a], new[1][a]] - n[new[0][-1], new[1][-1]])
                                      / avulsed_length)

                avul_locs = np.append(avul_locs, a)
                path_slopes = np.append(path_slopes, slope_new_path)
                path_diff = np.append(path_diff, (old_length - new_length))

            crevasse_locs = np.vstack((crevasse_locs, [new[0][a], new[1][a], a]))


    if (crevasse_locs.sum() > 0):
        crevasse_locs = np.delete(crevasse_locs, 0, 0)

    if avul_locs.size > 0:

        max_slope = np.argmax(path_slopes)
        loc = avul_locs[max_slope]
        path_difference = path_diff[max_slope]

        new = steep_desc.find_course(n, riv_i, riv_j, loc, ch_depth,
                                     sea_level=current_SL)

        avulsion_type = 1

        new, avulsion_type = avulse_to_new_path(n,
                                 (riv_i[loc - 1:], riv_j[loc - 1:]),
                                 (new[0][loc - 1:], new[1][loc - 1:]),
                                 current_SL, ch_depth, avulsion_type,
                                 slope, dx=dx, dy=dy)

        new = (np.append(riv_i[:loc - 1], new[0]),
               np.append(riv_j[:loc - 1], new[1]))

        avulse_length = find_riv_path_length(n, (riv_i[loc:], riv_j[loc:]),
                                             current_SL, ch_depth,
                                             slope, dx=dx, dy=dy)

        # fill up old channel... could be some fraction in the future
        # (determines whether channels are repellors or attractors)
        fill_abandoned_channel(loc, n, new, riv_i, riv_j, current_SL,
                               ch_depth, slope, dx)

        crevasse_locs = np.delete(crevasse_locs, max_slope, 0)

    else:
        new = riv_i, riv_j

    if (crevasse_locs.sum() > 0) and (splay_type > 0):

        n_before_splay = np.copy(n)

        # Don' think we need to worry about preserving old river elevations??
        # old_river_elevations = n[riv_i, riv_j]
        new_river_elevations = n[new[0], new[1]]

        for i in xrange(crevasse_locs.shape[0]):

            splay_dep = calc_crevasse_dep(dx, dy, nu, dt, ch_depth, riv_i, riv_j, n,
                                          current_SL, slope, crevasse_locs[i][2])

            if splay_dep > 0:
                FP.dep_splay(n, (crevasse_locs[i][0], crevasse_locs[i][1]),
                             splay_dep, splay_type=splay_type)

        # n[riv_i, riv_j] = old_river_elevations
        n[new[0], new[1]] = new_river_elevations
        n_splay = n - n_before_splay
        splay_depth += n_splay

    return (new, avulsion_type, loc, avulse_length, path_difference, splay_depth)