Example #1
0
    def test_rectangular(self):
        lons = numpy.array(range(100)).reshape((10, 10))
        lats = numpy.negative(lons)

        mesh = RectangularMesh(lons, lats, depths=None)
        bounding_mesh = mesh._get_bounding_mesh()
        expected_lons = numpy.array([
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
            19, 29, 39, 49, 59, 69, 79, 89,
            99, 98, 97, 96, 95, 94, 93, 92, 91,
            90, 80, 70, 60, 50, 40, 30, 20, 10
        ])
        expected_lats = numpy.negative(expected_lons)
        self.assertTrue((bounding_mesh.lons == expected_lons).all())
        self.assertTrue((bounding_mesh.lats == expected_lats).all())
        self.assertIsNone(bounding_mesh.depths)

        depths = lons + 10
        mesh = RectangularMesh(lons, lats, depths)
        expected_depths = expected_lons + 10
        bounding_mesh = mesh._get_bounding_mesh()
        self.assertIsNotNone(bounding_mesh.depths)
        self.assertTrue((bounding_mesh.depths
                         == expected_depths.flatten()).all())

        bounding_mesh = mesh._get_bounding_mesh(with_depths=False)
        self.assertIsNone(bounding_mesh.depths)
Example #2
0
    def test_single_column(self):
        lons = numpy.array([[0], [1], [2], [3], [4], [5]])
        lats = numpy.array([[-1], [-2], [-3], [-4], [-5], [-6]])
        mesh = RectangularMesh(lons, lats, depths=None)
        bounding_mesh = mesh._get_bounding_mesh()
        self.assertTrue((bounding_mesh.lons == lons.flatten()).all())
        self.assertTrue((bounding_mesh.lats == lats.flatten()).all())
        self.assertIsNone(bounding_mesh.depths)

        depths = numpy.array([[10], [11], [12], [13], [14], [15]])
        mesh = RectangularMesh(lons, lats, depths)
        bounding_mesh = mesh._get_bounding_mesh()
        self.assertIsNotNone(bounding_mesh.depths)
        self.assertTrue((bounding_mesh.depths == depths.flatten()).all())

        bounding_mesh = mesh._get_bounding_mesh(with_depths=False)
        self.assertIsNone(bounding_mesh.depths)
Example #3
0
    def test_single_row(self):
        lons = numpy.array([[0, 1, 2, 3, 4, 5]])
        lats = numpy.array([[-1, -2, -3, -4, -5, -6]])
        mesh = RectangularMesh(lons, lats, depths=None)
        bounding_mesh = mesh._get_bounding_mesh()
        self.assertIsInstance(bounding_mesh, Mesh)
        self.assertTrue((bounding_mesh.lons == lons[0]).all())
        self.assertTrue((bounding_mesh.lats == lats[0]).all())
        self.assertIsNone(bounding_mesh.depths)

        depths = numpy.array([[10, 11, 12, 13, 14, 15]])
        mesh = RectangularMesh(lons, lats, depths)
        bounding_mesh = mesh._get_bounding_mesh()
        self.assertIsNotNone(bounding_mesh.depths)
        self.assertTrue((bounding_mesh.depths == depths[0]).all())

        bounding_mesh = mesh._get_bounding_mesh(with_depths=False)
        self.assertIsNone(bounding_mesh.depths)