예제 #1
0
 def test_convert_units(self):
     """
     Should convert header units to plot units.
     """
     fig = plt.figure()
     ax = fig.add_subplot(111)
     splt = SEGYPlotManager(ax, self.segy)
     # should correctly perform unit conversions for distance
     splt.DISTANCE_UNIT = 'km'
     self.assertEqual(splt._convert_units('offset', [1000]), [1])
     # should correctly perform unit conversions for time
     splt.TIME_UNIT = 's'
     self.assertEqual(splt._convert_units('delay', [1000]), [1]) 
예제 #2
0
 def test_get_units(self):
     """
     Should return (segy units, plot units) or None.
     """
     fig = plt.figure()
     ax = fig.add_subplot(111)
     splt = SEGYPlotManager(ax, self.segy)
     splt.DISTANCE_UNIT = 'distance_unit_marker'
     splt.TIME_UNIT = 'time_unit_marker'
     for key in TRACE_HEADER_KEYS:
         if key in splt.SEGY_TIME_UNITS:
             # should return TIME_UNIT for a time attribute
             self.assertEqual(splt._get_units(key)[1],
                              'time_unit_marker')
         elif key in splt.SEGY_DISTANCE_UNITS:
             # should return DISTANCE_UNIT for a distance attribute
             self.assertEqual(splt._get_units(key)[1],
                              'distance_unit_marker')
         else:
             # should return None values are unitless
             self.assertEqual(splt._get_units(key), None)
예제 #3
0
 def test_get_header_value(self):
     """
     Should be able to use aliases to get unit-converted values 
     from headers.
     """
     fig = plt.figure()
     ax = fig.add_subplot(111)
     splt = SEGYPlotManager(ax, self.segy)
     # should return exact header values when convert_units=False
     tr = self.segy.traces[0]
     for alias in splt.SEGY_HEADER_ALIASES:
         key = splt.SEGY_HEADER_ALIASES[alias]
         value = splt.get_header_value(tr.header, alias,
                                        convert_units=False)
         _value = tr.header.__getattribute__(key)
         self.assertEqual(value, _value)
     # default should return header values in the plot units
     splt.DISTANCE_UNIT = 'km'
     alias = 'offset'
     key = splt.SEGY_HEADER_ALIASES[alias]
     scaled_value = splt.get_header_value(tr.header, alias)
     header_value = tr.header.__getattribute__(key)
     self.assertEqual(np.round(scaled_value, decimals=3), 
                      header_value/1000.)