Esempio n. 1
0
 def test_large_sample_rate_interval_raises(self):
     """
     SEG Y supports a sample interval from 1 to 65535 microseconds in steps
     of 1 microsecond. Larger intervals cannot be supported due to the
     definition of the SEG Y format. Therefore the smallest possible
     sampling rate is ~ 15.26 Hz.
     """
     with NamedTemporaryFile() as tf:
         outfile = tf.name
         # Test for SEG Y.
         file = os.path.join(self.path, '1.sgy_first_trace')
         segy = _read_segy(file)
         segy.stats.textual_file_header = \
             _patch_header(segy.stats.textual_file_header)
         # Set the largest possible delta value which should just work.
         segy[0].stats.delta = 0.065535
         _write_segy(segy, outfile)
         # Slightly larger should raise.
         segy[0].stats.delta = 0.065536
         self.assertRaises(SEGYSampleIntervalError, _write_segy, segy,
                           outfile)
         # Same for SU.
         file = os.path.join(self.path, '1.su_first_trace')
         su = _read_su(file)
         # Set the largest possible delta value which should just work.
         su[0].stats.delta = 0.065535
         _write_su(su, outfile)
     # Slightly larger should raise.
     su[0].stats.delta = 0.065536
     self.assertRaises(SEGYSampleIntervalError, _write_su, su, outfile)
Esempio n. 2
0
 def test_largeSampleRateIntervalRaises(self):
     """
     SEG Y supports a sample interval from 1 to 65535 microseconds in steps
     of 1 microsecond. Larger intervals cannot be supported due to the
     definition of the SEG Y format. Therefore the smallest possible
     sampling rate is ~ 15.26 Hz.
     """
     with NamedTemporaryFile() as tf:
         outfile = tf.name
         # Test for SEG Y.
         file = os.path.join(self.path, '1.sgy_first_trace')
         segy = _read_segy(file)
         # Set the largest possible delta value which should just work.
         segy[0].stats.delta = 0.065535
         _write_segy(segy, outfile)
         # Slightly larger should raise.
         segy[0].stats.delta = 0.065536
         self.assertRaises(SEGYSampleIntervalError, _write_segy, segy,
                           outfile)
         # Same for SU.
         file = os.path.join(self.path, '1.su_first_trace')
         su = _read_su(file)
         # Set the largest possible delta value which should just work.
         su[0].stats.delta = 0.065535
         _write_su(su, outfile)
     # Slightly larger should raise.
     su[0].stats.delta = 0.065536
     self.assertRaises(SEGYSampleIntervalError, _write_su, su, outfile)
Esempio n. 3
0
 def test_writing_starttime_timestamp_0(self):
     """
     If the starttime of the Trace is UTCDateTime(0) it will be interpreted
     as a missing starttime is not written. Test if this holds True.
     """
     file = os.path.join(self.path, '1.sgy_first_trace')
     # This file has a set date!
     with open(file, 'rb') as f:
         f.seek(3600 + 156, 0)
         date_time = f.read(10)
     year, julday, hour, minute, second = unpack(b'>5h', date_time)
     self.assertEqual([
         year == 2005, julday == 353, hour == 15, minute == 7, second == 54
     ], 5 * [True])
     # Read and set zero time.
     segy = _read_segy(file)
     segy.stats.textual_file_header = \
         _patch_header(segy.stats.textual_file_header)
     segy[0].stats.starttime = UTCDateTime(0)
     with NamedTemporaryFile() as tf:
         outfile = tf.name
         _write_segy(segy, outfile)
         # Check the new date.
         with open(outfile, 'rb') as f:
             f.seek(3600 + 156, 0)
             date_time = f.read(10)
     year, julday, hour, minute, second = unpack(b'>5h', date_time)
     self.assertEqual(
         [year == 0, julday == 0, hour == 0, minute == 0, second == 0],
         5 * [True])
     # The same for SU.
     file = os.path.join(self.path, '1.su_first_trace')
     # This file has a set date!
     with open(file, 'rb') as f:
         f.seek(156, 0)
         date_time = f.read(10)
     year, julday, hour, minute, second = unpack(b'<5h', date_time)
     self.assertEqual([
         year == 2005, julday == 353, hour == 15, minute == 7, second == 54
     ], 5 * [True])
     # Read and set zero time.
     su = _read_su(file)
     su[0].stats.starttime = UTCDateTime(0)
     with NamedTemporaryFile() as tf:
         outfile = tf.name
         _write_su(su, outfile)
         # Check the new date.
         with open(outfile, 'rb') as f:
             f.seek(156, 0)
             date_time = f.read(10)
     year, julday, hour, minute, second = unpack(b'<5h', date_time)
     self.assertEqual(
         [year == 0, julday == 0, hour == 0, minute == 0, second == 0],
         5 * [True])
