def test_Tile(self): """ Test for TileMap """ rxLocs = np.random.randn(3, 3) * 20 h = [5, 5, 5] padDist = np.ones((3, 2)) * 100 local_meshes = [] for ii in range(rxLocs.shape[0]): local_mesh = mesh_builder_xyz(rxLocs, h, padding_distance=padDist, mesh_type="tree") local_mesh = refine_tree_xyz( local_mesh, rxLocs[ii, :].reshape((1, -1)), method="radial", octree_levels=[1], finalize=True, ) local_meshes.append(local_mesh) mesh = mesh_builder_xyz(rxLocs, h, padding_distance=padDist, mesh_type="tree") # This garantees that the local meshes are always coarser or equal for local_mesh in local_meshes: mesh.insert_cells( local_mesh.gridCC, local_mesh.cell_levels_by_index(np.arange(local_mesh.nC)), finalize=False, ) mesh.finalize() # Define an active cells from topo activeCells = utils.surface2ind_topo(mesh, rxLocs) model = np.random.randn(int(activeCells.sum())) total_mass = (model * mesh.vol[activeCells]).sum() for local_mesh in local_meshes: tile_map = maps.TileMap( mesh, activeCells, local_mesh, ) local_mass = ((tile_map * model) * local_mesh.vol[tile_map.local_active]).sum() self.assertTrue((local_mass - total_mass) / total_mass < 1e-8)
# Add noise and uncertainties # We add some random Gaussian noise (1nT) synthetic_data = d + np.random.randn(len(d)) * 1e-3 wd = np.ones(len(synthetic_data)) * 1e-3 # Assign flat uncertainties ############################################################### # Tiled misfits # # # # local_misfits = [] for ii, local_survey in enumerate(local_surveys): tile_map = maps.TileMap(mesh, activeCells, local_meshes[ii]) local_actives = tile_map.local_active # Create the forward simulation simulation = gravity.simulation.Simulation3DIntegral( survey=local_survey, mesh=local_meshes[ii], rhoMap=tile_map, actInd=local_actives, sensitivity_path=f"Inversion\Tile{ii}.zarr", ) data_object = data.Data( local_survey, dobs=synthetic_data[local_indices[ii]],