Пример #1
0
 def test_transform_to(self):
     # TODO: verify result
     m = EuclideanMesh2D(self.coords,
                         self.triangles,
                         self.quads,
                         crs="EPSG:3395")
     m.transform_to("EPSG:4326")
Пример #2
0
    def test_property_setter__values_time_varying_bad_shape(self):
        m = EuclideanMesh2D(self.coords, self.triangles, self.quads, crs=4326)

        def wrapper():
            import numpy as np
            m._values = np.random.rand(3, len(self.coords), 1, 5)

        self.assertRaises(Exception, wrapper)
Пример #3
0
    def test_property_setter__values_raise_bad_shape(self):
        m = EuclideanMesh2D(self.coords, self.triangles, self.quads, crs=4326)

        def wrapper():
            import numpy as np
            m._values = np.random.rand(100, 1)

        self.assertRaises(AssertionError, wrapper)
Пример #4
0
 def test_open_gr3(self):
     nodes = {
         '1': ((0., 0.), -99999.),
         '2': ((.5, 0.), -99999.),
         '3': ((1., 0.), -99999.),
         '4': ((1., 1.), -99999.),
         '5': ((0., 1.), -99999.),
         '6': ((.5, 1.5), -99999.),
         '7': ((.33, .33), -99999.),
         '8': ((.66, .33), -99999.),
         '9': ((.5, .66), -99999.),
         '10': ((-1., 1.), -99999.),
         '11': ((-1., 0.), -99999.),
     }
     elements = {
         '1': ['5', '7', '9'],
         '2': ['1', '2', '7'],
         '3': ['2', '3', '8'],
         '4': ['8', '7', '2'],
         '5': ['3', '4', '8'],
         '6': ['4', '9', '8'],
         '7': ['4', '6', '5'],
         '8': ['5', '10', '11', '1'],
         '9': ['9', '4', '5'],
         '10': ['5', '1', '7']
     }
     f = "test\n"
     f += f'{len(elements):d} '
     f += f'{len(nodes):d}\n'
     for id, ((x, y), z) in nodes.items():
         f += f"{id} "
         f += f"{x} "
         f += f"{y} "
         f += f"{z}\n"
     for id, geom in elements.items():
         f += f"{id} "
         f += f"{len(geom)} "
         for idx in geom:
             f += f"{idx} "
         f += f"\n"
     tmpdir = tempfile.TemporaryDirectory()
     gr3 = pathlib.Path(tmpdir.name) / 'gr3.gr3'
     with open(gr3.absolute(), 'w') as h:
         h.write(f)
     msh = EuclideanMesh2D.open_gr3(gr3.absolute())
     self.assertIsInstance(msh, EuclideanMesh2D)
Пример #5
0
 def test_property_setter__quads_None(self):
     self.assertIsInstance(
         EuclideanMesh2D(self.coords, self.triangles, None),
         EuclideanMesh2D)
Пример #6
0
 def test_property_setter__values_time_varying(self):
     # TODO: verify result
     m = EuclideanMesh2D(self.coords, self.triangles, self.quads, crs=4326)
     import numpy as np
     m._values = np.random.rand(3, len(self.coords), 1)
Пример #7
0
 def test_property__grd(self):
     # TODO: verify result
     m = EuclideanMesh2D(self.coords, self.triangles, self.quads, crs=4326)
     m._grd
Пример #8
0
 def test_property_setter_description(self):
     # TODO: verify result
     m = EuclideanMesh2D(self.coords, self.triangles, self.quads, crs=4326)
     m.description = "test"
Пример #9
0
 def test_property_nodes(self):
     # TODO: verify result
     m = EuclideanMesh2D(self.coords, self.triangles, self.quads)
     m.nodes
Пример #10
0
 def test_write_raises(self):
     m = EuclideanMesh2D(self.coords, self.triangles, self.quads)
     import tempfile
     f = tempfile.NamedTemporaryFile()
     self.assertRaises(IOError, m.write, f.name)
Пример #11
0
 def test_get_xy(self):
     # TODO: verify result
     m = EuclideanMesh2D(self.coords, self.triangles, self.quads)
     m.get_xy()
Пример #12
0
 def test_get_y(self):
     # TODO: verify result
     m = EuclideanMesh2D(self.coords, self.triangles, self.quads, crs=4326)
     m.get_y(crs="EPSG:3395")
Пример #13
0
 def test_get_element_index(self):
     m = EuclideanMesh2D(self.coords, self.triangles, self.quads)
     self.assertEquals(m.get_element_index(323078), 0)
Пример #14
0
 def test_get_node_index(self):
     m = EuclideanMesh2D(self.coords, self.triangles, self.quads)
     self.assertEquals(m.get_node_index(123964), 0)
Пример #15
0
 def test_sms2dm(self):
     m = EuclideanMesh2D(self.coords, self.triangles, self.quads)
     self.assertIsInstance(m.sms2dm, str)