Coverage for /opt/obspy/update-docs/src/obspy/obspy/imaging/tests/test_waveform : 45%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- The obspy.imaging.waveform test suite. """
""" Test cases for waveform plotting. """ # directory where the test files are located
""" Helper method to create a Stream object that can be used for testing waveform plotting.
Takes the time frame of the Stream to be created and a sampling rate. Any other header information will have to be adjusted on a case by case basis. Please remember to use the same sampling rate for one Trace as merging and plotting will not work otherwise.
This method will create a single sine curve to a first approximation with superimposed 10 smaller sine curves on it.
:return: Stream object """ # Calculate first sine wave. # Superimpose it with a smaller but shorter wavelength sine wave. # To get a thick curve alternate between two curves. # Check if even number and adjust if necessary. data[0::2] = curve data[1::2] = curve + 0.2 else: # Fill dummy header.
""" Data should not be changed when plotting. """ # Use once with straight plotting with random calibration factor # compare with original data # Now with min-max list creation (more than 400000 samples). # compare with original data
""" Plotting of an empty stream should raise a warning. """
""" Plotting of a Stream object, that contains two traces with the same id and different sampling rates should raise an exception. """
def test_plotOneHourManySamples(self): """ Plots one hour, starting Jan 1970.
Uses a frequency of 1000 Hz to get a sample count of over 3 Million and get in the range, that plotting will choose to use a minimum maximum approach to plot the data. """ start = UTCDateTime(0) st = self._createStream(start, start + 3600, 1000.0) filename = 'waveform_one_hour_many_samples.png' st.plot(outfile=os.path.join(self.path, filename))
def test_plotOneHourFewSamples(self): """ Plots one hour, starting Jan 1970.
Uses a frequency of 10 Hz. """ start = UTCDateTime(0) st = self._createStream(start, start + 3600, 10.0) filename = 'waveform_one_hour_few_samples.png' st.plot(outfile=os.path.join(self.path, filename))
def test_plotSimpleGapManySamples(self): """ Plots three hours with a gap.
There are 45 minutes of data at the beginning and 45 minutes of data at the end. """ start = UTCDateTime(0) st = self._createStream(start, start + 3600 * 3 / 4, 500.0) st += self._createStream(start + 2.25 * 3600, start + 3 * 3600, 500.0) filename = 'waveform_simple_gap_many_samples.png' st.plot(outfile=os.path.join(self.path, filename))
def test_plotSimpleGapFewSamples(self): """ Plots three hours with a gap.
There are 45 minutes of data at the beginning and 45 minutes of data at the end. """ start = UTCDateTime(0) st = self._createStream(start, start + 3600 * 3 / 4, 5.0) st += self._createStream(start + 2.25 * 3600, start + 3 * 3600, 5.0) filename = 'waveform_simple_gap_few_samples.png' st.plot(outfile=os.path.join(self.path, filename))
def test_plotComplexGapManySamples(self): """ Plots three hours with a gap.
There are 45 minutes of data at the beginning and 45 minutes of data at the end. """ start = UTCDateTime(0) st = self._createStream(start, start + 3600 * 3 / 4, 500.0) st += self._createStream(start + 2.25 * 3600, start + 3 * 3600, 500.0) st[0].stats.location = '01' st[1].stats.location = '01' temp_st = self._createStream(start + 3600 * 3 / 4, start + 2.25 * 3600, 500.0) temp_st[0].stats.location = '02' st += temp_st filename = 'waveform_complex_gap_many_samples.png' st.plot(outfile=os.path.join(self.path, filename))
def test_plotComplexGapFewSamples(self): """ Plots three hours with a gap.
There are 45 minutes of data at the beginning and 45 minutes of data at the end. """ start = UTCDateTime(0) st = self._createStream(start, start + 3600 * 3 / 4, 5.0) st += self._createStream(start + 2.25 * 3600, start + 3 * 3600, 5.0) st[0].stats.location = '01' st[1].stats.location = '01' temp_st = self._createStream(start + 3600 * 3 / 4, start + 2.25 * 3600, 5.0) temp_st[0].stats.location = '02' st += temp_st filename = 'waveform_complex_gap_few_samples.png' st.plot(outfile=os.path.join(self.path, filename))
def test_plotMultipleTraces(self): """ Plots multiple traces underneath. """ st = read() # 1 trace outfile = os.path.join(self.path, 'waveform_1_trace.png') st[0].plot(outfile=outfile, automerge=False) # 3 traces outfile = os.path.join(self.path, 'waveform_3_traces.png') st.plot(outfile=outfile, automerge=False) # 5 traces st = st[0] * 5 outfile = os.path.join(self.path, 'waveform_5_traces.png') st.plot(outfile=outfile, automerge=False) # 10 traces st = st[0] * 10 outfile = os.path.join(self.path, 'waveform_10_traces.png') st.plot(outfile=outfile, automerge=False) # 10 traces - huge numbers st = st[0] * 10 for i, tr in enumerate(st): # scale data to have huge numbers st[i].data = tr.data * 10 ** i outfile = os.path.join(self.path, 'waveform_10_traces_huge.png') st.plot(outfile=outfile, automerge=False, equal_scale=False) # 10 traces - tiny numbers st = st[0] * 10 for i, tr in enumerate(st): # scale data to have huge numbers st[i].data = tr.data / (10 ** i) outfile = os.path.join(self.path, 'waveform_10_traces_tiny.png') st.plot(outfile=outfile, automerge=False, equal_scale=False) # 20 traces st = st[0] * 20 outfile = os.path.join(self.path, 'waveform_20_traces.png') st.plot(outfile=outfile, automerge=False)
def test_plotWithLabels(self): """ Plots with labels. """ st = read() st.label = u"Title #1 üöä?" st[0].label = 'Hello World!' st[1].label = u'Hällö Wörld & Marß' st[2].label = '*' * 80 outfile = os.path.join(self.path, 'waveform_labels.png') st.plot(outfile=outfile)
if __name__ == '__main__': unittest.main(defaultTest='suite') |