def slope(ix, iy, nextxy, uparea, elevtn, nxtdst, rivseq): nextX = nextxy[0] nextY = nextxy[1] slp1 = 0.0 slp2 = 0.0 if rivseq[iy, ix] > 1 and nextX[iy, ix] > 0: uXX, uYY = upstream(ix + 1, iy + 1, nextX.T, nextY.T, uparea.T) uXX = uXX - 1 uYY = uYY - 1 slp1 = (elevtn[uYY, uXX] - elevtn[iy, ix]) dXX = nextX[iy, ix] - 1 dYY = nextY[iy, ix] - 1 slp2 = (elevtn[iy, ix] - elevtn[dYY, dXX]) elif rivseq[iy, ix] == 1: slp1 = 0.0 dXX = nextX[iy, ix] - 1 dYY = nextY[iy, ix] - 1 slp2 = (elevtn[iy, ix] - elevtn[dYY, dXX]) elif nextX[iy, ix] <= 0: uXX, uYY = upstream(ix + 1, iy + 1, nextX.T, nextY.T, uparea.T) uXX = uXX - 1 uYY = uYY - 1 slp1 = (elevtn[uYY, uXX] - elevtn[iy, ix]) slp2 = 0.0 return slp1, slp2
def slope(ix, iy, nextxy, uparea, elevtn, rivlen, rivseq): if rivseq[iy, ix] > 1: nextX = nextxy[0] nextY = nextxy[1] uXX, uYY = upstream(ix + 1, iy + 1, nextX.T, nextY.T, uparea.T) uXX = uXX - 1 uYY = uYY - 1 slp = abs(elevtn[uYY, uXX] - elevtn[iy, ix]) / (rivlen[iy, ix] * 1e-6) else: slp = 0 return slp
coll_wse = np.zeros((nbdays, len(coll_lat), 2), 'f') coll_wse_max = np.zeros((nbyears, len(coll_lat), 2), 'f') coll_wse_min = np.zeros((nbyears, len(coll_lat), 2), 'f') # get the upstream pixels pnum = len(coll_name) uxlist = [] uylist = [] for point in np.arange(pnum): iix = coll_xx[point] iiy = coll_yy[point] if rivseq[iiy, iix] == 1: uxlist.append(iix) uylist.append(iiy) else: uXX, uYY = upstream(iix + 1, iiy + 1, nextX.T, nextY.T, uparea.T) uxlist.append(uXX) uylist.append(uYY) dxlist = [] dylist = [] for point in np.arange(pnum): iix = coll_xx[point] iiy = coll_yy[point] if nextX[iiy, iix] == -9 or nextX[iiy, iix] == -10: dxlist.append(iix) dylist.append(iiy) elif nextX[iiy, iix] == -9999: dxlist.append(iix) dylist.append(iiy) else: