Ejemplo n.º 1
0
    def test_export_edi_files(self):
        path3 = make_temp_dir(self.__class__.__name__ +
                              "_export_edi_files_no_interp",
                              base_dir=self._temp_dir)
        path4 = make_temp_dir(self.__class__.__name__ +
                              "_export_edi_files_interp",
                              base_dir=self._temp_dir)

        # Note that this test relies on the fact that the input edi files all have the same periods.
        # EDI files generated based on the periods as in the input edi files should be identical
        # to those produced with interpolation turned on or off.

        # no interp
        self.edi_collection.export_edi_files(path3)

        # interp
        mto = self.edi_collection.mt_obj_list[0]
        plist = 1. / mto.Z.freq
        self.edi_collection.export_edi_files(path4, period_list=plist)

        for fn in glob.glob('%s/*.edi' % (path3)):
            f1 = os.path.join(path3, fn)
            f2 = os.path.join(path4, fn)

            assert filecmp.cmp(f1, f2)
Ejemplo n.º 2
0
 def setUp(self):
     self.model_epsg = 28355
     #self._temp_dir = make_temp_dir(self.__name__)
     self._temp_dir = make_temp_dir("TestModEM_Model_tmp")
     # directory to save created input files
     self._output_dir = make_temp_dir(self._testMethodName,
                                      base_dir=self._temp_dir)
     self._model_dir = os.path.join(SAMPLE_DIR, 'ModEM')
     self._sgrid_fn = os.path.join(SAMPLE_DIR, 'gocad',
                                   'ModEM_Model_File.sg')
     self._model_fn = os.path.join(self._model_dir, 'ModEM_Model_File.rho')
     self._data_fn = os.path.join(self._model_dir, 'ModEM_Data.dat')
Ejemplo n.º 3
0
 def setUpClass(cls):
     """
     Reset building matplotlib plot and generate tempdir inputfiles 
     
     """
     reset_matplotlib()
     cls._temp_dir = make_temp_dir(cls.__name__)
Ejemplo n.º 4
0
    def setUp(self):
        # for each test, setup a different output dir
        self._output_dir = make_temp_dir(self._testMethodName,
                                         base_dir=self._temp_dir)

        # set the dir to the output from the previously correct run
        self._expected_output_dir = os.path.normpath(
            os.path.join(os.path.join(self._temp_dir, 'expected_data_output'),
                         self._testMethodName))

        # unzip expected output files
        tfn = os.path.join(os.path.dirname(__file__),
                           'test_data.expected.tar.gz')

        tf = tarfile.open(tfn)
        output_dir = self._expected_output_dir
        for member in tf.getmembers():
            if (member.isreg()):
                if (self._testMethodName in member.name):

                    member.name = os.path.basename(
                        member.name)  # remove the path by resetting it

                    tf.extract(member, output_dir)  # extract
                # end if
            # end if
        # end for

        if not os.path.isdir(self._expected_output_dir):
            self._expected_output_dir = None
Ejemplo n.º 5
0
    def setUp(self):

        # directory to save created input files
        self._output_dir = make_temp_dir(self._testMethodName,
                                         base_dir=self._temp_dir)

        self._expected_output_dir = os.path.join(SAMPLE_DIR, 'ModEM')
        if not os.path.isdir(self._expected_output_dir):
            self._expected_output_dir = None
Ejemplo n.º 6
0
    def setUp(self):

        # set the dir to the output from the previously correct run
        self._expected_output_dir = os.path.join(SAMPLE_DIR, 'Occam2d')

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

        # directory to save created input files
        self._output_dir = make_temp_dir('Occam2d', self._temp_dir)
Ejemplo n.º 7
0
    def setUp(self):

        # directory to save created input files
        self._output_dir = make_temp_dir(self._testMethodName,
                                         base_dir=self._temp_dir)

        # set the dir to the output from the previously correct run
        self._expected_output_dir = os.path.join(SAMPLE_DIR, 'ModEM')

        if not os.path.isdir(self._expected_output_dir):
            self._expected_output_dir = None
Ejemplo n.º 8
0
    def setUp(self):
        # for each test, setup a different output dir
        self._output_dir = make_temp_dir(self._testMethodName,
                                         base_dir=self._temp_dir)

        # set the dir to the output from the previously correct run
        self._expected_output_dir = os.path.normpath(
            os.path.join(os.path.join(self._temp_dir, 'expected_data_output'),
                         self._testMethodName))
        if not os.path.isdir(self._expected_output_dir):
            self._expected_output_dir = None
Ejemplo n.º 9
0
def test_read_write():
    # path2edi = 'data/AMT/15125A_spe.edi'
    output_dir = make_temp_dir(__name__)
    path2edi = os.path.normpath(
        os.path.join(TEST_MTPY_ROOT, 'data/AMT/15125A_imp.edi'))

    edi_obj = Edi(edi_fn=path2edi)
    # change the latitude
    edi_obj.lat = 45.7869

    new_edi_fn = os.path.join(output_dir, os.path.basename(path2edi))

    ret_edi = edi_obj.write_edi_file(new_edi_fn=new_edi_fn)

    print(ret_edi)
Ejemplo n.º 10
0
 def setUpClass(cls):
     cls._temp_dir = make_temp_dir(cls.__name__)
Ejemplo n.º 11
0
 def setUpClass(cls):
     plt.clf()
     cls._temp_dir = make_temp_dir(cls.__name__)
Ejemplo n.º 12
0
 def test_create_phase_tensor_csv(self):
     path = make_temp_dir(self.__class__.__name__ + "_phase_tensor_csv",
                          base_dir=self._temp_dir)
     self.edi_collection.create_phase_tensor_csv(path)
Ejemplo n.º 13
0
 def test_create_mt_station_gdf(self):
     path = make_temp_dir(self.__class__.__name__ + "_mt_station_gdf",
                          base_dir=self._temp_dir)
     self.edi_collection.create_mt_station_gdf(path)
Ejemplo n.º 14
0
 def setUpClass(cls):
     reset_matplotlib()
     cls._temp_dir = make_temp_dir(cls.__name__)
Ejemplo n.º 15
0
 def setUpClass(cls):
     _thread_lock.acquire()
     reset_matplotlib()
     cls._temp_dir = make_temp_dir(cls.__name__.split('.')[-1])
Ejemplo n.º 16
0
 def setUpClass(cls):
     # setup temp dir
     cls._temp_dir = make_temp_dir(cls.__name__)
Ejemplo n.º 17
0
 def test_create_phase_tensor_csv_with_image(self):
     path2 = make_temp_dir(self.__class__.__name__ +
                           "_phase_tensor_csv_with_image",
                           base_dir=self._temp_dir)
     self.edi_collection.create_phase_tensor_csv_with_image(path2)