Exemple #1
0
    def test_read_gocad_sgrid_file(self):

        if not os.path.isdir(self._model_dir):
            self._model_dir = None

        output_fn = os.path.basename(self._model_fn)

        # read data file to get centre position
        dObj = Data()
        dObj.read_data_file(data_fn=self._data_fn)

        # create a model object using the data object and read in gocad sgrid file
        mObj = Model(data_obj=dObj, save_path=self._output_dir)
        mObj.read_gocad_sgrid_file(self._sgrid_fn)
        mObj.write_model_file()

        output_data_file = os.path.normpath(
            os.path.join(self._output_dir, output_fn))

        self.assertTrue(os.path.isfile(output_data_file),
                        "output data file not found")

        expected_data_file = os.path.normpath(self._model_fn_old_z_mesh)

        self.assertTrue(
            os.path.isfile(expected_data_file),
            "Ref output data file does not exist, nothing to compare with")

        is_identical, msg = diff_files(output_data_file, expected_data_file)
        print(msg)
        self.assertTrue(
            is_identical,
            "The output file is not the same with the baseline file.")
Exemple #2
0
data_fn = r'C:\mtpywin\mtpy\examples\model_files\ModEM\ModEM_Data.dat'
dObj = Data()
dObj.read_data_file(data_fn=data_fn)

### option 2 ####
stationxyfile = r'C:\mtpywin\mtpy\examples\model_files\gocad\stationxy.txt'
xy = np.loadtxt(stationxyfile, usecols=(1, 2))
station_names = np.loadtxt(stationxyfile, usecols=(0, ), dtype='S10')
period_list = np.logspace(1, 4, 19)  # change to your period list

# create data file
dObj = Data(epsg=epsg)
dObj._initialise_empty_data_array(xy,
                                  period_list,
                                  location_type='LL',
                                  station_names=station_names)
dObj.write_data_file(fill=False, save_path=workdir)

# Create model file
mObj = Model(Data=dObj, save_path=workdir)
mObj.read_gocad_sgrid_file(gocad_sgrid_file)
mObj.model_fn_basename = op.join(workdir, 'ModEM_Model_forward.ws')
mObj.write_model_file()

# create covariance file
cov = Covariance(save_path=workdir,
                 smoothing_east=0.3,
                 smoothing_north=0.3,
                 smoothing_z=0.3)
cov.write_covariance_file(model_fn=mObj.model_fn)