Exemplo n.º 1
0
    def test_io_rhoa(self):
        # Setup a dipole-dipole Survey

        for survey_type, test_file, rhoa_file in zip(
            ["dipole-dipole", "pole-dipole", "dipole-pole", "pole-pole"],
            [
                "2sph_dipole_dipole.obs",
                "2sph_pole_dipole.obs",
                "2sph_dipole_pole.obs",
                "2sph_pole_pole.obs",
            ],
            [
                "rhoA_GIF_dd.txt",
                "rhoA_GIF_pd.txt",
                "rhoA_GIF_dp.txt",
                "rhoA_GIF_pp.txt",
            ],
        ):
            print("\n Testing {} ... ".format(survey_type))
            survey = utils.gen_DCIPsurvey(
                self.xyz,
                survey_type=survey_type,
                dim=self.mesh.dim,
                a=self.survey_a,
                b=self.survey_b,
                n=self.survey_n,
            )

            self.assertEqual(survey_type, survey.survey_type)

            # Setup Problem with exponential mapping
            expmap = maps.ExpMap(self.mesh)
            problem = dc.Simulation3DCellCentered(
                self.mesh, sigmaMap=expmap, survey=survey, bc_type="Neumann"
            )
            problem.solver = Solver

            # Create synthetic data
            dobs = problem.make_synthetic_data(self.model, relative_error=0.0)
            dobs.eps = 1e-5

            # Testing IO
            surveyfile = os.path.sep.join([self.basePath, test_file])
            utils.writeUBC_DCobs(
                surveyfile, dobs, survey_type=survey_type, dim=3, format_type="GENERAL"
            )
            data2 = utils.readUBC_DC3Dobs(surveyfile)
            self.assertTrue(np.allclose(mkvc(data2), mkvc(dobs)))

            if self.plotIt:
                import matplotlib.pyplot as plt

                # Test Pseudosections plotting
                fig, ax = plt.subplots(1, 1, figsize=(15, 3))
                ax = utils.plot_pseudoSection(
                    survey,
                    ax,
                    survey_type=survey_type,
                    scale="log",
                    clim=None,
                    data_type="appResistivity",
                    pcolorOpts={"cmap": "viridis"},
                    data_location=True,
                )
                plt.show()

            # Test the utils functions electrode_separations,
            # source_receiver_midpoints, geometric_factor,
            # apparent_resistivity all at once
            rhoapp = utils.apparent_resistivity(
                dobs, survey_type=survey_type, space_type="half-space", eps=0.0
            )

            rhoA_GIF_file = os.path.sep.join([self.basePath, rhoa_file])
            rhoA_GIF = np.loadtxt(rhoA_GIF_file)
            passed = np.allclose(rhoapp, rhoA_GIF)
            self.assertTrue(passed)
            print("   ... ok \n".format(survey_type))
Exemplo n.º 2
0
# Predict the data by running the simulation. The data are the raw voltage in
# units of volts.
dpred_dc = dc_simulation.dpred(conductivity_model)

# Define a data object (required for pseudo-section plot)
dc_data = data.Data(dc_survey, dobs=dpred_dc)

# Plot apparent conductivity pseudo-section
fig = plt.figure(figsize=(12, 5))

ax1 = fig.add_axes([0.05, 0.05, 0.8, 0.9])
plot_pseudoSection(
    dc_data,
    ax=ax1,
    survey_type="dipole-dipole",
    data_type="appConductivity",
    space_type="half-space",
    scale="log",
    pcolorOpts={"cmap": "viridis"},
)
ax1.set_title("Apparent Conductivity [S/m]")

plt.show()

#######################################################################
# Optional: Write out dpred
# -------------------------
#
# Write DC resistivity data, topography and true model
#