[obspy-users] Align waveform plots to p pick time

Reiter, Franz Franz.Reiter at uibk.ac.at
Thu Feb 16 10:49:15 CET 2017


Dear collegues!

I want to thank you for your replies and your suggestions.

A collegue from the University of Trieste replied directly to me with a python script with the following work flow which is similar to the suggestions I received via the Obspy list:

1. put all mseed files which should be plot together into one folder
2. iterate through all files and within this folder, read into streams and cut all to the desired length, starting with the p pick time and write cut streams to a second directory
3. now iterate through the cut streams:
Read trace of interest (e.g. "HHZ") 
filter
fill an np array with the data, starting at zero time, amplitudes normalized
add subplot to plot array of matplotlib.pyplot

4. finally show plot/subplots on screen or write to graphics output file

The script basically runs but problems still exist due to minimal time shifts (0.0003 seconds) which can appear in the start time of some traces. This causes matplotlib.pyplot to rise an error because of the small shift in the x axis. I will be trying to find out if there is a way to force the trim function to avoid these shifts.

Best regards
Franz Reiter

-----Original Message-----
From: obspy-users-bounces at lists.swapbytes.de [mailto:obspy-users-bounces at lists.swapbytes.de] On Behalf Of obspy-users-request at lists.swapbytes.de
Sent: Mittwoch, 15. Februar 2017 12:00
To: obspy-users at lists.swapbytes.de
Subject: obspy-users Digest, Vol 75, Issue 8

Send obspy-users mailing list submissions to
	obspy-users at lists.swapbytes.de

To subscribe or unsubscribe via the World Wide Web, visit
	http://lists.swapbytes.de/mailman/listinfo/obspy-users
or, via email, send a message with subject or body 'help' to
	obspy-users-request at lists.swapbytes.de

You can reach the person managing the list at
	obspy-users-owner at lists.swapbytes.de

When replying, please edit your Subject line so it is more specific than "Re: Contents of obspy-users digest..."


Today's Topics:

   1. Re: obspy-users Digest, Vol 75, Issue 7 (Saeed Soltani Moghadam)
   2. Re: Align waveform plots to p pock time (Peter Schmidt)


----------------------------------------------------------------------

Message: 1
Date: Tue, 14 Feb 2017 14:48:13 +0330
From: Saeed Soltani Moghadam <saeed.sltm at gmail.com>
To: obspy-users at lists.swapbytes.de
Subject: Re: [obspy-users] obspy-users Digest, Vol 75, Issue 7
Message-ID:
	<CAFpFS9L9MGCzi3yyQynYQtVajHVozoO=QP19ZO_TWB2BjLgcTQ at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Dear Franz
I think the easiest way is to use matplotlib and plot data for each channel of each EQ in a spcefic subplot. First yoy need to extrac waveforms time-series as they can be achived using tr.data (lets tr be a trace) then you need a for loop over entire traces and plot all them to ghether in one subplot (all traces for one spcefic channel and different EQs).

On 14 Feb 2017 14:30, <obspy-users-request at lists.swapbytes.de> wrote:

