def test_wrap_surface(self): surf = omfvista.wrap(SURFACE) self.assertTrue(isinstance(surf, pyvista.UnstructuredGrid)) self.assertEqual(surf.n_arrays, len(SURFACE.data)) self.assertEqual(surf.n_cells, SURFACE.geometry.num_cells) self.assertEqual(surf.n_points, SURFACE.geometry.num_nodes) grid = omfvista.wrap(GRID) self.assertTrue(isinstance(grid, pyvista.StructuredGrid)) self.assertEqual(grid.n_arrays, len(GRID.data)) self.assertEqual(grid.n_cells, GRID.geometry.num_cells) self.assertEqual(grid.n_points, GRID.geometry.num_nodes)
def test_wrap_volume(self): vol = omfvista.wrap(VOLUME) self.assertEqual(vol.n_arrays, 1) self.assertTrue(isinstance(vol, pyvista.RectilinearGrid)) self.assertEqual(vol.n_arrays, len(VOLUME.data)) self.assertEqual(vol.n_cells, VOLUME.geometry.num_cells) self.assertEqual(vol.n_points, VOLUME.geometry.num_nodes) vol_ir = omfvista.wrap(VOLUME_IR) self.assertEqual(vol_ir.n_arrays, 1) self.assertTrue(isinstance(vol_ir, pyvista.StructuredGrid)) self.assertEqual(vol_ir.n_arrays, len(VOLUME_IR.data)) self.assertEqual(vol_ir.n_cells, VOLUME_IR.geometry.num_cells) self.assertEqual(vol_ir.n_points, VOLUME_IR.geometry.num_nodes)
def test_wrap_lineset(self): line = omfvista.wrap(LINESET) self.assertTrue(isinstance(line, pyvista.PolyData)) # Note that omfvista adds a `Line Index` array self.assertEqual(line.n_arrays, len(LINESET.data) + 1) self.assertEqual(line.n_cells, LINESET.geometry.num_cells) self.assertEqual(line.n_points, LINESET.geometry.num_nodes)
def _get_raw_data(self): """Converts OMF data to VTK data objects.""" # Now iterate over the elements and add converted data to the data dict: data = dict() for e in self.__project.elements: if self._dataselection.ArrayIsEnabled(e.name): if e.name not in self.__data: self.__data[e.name] = omfvista.wrap(e) data[e.name] = self.__data[e.name] return data
def project_to_vtk(project): """Converts an OMF project (:class:`omf.base.Project`) to a :class:`pyvista.MultiBlock` data boject """ # Iterate over the elements and add converted VTK objects a MultiBlock data = pyvista.MultiBlock() for i, e in enumerate(project.elements): d = omfvista.wrap(e) data[i, e.name] = d return data
def test_wrap_pointset(self): pts = omfvista.wrap(POINTSET) self.assertTrue(isinstance(pts, pyvista.PolyData)) self.assertEqual(pts.n_arrays, len(POINTSET.data)) self.assertEqual(pts.n_cells, POINTSET.geometry.num_cells) self.assertEqual(pts.n_points, POINTSET.geometry.num_nodes)
def test_wrap_list_of_elements(self): proj = omfvista.wrap(PROJECT.elements) self._check_multi_block(proj)
def test_wrap_project(self): proj = omfvista.wrap(PROJECT) self._check_multi_block(proj)
import omfvista import pandas as pd import numpy as np ############################################################################### description='This contains vertices of meshed/interpolated ' \ 'surfaces of the granitoid-basin fill contact used in the ' \ 'Phase 2B earth model. All data are georeferenced to UTM, ' \ 'zone 12N, NAD 83, NAVD 88.' top_granitoid = gdc19.surf_to_omf('top_granitoid_vertices.csv', 'top_granitoid', description) top_granitoid.validate() ############################################################################### omfvista.wrap(top_granitoid).plot(show_edges=False) ############################################################################### description='Negro Mag Fault used in the Phase 2B earth model. ' \ 'All data are georeferenced to UTM, zone 12N, NAD 83, NAVD 88.' negro_mag_fault = gdc19.surf_to_omf('Negro_Mag_Fault_vertices.csv', 'negro_mag_fault', description) negro_mag_fault.validate() ############################################################################### omfvista.wrap(negro_mag_fault).plot(show_edges=False) ############################################################################### description='surfaces of the Opal Mound Fault used in the Phase ' \ '2B earth model. All data are georeferenced to UTM, zone '\
import pandas as pd import numpy as np ############################################################################### # First, get the land surface to match Z-coordinates of shape files with # the topography. description='vertices of meshed/interpolated surfaces of the ' \ 'land surface (based on 10-meter DEM) used in the Phase 2B '\ 'earth model. All data are georeferenced to UTM, zone 12N, '\ 'NAD 83, NAVD 88.' land_surface = gdc19.surf_to_omf('land_surface_vertices.csv', 'land_surface', description) land_surface.validate() topo = omfvista.wrap(land_surface) ############################################################################### # Load the shape files shapes = gdc19.read_shape_file_to_omf(gdc19.get_shp_path('FORGE_Outline'), topo_points=topo.points) shapes ############################################################################### boundary = shapes[0] boundary.name = 'boundary' boundary.validate() ############################################################################### omfvista.wrap(boundary).plot(show_edges=False)
def load_topo(): proj = omf.OMFReader(gdc19.get_omf_project_filename()).get_project() for el in proj.elements: if el.name == 'land_surface': return omfvista.wrap(el) raise RuntimeError('Topo is not in project file. Some one messed up.')