Skip to content

Commit 92ddf7a

Browse files
committed
Improved trace plotting
- Do not zero-pad traces to common length when plotting, so that missing data at beginning or at the end can be easily detected - Plot noise and signal windows separately for each component Fixes #21
1 parent dc4af75 commit 92ddf7a

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

CHANGELOG.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ Earthquake source parameters from P- or S-wave displacement spectra
4848
- Possibility of defining the number of sigmas for uncertainties on event means
4949
and weighted means
5050

51+
### Plotting
52+
53+
- Do not zero-pad traces to common length when plotting, so that missing data
54+
at beginning or at the end can be easily detected (see [#21])
55+
- Plot noise and signal windows separately for each component (see [#21])
56+
5157
### Config file
5258

5359
- Config file section `AVERAGES PARAMETERS` renamed to
@@ -221,7 +227,9 @@ Note that v1.5 is no more compatible with Python 2!
221227
- Compute errors for all station parameters
222228
- Compute weighted averages for all event parameters (except radiated energy)
223229
- Compute spectral residuals using weighted average spectral parameters
224-
- Plotting:
230+
231+
### v1.5: Plotting
232+
225233
- Source parameter box plots to evaluate parameter dispersion across stations
226234
and visually detect outliers
227235
- Misfit plot (2D and 1D) when using grid sampling
@@ -420,3 +428,4 @@ Initial Python port.
420428
[#15]: https://github.com/SeismicSource/sourcespec/issues/15
421429
[#16]: https://github.com/SeismicSource/sourcespec/issues/16
422430
[#18]: https://github.com/SeismicSource/sourcespec/issues/18
431+
[#21]: https://github.com/SeismicSource/sourcespec/issues/21

sourcespec/ssp_plot_traces.py

+21-7
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,27 @@ def _freq_string(freq):
206206

207207
def _plot_trace(config, trace, ntraces, tmax,
208208
ax, ax_text, trans, trans3, path_effects):
209+
# Origin and height to draw vertical patches for noise and signal windows
210+
rectangle_patch_origin = 0
211+
rectangle_patch_height = 1
209212
orientation = trace.stats.channel[-1]
210213
if orientation in config.vertical_channel_codes:
211214
color = 'purple'
215+
if ntraces > 1:
216+
rectangle_patch_origin = 1./3
217+
rectangle_patch_height = 1./3
212218
if orientation in config.horizontal_channel_codes_1:
213219
color = 'green'
214220
if ntraces > 1:
215221
trace.data = (trace.data / tmax - 1) * tmax
222+
rectangle_patch_origin = 0
223+
rectangle_patch_height = 1./3
216224
if orientation in config.horizontal_channel_codes_2:
217225
color = 'blue'
218226
if ntraces > 1:
219227
trace.data = (trace.data / tmax + 1) * tmax
228+
rectangle_patch_origin = 2./3
229+
rectangle_patch_height = 1./3
220230
# dim out ignored traces
221231
if trace.stats.ignore:
222232
alpha = 0.3
@@ -249,9 +259,11 @@ def _plot_trace(config, trace, ntraces, tmax,
249259
try:
250260
N1 = trace.stats.arrivals['N1'][1] - trace.stats.starttime
251261
N2 = trace.stats.arrivals['N2'][1] - trace.stats.starttime
252-
rect = patches.Rectangle((N1, 0), width=N2-N1, height=1,
253-
transform=trans, color='#eeeeee',
254-
zorder=-1)
262+
rect = patches.Rectangle(
263+
(N1, rectangle_patch_origin),
264+
width=N2-N1, height=rectangle_patch_height,
265+
transform=trans, color='#eeeeee',
266+
zorder=-1)
255267
ax.add_patch(rect)
256268
except KeyError:
257269
pass
@@ -262,9 +274,11 @@ def _plot_trace(config, trace, ntraces, tmax,
262274
elif config.wave_type[0] == 'P':
263275
t1 = trace.stats.arrivals['P1'][1] - trace.stats.starttime
264276
t2 = trace.stats.arrivals['P2'][1] - trace.stats.starttime
265-
rect = patches.Rectangle((t1, 0), width=t2-t1, height=1,
266-
transform=trans, color='yellow',
267-
alpha=0.5, zorder=-1)
277+
rect = patches.Rectangle(
278+
(t1, rectangle_patch_origin),
279+
width=t2-t1, height=rectangle_patch_height,
280+
transform=trans, color='yellow',
281+
alpha=0.5, zorder=-1)
268282
ax.add_patch(rect)
269283
if not ax_text:
270284
text_y = 0.01
@@ -308,7 +322,7 @@ def _trim_traces(config, st):
308322
for trace in st:
309323
t1 = (trace.stats.arrivals['P'][1] - config.noise_pre_time)
310324
t2 = (trace.stats.arrivals['S'][1] + 3 * config.win_length)
311-
trace.trim(starttime=t1, endtime=t2, pad=True, fill_value=0)
325+
trace.trim(starttime=t1, endtime=t2)
312326

313327

314328
def plot_traces(config, st, ncols=None, block=True):

0 commit comments

Comments
 (0)