Esempio n. 4
0
 def test_writing_starttime_timestamp_0(self):
     """
     If the starttime of the Trace is UTCDateTime(0) it will be interpreted
     as a missing starttime is not written. Test if this holds True.
     """
     file = os.path.join(self.path, '1.sgy_first_trace')
     # This file has a set date!
     with open(file, 'rb') as f:
         f.seek(3600 + 156, 0)
         date_time = f.read(10)
     year, julday, hour, minute, second = unpack(b'>5h', date_time)
     self.assertEqual([year == 2005, julday == 353, hour == 15, minute == 7,
                       second == 54], 5 * [True])
     # Read and set zero time.
     segy = _read_segy(file)
     segy.stats.textual_file_header = \
         _patch_header(segy.stats.textual_file_header)
     segy[0].stats.starttime = UTCDateTime(0)
     with NamedTemporaryFile() as tf:
         outfile = tf.name
         _write_segy(segy, outfile)
         # Check the new date.
         with open(outfile, 'rb') as f:
             f.seek(3600 + 156, 0)
             date_time = f.read(10)
     year, julday, hour, minute, second = unpack(b'>5h', date_time)
     self.assertEqual([year == 0, julday == 0, hour == 0, minute == 0,
                       second == 0], 5 * [True])
     # The same for SU.
     file = os.path.join(self.path, '1.su_first_trace')
     # This file has a set date!
     with open(file, 'rb') as f:
         f.seek(156, 0)
         date_time = f.read(10)
     year, julday, hour, minute, second = unpack(b'<5h', date_time)
     self.assertEqual([year == 2005, julday == 353, hour == 15, minute == 7,
                       second == 54], 5 * [True])
     # Read and set zero time.
     su = _read_su(file)
     su[0].stats.starttime = UTCDateTime(0)
     with NamedTemporaryFile() as tf:
         outfile = tf.name
         _write_su(su, outfile)
         # Check the new date.
         with open(outfile, 'rb') as f:
             f.seek(156, 0)
             date_time = f.read(10)
     year, julday, hour, minute, second = unpack(b'<5h', date_time)
     self.assertEqual([year == 0, julday == 0, hour == 0, minute == 0,
                       second == 0], 5 * [True])
Esempio n. 5
0
 def test_writing_modified_date(self):
     """
     Tests if the date in Trace.stats.starttime is correctly written in SU
     and SEGY files.
     """
     # Define new date!
     new_date = UTCDateTime(2010, 7, 7, 2, 2, 2)
     with NamedTemporaryFile() as tf:
         outfile = tf.name
         # Test for SEGY.
         file = os.path.join(self.path, 'example.y_first_trace')
         segy = _read_segy(file)
         segy[0].stats.starttime = new_date
         _write_segy(segy, outfile)
         segy_new = _read_segy(outfile)
         self.assertEqual(new_date, segy_new[0].stats.starttime)
         # Test for SU.
         file = os.path.join(self.path, '1.su_first_trace')
         su = _read_su(file)
         su[0].stats.starttime = new_date
         _write_su(su, outfile)
         su_new = _read_su(outfile)
     self.assertEqual(new_date, su_new[0].stats.starttime)
Esempio n. 6
0
 def test_writingModifiedDate(self):
     """
     Tests if the date in Trace.stats.starttime is correctly written in SU
     and SEGY files.
     """
     # Define new date!
     new_date = UTCDateTime(2010, 7, 7, 2, 2, 2)
     with NamedTemporaryFile() as tf:
         outfile = tf.name
         # Test for SEGY.
         file = os.path.join(self.path, 'example.y_first_trace')
         segy = _read_segy(file)
         segy[0].stats.starttime = new_date
         _write_segy(segy, outfile)
         segy_new = _read_segy(outfile)
         self.assertEqual(new_date, segy_new[0].stats.starttime)
         # Test for SU.
         file = os.path.join(self.path, '1.su_first_trace')
         su = _read_su(file)
         su[0].stats.starttime = new_date
         _write_su(su, outfile)
         su_new = _read_su(outfile)
     self.assertEqual(new_date, su_new[0].stats.starttime)