# Best way to store theoretical arrival times using obspy Event/Pick/Arrival classes

**URL:** <https://discourse.obspy.org/t/best-way-to-store-theoretical-arrival-times-using-obspy-event-pick-arrival-classes/816>\
**Category:** Users Mailing List Archive\
**Tags:** archive\
**Created:** [January 18, 2019, 7:04pm UTC](https://discourse.obspy.org/t/best-way-to-store-theoretical-arrival-times-using-obspy-event-pick-arrival-classes/816 "2019-01-18T19:04:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Baillard](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/c/0ea827/32.png) [@Christian\_Baillard](https://discourse.obspy.org/u/Christian_Baillard)\
**Post date:** [January 18, 2019, 7:04pm UTC](https://discourse.obspy.org/t/best-way-to-store-theoretical-arrival-times-using-obspy-event-pick-arrival-classes/816/1 "2019-01-18T19:04:33Z")

</div>

Dear Obspy-users,

Couple of months ago I wrote some functions to plot my picks on top of a stream.plot(), I was happy with that and it worked quite well. But I also want to plot the theoretical arrival times for picks that are not associated to manual or auto picks.

The problem is that the Pick object doesn’t have a “theoretical” arrival time in addition to Pick.time. The theoretical arrival time is stored in the Arrival.residual attributes, but it implies that a Pick.time has already been defined.

How can I specify in the Obspy/QuakeML convention that I have a theoretical pick with no auto/manual pick associated to it? Should I edit the Pick.comment or Pick.evaluation\_mode to specify “theoretical” and add a Arrival.residual of “-999” or something like that?

Thanks a lot for your upcoming help,

---

<div class="post-metadata">

**Author:** ![LionKrischer](https://discourse.obspy.org/user_avatar/discourse.obspy.org/lionkrischer/32/219_2.png) [@LionKrischer](https://discourse.obspy.org/u/LionKrischer)\
**Post date:** [January 22, 2019, 9:45am UTC](https://discourse.obspy.org/t/best-way-to-store-theoretical-arrival-times-using-obspy-event-pick-arrival-classes/816/2 "2019-01-22T09:45:04Z")

</div>

Hi Christian,

our internal format for all things related events are based on QuakeML so we are limited by its definition. The reason for this is that we want to have a format which can retain all the information. You thus cannot set the evaluation mode to “theoretical”. You could of course set the residual to some magical number and then internally decide that its a theoretical pick. Another option would be to add a custom tag to the picks as described here:

These can be serialized to valid QuakeML files and be read again.

All the best,

Lion

---

<div class="post-metadata">

**Author:** ![mth](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/m/dc4da7/32.png) [@mth](https://discourse.obspy.org/u/mth)\
**Post date:** [January 22, 2019, 2:21pm UTC](https://discourse.obspy.org/t/best-way-to-store-theoretical-arrival-times-using-obspy-event-pick-arrival-classes/816/3 "2019-01-22T14:21:15Z")

</div>

If you’re mainly interested in plotting the theoretical arrival times (as opposed to producing quakeml),  
the way I did this was to create an extras{} dictionary with the P,S times and pass this into  
WaveformPlotting function, which I hacked to plot dotted lines at the arrival times.  
e.g.,

waveform = wp(stream=st, color=‘k’, type=‘relative’, xlabel=‘Seconds’, …, extras=extras)

waveform.plot\_waveform()

If instead you’re interested in adding theoretical arrivals to the quakeml, this can be done  
by adding picks with either a method id or comment set to indicate their (theoretical) source, and  
wrapping these in arrivals.

Or, if you really want to be able to do something like: my\_pick.method=‘Computed using IASP91’ …  
you can extend the obspy pick class like this (to add a method attribute that plays well with obspy attrib dict):

class Pick(obsevent.Pick):

extra\_keys = [‘method’]

def **init** (self, obspy\_obj=None, \*\*kwargs):

\_init\_handler(self, obspy\_obj, \*\*kwargs)

def **setattr** (self, name, value):

\_set\_attr\_handler(self, name, value)

Let me know if any of these are of interest to you and I can send the necessary code.

Cheers,  
-Mike Hagerty  
[m.hagerty@isti.com](mailto:m.hagerty@isti.com)

---

<div class="post-metadata">

**Author:** ![Christian\_BAILLARD1](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/c/df788c/32.png) [@Christian\_BAILLARD1](https://discourse.obspy.org/u/Christian_BAILLARD1)\
**Post date:** [January 22, 2019, 5:14pm UTC](https://discourse.obspy.org/t/best-way-to-store-theoretical-arrival-times-using-obspy-event-pick-arrival-classes/816/4 "2019-01-22T17:14:11Z")

</div>

Hi Lion,

Thanks for the advice. I didn’t know about the .extra attribute that could be added, that’s great! I’ll see which one of the two options I’ll use.

Best,

Ch.

---

<div class="post-metadata">

**Author:** ![Christian\_BAILLARD1](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/c/df788c/32.png) [@Christian\_BAILLARD1](https://discourse.obspy.org/u/Christian_BAILLARD1)\
**Post date:** [January 22, 2019, 9:41pm UTC](https://discourse.obspy.org/t/best-way-to-store-theoretical-arrival-times-using-obspy-event-pick-arrival-classes/816/5 "2019-01-22T21:41:07Z")

</div>

Thanks Mike, ideally I would like all the info in the quakeml for exporting purposes also. I’ll probably use the extra feature advised by Lion or edit the Pick.comment as you mentioned to specify that the pick is “theoretical”. This would also be easier to integrate in my plot\_picks() function, I guess.

Thanks again! Ch.
