Exemple #1
0
    def setup(self):
        self.known_filename = 'pygridtools/tests/baseline_files/testgrid.out'
        self.result_filename = 'pygridtools/tests/result_files/testgrid.out'

        self.x, self.y = testing.makeSimpleNodes()
 def test_plotCells_smoke(self):
     x, y = pgtest.makeSimpleNodes()
     fig1 = viz.plotCells(x, y)
def test__plot_cells():
    x, y = pgtest.makeSimpleNodes()
    fig1 = _viz_mpl._plot_cells(x, y)
def test_ModelGrid_plots():
    xn, yn = testing.makeSimpleNodes()
    mg = core.ModelGrid(xn, yn)
    mg.cell_mask = np.ma.masked_invalid(mg.xc).mask

    fig1 = mg.plotCells()
    def setup(self):
        self.xn, self.yn = testing.makeSimpleNodes()
        self.xc, self.yc = testing.makeSimpleCells()
        self.mg = core.ModelGrid(self.xn, self.yn)
        self.g1 = core.ModelGrid(self.xn[:, :3], self.yn[:, :3])
        self.g2 = core.ModelGrid(self.xn[2:5, 3:], self.yn[2:5, 3:])
        self.polyverts = [
            (2.4, 0.9),
            (3.6, 0.9),
            (3.6, 2.4),
            (2.4, 2.4),
        ]

        self.template = 'pygridtools/tests/test_data/schema_template.shp'
        self.g1.template = self.template
        self.g2.template = self.template

        self.known_rows = 9
        self.known_cols = 3
        self.known_df = pandas.DataFrame({
            ('easting', 0): {
                0: 1.0, 1: 1.0, 2: 1.0, 3: 1.0, 4: 1.0,
                5: 1.0, 6: 1.0, 7: 1.0, 8: 1.0
            }, ('easting', 1): {
                0: 1.5, 1: 1.5, 2: 1.5, 3: 1.5, 4: 1.5,
                5: 1.5, 6: 1.5, 7: 1.5, 8: 1.5
            }, ('easting', 2): {
                0: 2.0, 1: 2.0, 2: 2.0, 3: 2.0, 4: 2.0,
                5: 2.0, 6: 2.0, 7: 2.0, 8: 2.0
            }, ('northing', 0): {
                0: 0.0, 1: 0.5, 2: 1.0, 3: 1.5, 4: 2.0,
                5: 2.5, 6: 3.0, 7: 3.5, 8: 4.0
            }, ('northing', 1): {
                0: 0.0, 1: 0.5, 2: 1.0, 3: 1.5, 4: 2.0,
                5: 2.5, 6: 3.0, 7: 3.5, 8: 4.0
            }, ('northing', 2): {
                0: 0.0, 1: 0.5, 2: 1.0, 3: 1.5, 4: 2.0,
                5: 2.5, 6: 3.0, 7: 3.5, 8: 4.0}
        })
        self.known_df.columns.names = ['coord', 'i']
        self.known_df.index.names = ['j']

        self.known_masked_cell_df = pandas.DataFrame({
            ('easting', 0): {
                0: nan, 1: nan, 2: 1.25, 3: 1.25, 4: 1.25,
                5: 1.25, 6: 1.25, 7: 1.25
            }, ('easting', 1): {
                0: nan, 1: nan, 2: 1.75, 3: 1.75, 4: 1.75,
                5: 1.75, 6: 1.75, 7: 1.75
            }, ('northing', 0): {
                0: nan, 1: nan, 2: 1.25, 3: 1.75, 4: 2.25,
                5: 2.75, 6: 3.25, 7: 3.75
            }, ('northing', 1): {
                0: nan, 1: nan, 2: 1.25, 3: 1.75, 4: 2.25,
                5: 2.75, 6: 3.25, 7: 3.75
            }
        })
        self.known_masked_cell_df.columns.names = ['coord', 'i']
        self.known_masked_cell_df.index.names = ['j']

        self.known_coord_pairs = np.array([
            [1. , 0. ], [1.5, 0. ], [2. , 0. ], [1. , 0.5],
            [1.5, 0.5], [2. , 0.5], [1. , 1. ], [1.5, 1. ],
            [2. , 1. ], [1. , 1.5], [1.5, 1.5], [2. , 1.5],
            [1. , 2. ], [1.5, 2. ], [2. , 2. ], [1. , 2.5],
            [1.5, 2.5], [2. , 2.5], [1. , 3. ], [1.5, 3. ],
            [2. , 3. ], [1. , 3.5], [1.5, 3.5], [2. , 3.5],
            [1. , 4. ], [1.5, 4. ], [2. , 4. ]
        ])

        self.known_mask = np.array([
            [True,  True ], [True,  True ],
            [False, False], [False, False],
            [False, False], [False, False],
            [False, False], [False, False],
        ])

        self.known_node_pairs_masked = np.array([
            [ nan,  nan], [ nan,  nan], [ nan,  nan], [ nan,  nan],
            [1.25, 1.25], [1.75, 1.25], [1.25, 1.75], [1.75, 1.75],
            [1.25, 2.25], [1.75, 2.25], [1.25, 2.75], [1.75, 2.75],
            [1.25, 3.25], [1.75, 3.25], [1.25, 3.75], [1.75, 3.75]
        ])

        self.known_node_pairs = np.array([
            [1.25, 0.25], [1.75, 0.25], [1.25, 0.75], [1.75, 0.75],
            [1.25, 1.25], [1.75, 1.25], [1.25, 1.75], [1.75, 1.75],
            [1.25, 2.25], [1.75, 2.25], [1.25, 2.75], [1.75, 2.75],
            [1.25, 3.25], [1.75, 3.25], [1.25, 3.75], [1.75, 3.75]
        ])
def test__plot_points():
    x, y = pgtest.makeSimpleNodes()
    fig1 = _viz_bokeh._plot_points(x, y)