示例#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
示例#2
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)