Пример #1
0
    def load_data(self):
        self.input_file = self.get_input()

        if self.input_file is None:
            print "No input file selected. Exiting..."
            import sys
            sys.exit(0)

        self.nc = NC(self.input_file)
        nc = self.nc

        self.x = np.array(nc.variables['x'][:], dtype=np.double)
        self.y = np.array(nc.variables['y'][:], dtype=np.double)
        self.z = np.array(np.squeeze(nc.variables['usurf'][:]), dtype=np.double)
        self.thk = np.array(np.squeeze(nc.variables['thk'][:]), dtype=np.double)

        self.mask = dbg.initialize_mask(self.thk)
        print "Mask initialization: done"

        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
    def get_terminus(self):
        from matplotlib.widgets import Cursor

        if self.mask_computed == True:
            self.mask = dbg.initialize_mask(self.thk)

            plt.clf()
            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.draw()

        plt.setp(plt.gca(),autoscale_on=False)

        cursor = Cursor(plt.axes(), useblit=True, color='white', linewidth=1 )

        if self.ph is not None and self.mask_computed == False:
            for p in self.ph:
                p.remove()
            self.ph = None

        pts = []
        while len(pts) < 4:
            pts = np.asarray( plt.ginput(4, timeout=-1) )

        self.ph = plt.fill(pts[:,0], pts[:,1], 'white', lw = 2, alpha=0.5)
        plt.draw()

        self.pts = pts

        self.mask_computed = False
Пример #3
0
        # Get rid of fill
        if not happy:
            for p in ph: p.remove()

        return pts

# read the DEM data
nc = NC(sys.argv[1])
x = np.array(nc.variables['x'][:], dtype=np.double)
y = np.array(nc.variables['y'][:], dtype=np.double)
thk = np.array(np.squeeze(nc.variables['thk'][:]), dtype=np.double)
z = np.array(np.squeeze(nc.variables['usurf'][:]), dtype=np.double)

# initialize the mask
mask = dbg.initialize_mask(thk)
print "Mask initialization: done"

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

pts = get_terminus()

import matplotlib.nxutils as nx

def correct_mask(pts):
        for j in range(y.size):
            for i in range(x.size):