コード例 #1
0
    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, ]

        mapping = maps.LogMap(self.mesh2)
        self.assertTrue(mapping.test(v2, dx=dv2))
        mapping = maps.LogMap(self.mesh3)
        self.assertTrue(mapping.test(v3, dx=dv3))

        mapping = maps.ReciprocalMap(self.mesh2)
        self.assertTrue(mapping.test(v2, dx=dv2))
        mapping = maps.ReciprocalMap(self.mesh3)
        self.assertTrue(mapping.test(v3, dx=dv3))
コード例 #2
0
# Starting/Reference Model and Mapping on Tensor Mesh
# ---------------------------------------------------
#
# Here, we create starting and/or reference models for the inversion as
# well as the mapping from the model space to the slowness. Starting and
# reference models can be a constant background value or contain a-priori
# structures. Here, the background is 3000 m/s.
#

# Define density contrast values for each unit in g/cc. Don't make this 0!
# Otherwise the gradient for the 1st iteration is zero and the inversion will
# not converge.
background_velocity = 3000.0

# Define mapping from model space to the slowness on mesh cells
model_mapping = maps.ReciprocalMap()

# Define starting model
starting_model = background_velocity * np.ones(mesh.nC)

##############################################
# Define the Physics
# ------------------
#
# Here, we define the physics of the 2D straight ray tomography problem by
# using the simulation class.
#

# Define the forward simulation. To do this we need the mesh, the survey and
# the mapping from the model to the slowness value on each cell.
simulation = tomo.Simulation(mesh, survey=survey, slownessMap=model_mapping)
コード例 #3
0
ファイル: plot_3_tree_models.py プロジェクト: yjx520/simpeg
# Define the model on subsurface cells
model = background_value * np.ones(ind_active.sum())
ind_dyke = (mesh.gridCC[ind_active, 0] > 20.0) & (mesh.gridCC[ind_active, 0] <
                                                  40.0)
model[ind_dyke] = dyke_value
ind_block = ((mesh.gridCC[ind_active, 0] > -40.0)
             & (mesh.gridCC[ind_active, 0] < -10.0)
             & (mesh.gridCC[ind_active, 1] > -30.0)
             & (mesh.gridCC[ind_active, 1] < 30.0)
             & (mesh.gridCC[ind_active, 2] > -40.0)
             & (mesh.gridCC[ind_active, 2] < 0.0))
model[ind_block] = block_value

# Define a single mapping from model to mesh
exponential_map = maps.ExpMap()
reciprocal_map = maps.ReciprocalMap()
model_map = active_map * reciprocal_map * exponential_map

# Plot
fig = plt.figure(figsize=(5, 5))
ax = fig.add_subplot(111)
ind_slice = int(mesh.hy.size / 2)
mesh.plotSlice(model_map * model, normal="Y", ax=ax, ind=ind_slice, grid=True)
ax.set_title("Model slice at y = {} m".format(mesh.x0[1] +
                                              np.sum(mesh.hy[0:ind_slice])))
plt.show()

#############################################
# Models with arbitrary shapes
# ----------------------------
#
コード例 #4
0
def setupProblem(
    mesh,
    muMod,
    sigmaMod,
    prbtype="ElectricField",
    invertMui=False,
    sigmaInInversion=False,
    freq=1.0,
):
    rxcomp = ["real", "imag"]

    loc = utils.ndgrid([mesh.vectorCCx, np.r_[0.0], mesh.vectorCCz])

    if prbtype in ["ElectricField", "MagneticFluxDensity"]:
        rxfields_y = ["ElectricField", "CurrentDensity"]
        rxfields_xz = ["MagneticFluxDensity", "MagneticField"]

    elif prbtype in ["MagneticField", "CurrentDensity"]:
        rxfields_y = ["MagneticFluxDensity", "MagneticField"]
        rxfields_xz = ["ElectricField", "CurrentDensity"]

    receiver_list_edge = [
        getattr(fdem.receivers, "Point{f}".format(f=f))(loc,
                                                        component=comp,
                                                        orientation=orient)
        for f in rxfields_y for comp in rxcomp for orient in ["y"]
    ]

    receiver_list_face = [
        getattr(fdem.receivers, "Point{f}".format(f=f))(loc,
                                                        component=comp,
                                                        orientation=orient)
        for f in rxfields_xz for comp in rxcomp for orient in ["x", "z"]
    ]

    receiver_list = receiver_list_edge + receiver_list_face

    src_loc = np.r_[0.0, 0.0, 0.0]

    if prbtype in ["ElectricField", "MagneticFluxDensity"]:
        src = fdem.sources.MagDipole(receiver_list=receiver_list,
                                     location=src_loc,
                                     frequency=freq)

    elif prbtype in ["MagneticField", "CurrentDensity"]:
        ind = utils.closestPoints(mesh, src_loc, "Fz") + mesh.vnF[0]
        vec = np.zeros(mesh.nF)
        vec[ind] = 1.0

        src = fdem.sources.RawVec_e(receiver_list=receiver_list,
                                    frequency=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,
                           "Simulation3D{}".format(prbtype))(mesh,
                                                             muiMap=muiMap,
                                                             sigmaMap=sigmaMap)
            # m0 = np.hstack([1./muMod, sigmaMod])
        else:
            prob = getattr(fdem,
                           "Simulation3D{}".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,
                           "Simulation3D{}".format(prbtype))(mesh,
                                                             sigma=sigmaMod,
                                                             muiMap=muiMap)
            # m0 = 1./muMod
        else:
            prob = getattr(fdem,
                           "Simulation3D{}".format(prbtype))(mesh,
                                                             sigma=sigmaMod,
                                                             muMap=muMap)
        m0 = muMod

    prob.survey = survey

    return m0, prob, survey