示例#1
0
 def test_read_moment_info(self):
     """
     Test reading the info from spectral analysis.
     """
     testing_path = os.path.join(self.testing_path, 'automag.out')
     spec_inf = read_spectral_info(testing_path)
     self.assertEqual(len(spec_inf), 5)
     # This should actually test that what we are reading in is correct.
     average = spec_inf[('AVERAGE', '')]
     check_av = {
         u'channel': '',
         u'corner_freq': 5.97,
         u'decay': 0.0,
         u'moment': 12589254117.941662,
         u'moment_mag': 0.7,
         u'source_radius': 0.231,
         u'spectral_level': 0.3981071705534972,
         u'station': 'AVERAGE',
         u'stress_drop': 0.006,
         u'window_length': 1.6
     }
     for key in average.keys():
         if isinstance(average.get(key), str):
             self.assertEqual(average.get(key), check_av.get(key))
         else:
             self.assertEqual(round(average.get(key), 4),
                              round(check_av.get(key), 4))
示例#2
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')
示例#3
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')
示例#4
0
文件: test_nordic.py 项目: mbyt/obspy
 def test_read_moment_info(self):
     """Test reading the info from spectral analysis."""
     testing_path = os.path.join(self.testing_path, 'automag.out')
     spec_inf = read_spectral_info(testing_path)
     self.assertEqual(len(spec_inf), 5)
     # This should actually test that what we are reading in is correct.
     average = spec_inf[('AVERAGE', '')]
     check_av = {u'channel': '', u'corner_freq': 5.97, u'decay': 0.0,
                 u'moment': 12589254117.941662, u'moment_mag': 0.7,
                 u'source_radius': 0.231,
                 u'spectral_level': 0.3981071705534972,
                 u'station': 'AVERAGE', u'stress_drop': 0.006,
                 u'window_length': 1.6}
     for key in average.keys():
         if isinstance(average.get(key), str):
             self.assertEqual(average.get(key), check_av.get(key))
         else:
             self.assertEqual(round(average.get(key), 4),
                              round(check_av.get(key), 4))