> Send obspy-users mailing list submissions to
>         obspy-users at lists.swapbytes.de
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://lists.swapbytes.de/mailman/listinfo/obspy-users
> or, via email, send a message with subject or body 'help' to
>         obspy-users-request at lists.swapbytes.de
>
> You can reach the person managing the list at
>         obspy-users-owner at lists.swapbytes.de
>
> When replying, please edit your Subject line so it is more specific 
> than "Re: Contents of obspy-users digest..."
>
>
> Today's Topics:
>
>    1. Align waveform plots to p pock time (Reiter, Franz)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 14 Feb 2017 08:15:43 +0000
> From: "Reiter, Franz" <Franz.Reiter at uibk.ac.at>
> To: "users at obspy.org" <users at obspy.org>
> Subject: [obspy-users] Align waveform plots to p pock time
> Message-ID:
>         <B43E97EB84E76A4D939F6831FCA826AD8BC9F439 at XMBX2.uibk.ac.at>
> Content-Type: text/plain; charset="us-ascii"
>
> Dear Collegues!
>
> I would like to compare waveform data (mseed files) from different 
> earthquake events to each other in order to show that repeating 
> earthquakes at the same fault have similar waveforms.
> I am looking for a way to overlay several waveform files in one plot, 
> aligned at p-wave onset or plot several waveforms one below the other, 
> aligned with the p-onset time I have picked for each event.
>
> Has anyone experience producing plots like that with Obspy or an idea 
> how this could be done?
>
> Thank you in advance!
> Franz
>
>
>
> Franz Reiter
> PhD Student
> Institute for Geology
> University of Innsbruck
> Austria
> -------------- next part -------------- An HTML attachment was 
> scrubbed...
> URL: <http://lists.swapbytes.de/pipermail/obspy-users/
> attachments/20170214/4face89a/attachment-0001.html>
>
> ------------------------------
>
> _______________________________________________
> obspy-users mailing list
> obspy-users at lists.swapbytes.de
> http://lists.swapbytes.de/mailman/listinfo/obspy-users
>
> End of obspy-users Digest, Vol 75, Issue 7
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.swapbytes.de/pipermail/obspy-users/attachments/20170214/cded6a4e/attachment-0001.html>

------------------------------

Message: 2
Date: Wed, 15 Feb 2017 10:30:54 +0100
From: Peter Schmidt <peter.schmidt at geo.uu.se>
To: <users at obspy.org>
Subject: Re: [obspy-users] Align waveform plots to p pock time
Message-ID: <a9aab01a-ab38-d9d6-2b4e-b1c98ff6ff7e at geo.uu.se>
Content-Type: text/plain; charset="windows-1252"; Format="flowed"

Hi Franz


Don't think there's dedicated method to do so (but then again if I'm wrong it wouldn't be the first time...), but in principle what you want to achieve should should be doable in obspy. One way (perhaps not the
best) would be to

1. read in all the wave forms into a stream object (see obspy.read() ) 2. select a reference waveform and compute the time difference between the p-picks for all the other waveforms 3. shift the start time of all waveforms by the time difference computed under point 2., i.e. adjust stream.traces[i].stats.starttime where stream is the object created under point 1.
4. set the offset of all waveforms to be equal
(stream.traces[i].stats.distance)
5. Plot the waveforms using stream.plot(type='section') (for some more info see https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial.html
and
https://docs.obspy.org/packages/autogen/obspy.core.stream.Stream.plot.html#obspy.core.stream.Stream.plot)

Now, I have not tested the above recipe but in principle it should work


\p


On 14/02/17 09:15, Reiter, Franz wrote:
>
> Dear Collegues!
>
> I would like to compare waveform data (mseed files) from different 
> earthquake events to each other in order to show that repeating 
> earthquakes at the same fault have similar waveforms.
>
> I am looking for a way to overlay several waveform files in one plot, 
> aligned at p-wave onset or plot several waveforms one below the other, 
> aligned with the p-onset time I have picked for each event.
>
> Has anyone experience producing plots like that with Obspy or an idea 
> how this could be done?
>
> Thank you in advance!
>
> Franz
>
> Franz Reiter
>
> PhD Student
>
> Institute for Geology
>
> University of Innsbruck
>
> Austria
>
>
>
> _______________________________________________
> obspy-users mailing list
> obspy-users at lists.swapbytes.de
> http://lists.swapbytes.de/mailman/listinfo/obspy-users

--
********************************************************************************
Peter Schmidt                                      Tel: +46-18-4712259
Swedish National Seismic Network (SNSN)         Mobile: +46-73-3190975
Dept. of Earth Sciences:geophysics              e-mail: peter.schmidt at geo.uu.se
Uppsala University
Villavagen 16
SE-75236 Uppsala
********************************************************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.swapbytes.de/pipermail/obspy-users/attachments/20170215/2ac3bef8/attachment-0001.html>

------------------------------

_______________________________________________
obspy-users mailing list
obspy-users at lists.swapbytes.de
http://lists.swapbytes.de/mailman/listinfo/obspy-users

End of obspy-users Digest, Vol 75, Issue 8
******************************************


More information about the obspy-users mailing list