Beispiel #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
Beispiel #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)
Beispiel #3
0
def find_avulsion(dx, dy, imax, jmax, riv_x, riv_y, n, super_ratio, current_SL,
                  ch_depth, short_path, dn_fp, splay_type, splay_dep):

    loc = []
    SEL = np.zeros(len(riv_x))
    SER = np.zeros(len(riv_x))
    avulsion_type = 0
    length_new_sum = 0    
    length_old = 0

    for a in range(1, len(riv_x)):

        ch_Z = n[riv_x[a]/dx][riv_y[a]/dy] + ch_depth   # bankfull elev.
        LHS = n[riv_x[a]/dx][(riv_y[a]/dy)-1]
        RHS = n[riv_x[a]/dx][(riv_y[a]/dy)+1]

        # normalized superelevation ratio on left side
        SEL[a] = ((ch_Z - LHS) / ch_depth)

        # normalized superelevation ratio on right side
        SER[a] = ((ch_Z - RHS) / ch_depth)

        if SEL[a] >= super_ratio or SER[a] >= super_ratio:

            # if superelevation greater than trigger ratio, determine
            # length of new steepest descent path
            new_riv_x = riv_x[:a-1]
            new_riv_y = riv_y[:a-1]

            new_riv_x, new_riv_y = steep_desc.find_new_course(
                dx, dy, imax, jmax, n, new_riv_x, new_riv_y, 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:
                
                # duplicates arrays so that length can be compared below
                test_new_x = new_riv_x[a:]
                test_new_y = new_riv_y[a:]
                test_old_x = riv_x[a:]
                test_old_y = riv_y[a:]
                length_new = []
                
                for c in range(len(test_new_x)-1):
                    
                    if (((test_new_x[c+1]/dx) - (test_new_x[c]/dx) == 0) and
                        (test_new_y[c+1]/dy) - (test_new_y[c]/dy) == -1):
                            
                            length_new.append(1)
                    
                    elif (((test_new_x[c+1]/dx) - (test_new_x[c]/dx) == 0)
                        and (test_new_y[c+1]/dy) - (test_new_y[c]/dy) == 1):
                    
                            length_new.append(1)
                            
                    elif (((test_new_x[c+1]/dx) - (test_new_x[c]/dx) == 1)
                        and (test_new_y[c+1]/dy) - (test_new_y[c]/dy) == 0):

                            length_new.append(1)
                    
                    elif (((test_new_x[c+1]/dx) - (test_new_x[c]/dx) == 1)
                        and (test_new_y[c+1]/dy) - (test_new_y[c]/dy) == -1):
                            
                            length_new.append(math.sqrt(2))

                    elif (((test_new_x[c+1]/dx) - (test_new_x[c]/dx) == 1)
                        and (test_new_y[c+1]/dy) - (test_new_y[c]/dy) == 1):
                            
                            length_new.append(math.sqrt(2))
                    
                    c += 1
                
                for b in range(len(test_old_x)-1):
                    
                    if (((test_old_x[b+1]/dx) - (test_old_x[b]/dx) == 0) and
                        (test_old_y[b+1]/dy) - (test_old_y[b]/dy) == -1):
                            
                            length_old += 1
                    
                    elif (((test_old_x[b+1]/dx) - (test_old_x[b]/dx) == 0)
                        and (test_old_y[b+1]/dy) - (test_old_y[b]/dy) == 1):
                    
                            length_old += 1
                            
                    elif (((test_old_x[b+1]/dx) - (test_old_x[b]/dx) == 1)
                        and (test_old_y[b+1]/dy) - (test_old_y[b]/dy) == 0):

                            length_old += 1
                    
                    elif (((test_old_x[b+1]/dx) - (test_old_x[b]/dx) == 1)
                        and (test_old_y[b+1]/dy) - (test_old_y[b]/dy) == -1):
                            
                            length_old += math.sqrt(2)

                    elif (((test_old_x[b+1]/dx) - (test_old_x[b]/dx) == 1)
                        and (test_old_y[b+1]/dy) - (test_old_y[b]/dy) == 1):
                            
                            length_old += math.sqrt(2)
                    
                    b += 1

                # if new river course < length of old
                # river course, then an avulsion will occur
                length_new_sum = sum(length_new)
                if sum(length_new) < length_old:
                    
                    loc = [a]         # avulsion location
                    avulsion_type = 1 # sets avulsion to be regional, may be 
                                        # updated again below (if local)
                
                    # maybe this should be len(test_old_x)-1?
                    for d in range(1,len(test_old_x)):
                        
                        x_diff = new_riv_x[-1] - riv_x[a+d]
                        y_diff = new_riv_y[-1] - riv_y[a+d]
                        
                        if x_diff == 0 and y_diff == 0:
                            
                            avulsion_type = 2   # local avulsion
                            
                            riv_x = new_riv_x + riv_x[a+d+1:]
                            riv_y = new_riv_y + riv_y[a+d+1:]
                            """
                            above doesn't change river mouth location unless it's
                            a regional avulsion
                            """ 

                            break
                        
                        else: d += 1
                    
                    if avulsion_type == 1: 
                    
                        riv_x = new_riv_x
                        riv_y = new_riv_y

                        n = downcut.cut_new(dx, dy, riv_x, riv_y, n, length_new,
                                        current_SL, a, ch_depth)

                    return (riv_x, riv_y, loc, SEL, SER, n, dn_fp, avulsion_type,
                            length_new_sum, length_old
                            )

                else:

                    if splay_type > 0:
                        n, dn_fp = FP.dep_splay(dy, dx, imax, jmax,
                                   riv_x, riv_y, new_riv_x, new_riv_y,
                                   ch_depth, n, a, dn_fp, splay_type,
                                   splay_dep)

            # 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
            if short_path == 0:

                riv_x = new_riv_x
                riv_y = new_riv_y
                loc = [a]
        a += 1

    return (riv_x, riv_y, loc, SEL, SER, n, dn_fp, avulsion_type, length_new_sum,
            length_old)