示例#1
0
 def test_is_sfile(self):
     sfiles = ['01-0411-15L.S201309', 'automag.out', 'bad_picks.sfile',
               'round_len_undef.sfile', 'Sfile_extra_header',
               'Sfile_no_location']
     for sfile in sfiles:
         self.assertTrue(_is_sfile(os.path.join(self.testing_path, sfile)))
     self.assertFalse(
         _is_sfile(os.path.join(self.testing_path, 'Sfile_no_header')))
     self.assertFalse(_is_sfile(os.path.join(
         self.path, '..', '..', 'nlloc', 'tests', 'data', 'nlloc.hyp')))
示例#2
0
 def test_is_sfile(self):
     sfiles = ['01-0411-15L.S201309', 'automag.out', 'bad_picks.sfile',
               'round_len_undef.sfile', 'Sfile_extra_header',
               'Sfile_no_location']
     for sfile in sfiles:
         self.assertTrue(_is_sfile(os.path.join(self.testing_path, sfile)))
     self.assertFalse(_is_sfile(os.path.join(self.testing_path,
                                             'Sfile_no_header')))
     self.assertFalse(_is_sfile(os.path.join(self.path, '..', '..',
                                             'nlloc', 'tests', 'data',
                                             'nlloc.hyp')))
示例#3
0
 def test_write_select(self):
     cat = read_events()
     with NamedTemporaryFile(suffix='.out') as tf:
         # raises "UserWarning: mb is not convertible"
         with warnings.catch_warnings():
             warnings.simplefilter('ignore', UserWarning)
             write_select(cat, filename=tf.name)
         self.assertTrue(_is_sfile(tf.name))
         cat_back = read_events(tf.name)
         for event_1, event_2 in zip(cat, cat_back):
             _assert_similarity(event_1=event_1, event_2=event_2)
示例#4
0
 def test_write_select(self):
     cat = read_events()
     with NamedTemporaryFile(suffix='.out') as tf:
         # raises "UserWarning: mb is not convertible"
         with warnings.catch_warnings():
             warnings.simplefilter('ignore', UserWarning)
             write_select(cat, filename=tf.name)
         self.assertTrue(_is_sfile(tf.name))
         cat_back = read_events(tf.name)
         for event_1, event_2 in zip(cat, cat_back):
             _assert_similarity(event_1=event_1, event_2=event_2)
示例#5
0
 def test_read_latin1(self):
     """
     Check that we can read dos formatted, latin1 encoded files.
     """
     dos_file = os.path.join(self.testing_path, 'dos-file.sfile')
     self.assertTrue(_is_sfile(dos_file))
     event = readheader(dos_file)
     self.assertEqual(event.origins[0].latitude, 60.328)
     cat = read_events(dos_file)
     self.assertEqual(cat[0].origins[0].latitude, 60.328)
     wavefiles = readwavename(dos_file)
     self.assertEqual(wavefiles[0], "90121311.0851W41")
     spectral_info = read_spectral_info(dos_file)
     self.assertEqual(len(spectral_info.keys()), 10)
     self.assertEqual(spectral_info[('AVERAGE', '')]['stress_drop'], 27.7)
     with self.assertRaises(UnicodeDecodeError):
         readheader(dos_file, 'ASCII')
示例#6
0
 def test_read_latin1(self):
     """
     Check that we can read dos formatted, latin1 encoded files.
     """
     dos_file = os.path.join(self.testing_path, 'dos-file.sfile')
     self.assertTrue(_is_sfile(dos_file))
     event = readheader(dos_file)
     self.assertEqual(event.origins[0].latitude, 60.328)
     cat = read_events(dos_file)
     self.assertEqual(cat[0].origins[0].latitude, 60.328)
     wavefiles = readwavename(dos_file)
     self.assertEqual(wavefiles[0], "90121311.0851W41")
     spectral_info = read_spectral_info(dos_file)
     self.assertEqual(len(spectral_info.keys()), 10)
     self.assertEqual(spectral_info[('AVERAGE', '')]['stress_drop'], 27.7)
     with self.assertRaises(UnicodeDecodeError):
         readheader(dos_file, 'ASCII')