def setUp(self): url = "https://storage.googleapis.com/simpeg/tests/dc_utils/" cloudfiles = [ "dPred_fullspace.txt", "AB_GIF_fullspace.txt", "MN_GIF_fullspace.txt", "AM_GIF_fullspace.txt", "AN_GIF_fullspace.txt", "BM_GIF_fullspace.txt", "BN_GIF_fullspace.txt", "RhoApp_GIF_fullspace.txt", ] self.basePath = os.path.expanduser("~/Downloads/TestDCUtilsFullSpace") self.files = io_utils.download( [url + f for f in cloudfiles], folder=self.basePath, overwrite=True ) survey_file = os.path.sep.join([self.basePath, "dPred_fullspace.txt"]) data = utils.readUBC_DC3Dobs(survey_file) self.survey = data.survey self.data = data
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))