示例#1
0
    def test_fill_01(self):
        arr = np.array([[49, 36, 29, 29], [32, 19, 17, 20], [19, 18, 31, 39],
                        [19, 29, 42, 51]])
        dem = DEM()
        dem.set_array(arr)
        fill = dem.fill_sinks()
        computed = fill.read_array().tolist()
        arr = np.array([[49, 36, 29, 29], [32, 19, 19, 20], [19, 19, 31, 39],
                        [19, 29, 42, 51]])
        expected = arr.tolist()

        self.assertEqual(computed, expected)
示例#2
0
    def test_fill_03(self):
        arr = np.array([[49, 36, 29, 29], [32, 17, 12, 20], [19, 17, 19, 39],
                        [19, 29, 42, -99]])
        dem = DEM()
        dem.set_nodata(-99)
        dem.set_array(arr)
        fill = dem.fill_sinks()
        computed = fill.read_array(False).tolist()
        arr = np.array([[49, 36, 29, 29], [32, 19, 19, 20], [19, 19, 19, 39],
                        [19, 29, 42, -99]])

        expected = arr.tolist()

        self.assertEqual(computed, expected)
示例#3
0
del IX

# Get the steepest one
I = (G1 <= G2) & (xxx2.ravel()[ix] > xxx1.ravel()[ix])
ixc = IXC1
ixc[I] = IXC2[I]
I = ixc == ix
I = np.invert(I)
ix = ix[I]
ixc = ixc[I]
print("Receivers pixels identified -- {0:.3f} seconds".format(time.time() -
                                                              time_lap))

# 08 Calculate flow accumulation
time_lap = time.time()
nix = len(ix)

A = np.ones(ncells)
for n in range(nix):
    A[ixc[n]] = A[ix[n]] + A[ixc[n]]

A = A.reshape(dims)

acc = DEM()
acc.copy_layout(dem)
acc.set_array(A)
print("Flow accumulation calculated -- {0:.3f} seconds".format(time.time() -
                                                               time_lap))

acc.save("flow_Arr3.tif")
示例#4
0
import sys
sys.path.append("../../")
from topopy import Flow, Grid, DEM
import numpy as np
from scipy.sparse import csc_matrix
import matplotlib.pyplot as plt


arr = np.array([[49, 50, 50, 50],
                [49, 47, 47, 46],
                [49, 48, 45, 45],
                [49, 47, 46, 43],
                [46, 47, 47, 47]], dtype=np.int16)

dem = DEM()
dem.set_array(arr)
flow = Flow(dem)

ixcix = np.zeros(flow._ncells, np.int)
ixcix[flow._ix] = np.arange(len(flow._ix))

new_ind = 0
channel_points = [new_ind]
while ixcix[new_ind] != 0:
    new_ind = flow._ixc[ixcix[new_ind]]
    channel_points.append(new_ind)

print(flow._ix)
print(flow._ixc)
print(ixcix)
print(channel_points)