def test_load_quakeML(): """Test the create directory method""" # Check one cmt file with tempfile.TemporaryDirectory() as tmp_dir: # Cmtfile path cmtfile = os.path.join(DATA_DIR, "testCMT") # create new directory new_xml_path = os.path.join(tmp_dir, "tests.xml") xml = read_events(cmtfile) xml.write(new_xml_path, format="QUAKEML") assert(os.path.exists(new_xml_path) and os.path.isfile(new_xml_path)) print("QuakeML\n", CMTSource.from_quakeml_file(new_xml_path)) print("CMT\n", CMTSource.from_CMTSOLUTION_file(cmtfile)) assertDictAlmostEqual(CMTSource.from_quakeml_file(new_xml_path), CMTSource.from_CMTSOLUTION_file(cmtfile))
def test__copy_quake(self): """Test the create directory method""" # Check one cmt file with tempfile.TemporaryDirectory() as tmp_dir: # Cmtfile path cmtfile = os.path.join(DATA_DIR, "testCMT") # Initialize database skeleton class DB = DataBaseSkeleton(basedir=tmp_dir, cmt_fn=cmtfile, specfem_dir=self.specfem_dir) # create new directory new_cmt_path = os.path.join(tmp_dir, "blub.xml") DB._write_quakeml(cmtfile, new_cmt_path, True) self.assertTrue(os.path.exists(new_cmt_path) and os.path.isfile(new_cmt_path)) print("QuakeML\n", CMTSource.from_quakeml_file(new_cmt_path)) print("CMT\n", CMTSource.from_CMTSOLUTION_file(cmtfile)) assertDictAlmostEqual(CMTSource.from_quakeml_file(new_cmt_path), CMTSource.from_CMTSOLUTION_file(cmtfile))