stream plot section: st.plot(type='section')

Dear All,

Having three issues with stream plot st.plot(type=‘section’) in FC20 linux, with obspy0.9.2

import obspy
print obspy.version
0.9.2

  1. The traces are assumed to have the same start time. (There is no relative shifting between traces, as in plot(type=‘normal’). Easy to handle if known, but If this is a feature, not a bug, it would be good to state this in the docs?

  2. scaling/normalization: in plot(type=‘normal’) the parameter is equal_scale. equal_scale works fine, but In plot(type=‘section’) the parameter is norm. (Why not use equal_scale in section?) But I can’t get norm to do anything, despite:

def __sectNormalizeTraces(self):
“”"
This helper function normalizes the traces
“”"
self._tr_normfac = np.ones(self._tr_num)
if self.sect_norm_method == ‘trace’:

Normalize against each traces’ maximum

for tr in range(self._tr_num):
self._tr_normfac[tr] = np.abs(self._tr_data[tr]).max()
elif self.sect_norm_method == ‘stream’:

Normalize the whole stream

self._tr_normfac.fill(self._tr_max_count_glob)
else:
msg = ‘Define a normalisation method. Valid normalisations’ +
‘are 'trace', 'stream'. See documentation.’
raise ValueError(msg)

self._plot_init = False

but given the fact that I don’t get msg even if I say:

plot(type=‘section’, norm=‘bla’)

makes me think that it is not used at all. I don’t understand this because it appears to be called here:

def plotSection(self, *args, **kwargs):
“”"
Plots multiple waveforms as a record section on a single plot.
“”"

Initialise data and plot

self.__sectInitTraces()

self.__sectInitPlot()

where:

def __sectInitPlot(self):
“”"
Function initialises plot all the illustration is done by
self.plotSection()
“”"
ax = self.fig.gca()

Calculate normalizing factor

self.__sectNormalizeTraces()

Calculate scaling factor

self.__sectScaleTraces()

ax.plot() prefered over containers

for _tr in range(self._tr_num):

Scale, normalize and shift traces by offset

for plotting

ax.plot(self._tr_data[_tr] / self._tr_normfac[_tr]

  • (1. / self._sect_scale)
  • self._tr_offsets_norm[_tr],
    self._tr_times[_tr])
    self._sect_plot_init = True

Can ‘section’ use the same scheme as in type=‘normal’, where equal_scale does work?

  1. Finally, I don’t know why, but in type=‘section’, you need a bandpass of sorts. At least in my example, AND in the one on the gallery waveform_plotting_tutorial_6:

without the filter:

#st.filter(‘bandpass’, freqmin=0.1, freqmax=10)

I get the following error when using st.plot(type=‘section’) by running python “waveform_plotting_tutorial_6.py”:

Traceback (most recent call last):
File “”, line 1, in
File “/home/kasper/Downloads/waveform_plotting_tutorial_6.py”, line 32, in
time_down=True, linewidth=.25, grid_linewidth=.25)
File “/usr/lib/python2.7/site-packages/obspy-0.9.2-py2.7-linux-x86_64.egg/obspy/core/stream.py”, line 1058, in plot
return waveform.plotWaveform(*args, **kwargs)
File “/usr/lib/python2.7/site-packages/obspy-0.9.2-py2.7-linux-x86_64.egg/obspy/imaging/waveform.py”, line 253, in plotWaveform
self.plotSection(*args, **kwargs)
File “/usr/lib/python2.7/site-packages/obspy-0.9.2-py2.7-linux-x86_64.egg/obspy/imaging/waveform.py”, line 1114, in plotSection
self.__sectInitTraces()
File “/usr/lib/python2.7/site-packages/obspy-0.9.2-py2.7-linux-x86_64.egg/obspy/imaging/waveform.py”, line 1229, in __sectInitTraces
self.stream[_tr].data, self.max_npts)
File “/usr/lib64/python2.7/site-packages/scipy/signal/signaltools.py”, line 1292, in resample
X = fft(x, axis=axis)
File “/usr/lib64/python2.7/site-packages/scipy/fftpack/basic.py”, line 222, in fft
raise ValueError(“type %s is not supported” % tmp.dtype)
ValueError: type >f4 is not supported

Why is there an fft involved in plotting traces in a section? There doesn’t seem to be one in st.plot(type=‘normal’), which runs with and without the bandpass filter…

Thanks for your help,
kasper

Hi Kasper,

this appears to be a bit more complex so I opened an issue on GitHub to be able to track it easier: https://github.com/obspy/obspy/issues/913

Thanks for your report and all the best!

Lion

Hi Kasper,

for customized plots it's probably better/faster to build up the plot
using matplotlib from scratch. There's pretty good support also for
having timestamps on one axis.

See this mail from march for a start..
http://lists.swapbytes.de/archives/obspy-users/2014-March/001300.html

best,
Tobias

Thanks, Lion and Tobias:

I understand – and agree – that for full control and flexibility in plotting we should write custom scripts using matplotlib. (I do this for research purposes.) However, for teaching students new to python and obspy it would be nice for “type=‘section’” to handle what I think are the basics, the way you intended. I will continue to look at these issues too.

Thanks again for all your hard work on this!
Kasper