How do I plot a shot gather that has 24 traces?

How do I plot a shot gather that has 24 traces?

Check here: Waveform Plotting Tutorial — ObsPy 1.3.0.post0+271.g4fcb7687d7.obspy.master documentation

1 Like

Umm, st.plot(type = ‘section’) doesn’t work! It returns the following error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File ~\anaconda3\envs\obspy\lib\site-packages\obspy\core\util\attribdict.py:142, in AttribDict.__getattr__(self, name, default)
    141 try:
--> 142     return self.__getitem__(name, default)
    143 except KeyError as e:

File ~\anaconda3\envs\obspy\lib\site-packages\obspy\core\trace.py:232, in Stats.__getitem__(self, key, default)
    231 else:
--> 232     return super(Stats, self).__getitem__(key, default)

File ~\anaconda3\envs\obspy\lib\site-packages\obspy\core\util\attribdict.py:97, in AttribDict.__getitem__(self, name, default)
     96 try:
---> 97     return self.__dict__[name]
     98 except KeyError:
     99     # check if we got any default value given at class level

KeyError: 'distance'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
File ~\anaconda3\envs\obspy\lib\site-packages\obspy\imaging\waveform.py:1170, in WaveformPlotting.__sect_init_traces(self)
   1169     for _i, tr in enumerate(self.stream):
-> 1170         self._tr_offsets[_i] = tr.stats.distance
   1171 except Exception:

File ~\anaconda3\envs\obspy\lib\site-packages\obspy\core\util\attribdict.py:144, in AttribDict.__getattr__(self, name, default)
    143 except KeyError as e:
--> 144     raise AttributeError(e.args[0])

AttributeError: distance

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
Input In [9], in <cell line: 1>()
----> 1 st.plot(type = 'section')

File ~\anaconda3\envs\obspy\lib\site-packages\obspy\core\stream.py:1155, in Stream.plot(self, *args, **kwargs)
   1153 from obspy.imaging.waveform import WaveformPlotting
   1154 waveform = WaveformPlotting(stream=self, *args, **kwargs)
-> 1155 return waveform.plot_waveform(*args, **kwargs)

File ~\anaconda3\envs\obspy\lib\site-packages\obspy\imaging\waveform.py:271, in WaveformPlotting.plot_waveform(self, *args, **kwargs)
    269     self.plot_day(*args, **kwargs)
    270 elif self.type == 'section':
--> 271     self.plot_section(*args, **kwargs)
    272 else:
    273     self.plot(*args, **kwargs)

File ~\anaconda3\envs\obspy\lib\site-packages\obspy\imaging\waveform.py:1075, in WaveformPlotting.plot_section(self, *args, **kwargs)
   1071 """
   1072 Plots multiple waveforms as a record section on a single plot.
   1073 """
   1074 # Initialise data and plot
-> 1075 self.__sect_init_traces()
   1076 ax, lines = self.__sect_init_plot()
   1078 # Setting up line properties

File ~\anaconda3\envs\obspy\lib\site-packages\obspy\imaging\waveform.py:1175, in WaveformPlotting.__sect_init_traces(self)
   1171     except Exception:
   1172         msg = 'trace.stats.distance undefined ' +\
   1173               '(set before plotting [in m], ' +\
   1174               'or use the ev_coords argument)'
-> 1175         raise ValueError(msg)
   1176 else:
   1177     # Define offset as degree from epicenter
   1178     try:

ValueError: trace.stats.distance undefined (set before plotting [in m], or use the ev_coords argument)

<Figure size 1000x600 with 0 Axes>

tr.stats gives the following, the units is in meters

`network: 
         station: 
        location: 
         channel: 
       starttime: 1970-01-01T00:00:00.000000Z
         endtime: 1970-01-01T00:00:01.999750Z
   sampling_rate: 4000.0
           delta: 0.00025
            npts: 8000
           calib: 1.0
         _format: SEG2
            seg2: AttribDict({'TRACE_SORT': 'AS_ACQUIRED', 'UNITS': 'METERS', 'CDP_NUMBER': '0', 'CDP_TRACE': '0', 'DELAY': '0', 'DIGITAL_HIGH_CUT_FILTER': '0', 'DIGITAL_LOW_CUT_FILTER': '0', 'RECEIVER_GEOMETRY': '2.500000 0.000000 0.000000', 'RECEIVER_LOCATION': '2.500000 0.000000 0.000000', 'RECEIVER_STATION_NUMBER': '0', 'SAMPLE_INTERVAL': '0.00025', 'SHOT_SEQUENCE_NUMBER': '1', 'SOURCE_LOCATION': '0.000000 0.000000 0.000000', 'SOURCE_STATION_NUMBER': '0'})`

If your data is segy i recomend you using seismic unix, its free and its very good for plotting and manipulating data.

1 Like

Please do not spam the board with multiple topics linking to the same topic.

The error message seems fairly explanatory. Did you do as the error message suggests:

ValueError: trace.stats.distance undefined (set before plotting [in m], or use the ev_coords argument)

Your stats seem to show that tr.stats.distance is not set. As the error message says, set tr.stats.distance before plotting.

2 Likes