def test_transforms_logMap_reciprocalMap(self): # Note that log/reciprocal maps can be kinda finicky, so we are being # explicit about the random seed. v2 = np.r_[0.40077291, 0.1441044, 0.58452314, 0.96323738, 0.01198519, 0.79754415] dv2 = np.r_[0.80653921, 0.13132446, 0.4901117, 0.03358737, 0.65473762, 0.44252488] v3 = np.r_[0.96084865, 0.34385186, 0.39430044, 0.81671285, 0.65929109, 0.2235217, 0.87897526, 0.5784033, 0.96876393, 0.63535864, 0.84130763, 0.22123854] dv3 = np.r_[0.96827838, 0.26072111, 0.45090749, 0.10573893, 0.65276365, 0.15646586, 0.51679682, 0.23071984, 0.95106218, 0.14201845, 0.25093564, 0.3732866] maps = Maps.LogMap(self.mesh2) self.assertTrue(maps.test(v2, dx=dv2)) maps = Maps.LogMap(self.mesh3) self.assertTrue(maps.test(v3, dx=dv3)) maps = Maps.ReciprocalMap(self.mesh2) self.assertTrue(maps.test(v2, dx=dv2)) maps = Maps.ReciprocalMap(self.mesh3) self.assertTrue(maps.test(v3, dx=dv3))
ind_active = mesh.gridCC[:, 2] < 0. active_map = Maps.InjectActiveCells(mesh, ind_active, air_value) # Define the model model = background_value * np.ones(ind_active.sum()) ind_layer = ((mesh.gridCC[ind_active, 2] > -20.) & (mesh.gridCC[ind_active, 2] < -0)) model[ind_layer] = layer_value ind_pipe = ((mesh.gridCC[ind_active, 0] < 10.) & (mesh.gridCC[ind_active, 2] > -50.) & (mesh.gridCC[ind_active, 2] < 0.)) model[ind_pipe] = pipe_value # Define a single mapping from model to mesh exponential_map = Maps.ExpMap() reciprocal_map = Maps.ReciprocalMap() model_map = Maps.ComboMap([active_map, reciprocal_map, exponential_map]) # Plotting fig = plt.figure(figsize=(5, 5)) ax = fig.add_subplot(111) mesh.plotImage(model_map * model, ax=ax, grid=True) ax.set_title('Cylindrically Symmetric Model') ############################################# # Parameterized pipe model # ------------------------ # # Instead of defining a model value for each sub-surface cell, we can define # the model in terms of a small number of parameters. Here we parameterize the # model as a block in a half-space. We then create a mapping which projects
def setupProblem( mesh, muMod, sigmaMod, prbtype='e', invertMui=False, sigmaInInversion=False, freq=1. ): rxcomp = ['real', 'imag'] loc = Utils.ndgrid( [mesh.vectorCCx, np.r_[0.], mesh.vectorCCz] ) if prbtype in ['e', 'b']: rxfields_y = ['e', 'j'] rxfields_xz = ['b', 'h'] elif prbtype in ['h', 'j']: rxfields_y = ['b', 'h'] rxfields_xz = ['e', 'j'] rxList_edge = [ getattr(FDEM.Rx, 'Point_{f}'.format(f=f))( loc, component=comp, orientation=orient ) for f in rxfields_y for comp in rxcomp for orient in ['y'] ] rxList_face = [ getattr(FDEM.Rx, 'Point_{f}'.format(f=f))( loc, component=comp, orientation=orient ) for f in rxfields_xz for comp in rxcomp for orient in ['x', 'z'] ] rxList = rxList_edge + rxList_face src_loc = np.r_[0., 0., 0.] if prbtype in ['e', 'b']: src = FDEM.Src.MagDipole( rxList=rxList, loc=src_loc, freq=freq ) elif prbtype in ['h', 'j']: ind = Utils.closestPoints(mesh, src_loc, 'Fz') + mesh.vnF[0] vec = np.zeros(mesh.nF) vec[ind] = 1. src = FDEM.Src.RawVec_e(rxList=rxList, freq=freq, s_e=vec) survey = FDEM.Survey([src]) if sigmaInInversion: wires = Maps.Wires( ('mu', mesh.nC), ('sigma', mesh.nC) ) muMap = Maps.MuRelative(mesh) * wires.mu sigmaMap = Maps.ExpMap(mesh) * wires.sigma if invertMui: muiMap = Maps.ReciprocalMap(mesh)*muMap prob = getattr(FDEM, 'Problem3D_{}'.format(prbtype))( mesh, muiMap=muiMap, sigmaMap=sigmaMap ) # m0 = np.hstack([1./muMod, sigmaMod]) else: prob = getattr(FDEM, 'Problem3D_{}'.format(prbtype))( mesh, muMap=muMap, sigmaMap=sigmaMap ) m0 = np.hstack([muMod, sigmaMod]) else: muMap = Maps.MuRelative(mesh) if invertMui: muiMap = Maps.ReciprocalMap(mesh) * muMap prob = getattr(FDEM, 'Problem3D_{}'.format(prbtype))( mesh, sigma=sigmaMod, muiMap=muiMap ) # m0 = 1./muMod else: prob = getattr(FDEM, 'Problem3D_{}'.format(prbtype))( mesh, sigma=sigmaMod, muMap=muMap ) m0 = muMod prob.pair(survey) return m0, prob, survey