Esempio n. 1
0
    def test_apparent_resistivity(self):

        # Compute apparent resistivity from survey
        rhoapp = utils.apparent_resistivity(
            self.data, space_type="whole-space", eps=1e-16
        )

        # Load benchmarks files from UBC-GIF codes
        rhoappfile = os.path.sep.join([self.basePath, "RhoApp_GIF_fullspace.txt"])
        rhogif = np.loadtxt(rhoappfile)
        # remove value with almost null geometric factor
        idx = rhoapp < 1e8
        # Assert agreements between the two codes
        passed = np.allclose(rhoapp[idx], rhogif[idx])
        self.assertTrue(passed)
Esempio n. 2
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))