예제 #1
0
    def test_io_survey(self):

        data_object = Data(survey=self.survey)
        filename = "survey.mag"

        write_mag3d_ubc(filename, data_object)
        data_loaded = read_mag3d_ubc(filename)
        os.remove(filename)

        passed = np.all(
            np.isclose(
                self.survey.receiver_locations, data_loaded.survey.receiver_locations
            )
        )
        self.assertTrue(passed, True)

        passed = np.all(
            np.isclose(
                self.survey.source_field.parameters,
                data_loaded.survey.source_field.parameters,
            )
        )
        self.assertTrue(passed, True)

        print("SURVEY FILE IO FOR MAG3D PASSED")
예제 #2
0
    def test_io_dobs(self):

        data_object = Data(survey=self.survey,
                           dobs=self.dobs,
                           standard_deviation=self.std)
        filename = "dpred.mag"

        write_mag3d_ubc(filename, data_object)
        data_loaded = read_mag3d_ubc(filename)
        os.remove(filename)

        passed = np.all(
            np.isclose(
                np.c_[self.survey.receiver_locations, self.dobs, self.std],
                np.c_[data_loaded.survey.receiver_locations, data_loaded.dobs,
                      data_loaded.standard_deviation, ],
            ))
        self.assertTrue(passed, True)

        passed = np.all(
            np.isclose(
                self.survey.source_field.parameters,
                data_loaded.survey.source_field.parameters,
            ))
        self.assertTrue(passed, True)

        print("OBSERVED DATA FILE IO FOR MAG3D PASSED")
예제 #3
0
    def test_magnetics_inversion(self):

        inp_file = os.path.sep.join([self.basePath, "SimPEG_Mag_Input.inp"])

        driver = MagneticsDriver_Inv(inp_file)

        print(driver.mesh)
        print(driver.survey)
        print(driver.m0)
        print(driver.mref)
        print(driver.activeCells)
        print(driver.staticCells)
        print(driver.dynamicCells)
        print(driver.chi)
        print(driver.nC)
        print(driver.alphas)
        print(driver.bounds)
        print(driver.lpnorms)
        print(driver.eps)

        # Write obs to file
        io_utils.write_mag3d_ubc(
            os.path.sep.join([self.basePath, "FWR_data.dat"]), driver.data)

        # Read it back
        data = io_utils.read_mag3d_ubc(
            os.path.sep.join([self.basePath, "FWR_data.dat"]))
        # Check similarity
        passed = np.all(data.dobs == driver.data.dobs)
        self.assertTrue(passed, True)

        # Clean up the working directory
        shutil.rmtree(self.basePath)