示例#1
0
    def compute_mask(self):
        import matplotlib.nxutils as nx

        if self.pts is not None:
            def correct_mask(mask, x, y, pts):
                    for j in range(y.size):
                        for i in range(x.size):
                            if mask[j,i] > 0:
                                if nx.pnpoly(x[i], y[j], pts):
                                    mask[j,i] = 2
                                else:
                                    mask[j,i] = 1

            correct_mask(self.mask, self.x, self.y, self.pts)

        dbg.upslope_area(self.x, self.y, self.z, self.mask)
        print "Drainage basin computation: done"
        self.mask_computed = True

        plt.figure(1)
        plt.pcolormesh(self.x, self.y, self.mask)
        plt.contour(self.x, self.y, self.z, colors='black')
        plt.axis('tight')
        plt.axes().set_aspect('equal')
        plt.show()
示例#2
0
pts = get_terminus()

import matplotlib.nxutils as nx

def correct_mask(pts):
        for j in range(y.size):
            for i in range(x.size):
                if mask[j,i] > 0:
                    if nx.pnpoly(x[i], y[j], pts):
                        mask[j,i] = 2
                    else:
                        mask[j,i] = 1

correct_mask(pts)

dbg.upslope_area(x, y, z, mask)
print "Drainage basin computation: done"

plt.figure(1)
plt.pcolormesh(x, y, mask)
plt.contour(x, y, z, colors='black')
plt.axis('tight')
plt.axes().set_aspect('equal')
plt.title("upslope areas")

# mask2 = np.zeros(thk.shape, dtype=np.float64) - 1
# mask2[thk > 5] = 0
# mask2[mask != 2] = -1

# dbg.accumulated_flow(x, y, z, mask2, n_samples = 4)