[obspy-users] Merge two events in one with control on preferred_*

Fred Massin fred.massin at gmail.com
Thu Apr 6 12:43:11 CEST 2017


Hi Lion,

This is not so hard...

Thank you very much !

Regards

Fred

2017-04-06 9:59 GMT+02:00 Lion Krischer <krischer at geophysik.uni-muenchen.de>
:

> Hi Fred,
>
> this is a bit of a special use case so I am not sure that there is a
> proper way to do it. In any case - your code is basically correct - don't
> use the update() method.
>
>
> Note that you don't have to loop to add all origins of event 2 to event 1:
>
> >>> ev1.origins.extend(ev2.origins)
>
> and instead of directly copying the preferred origin id you could also
> manually pick the preferred origin:
>
> >>> ev1.preferred_origin_id = ev1.origins[-1].resource_id
>
>
> If you have any ideas on how to make this easier or more intuitive let us
> know. I think this is just a consequence of the fairly complex data model
> of ObsPy which is modelled after QuakeML.
>
>
> Cheers!
>
> Lion
>
>
>
>
> On 05.04.17 12:20, Fred Massin wrote:
>
> Hello
>
> What is the proper way to merge the origins, magnitudes (and all other
> elements if possible) of two events coming from different 2 catalogs. And
> how to define manually the preferred [origin, magnitude, etc] to pick
> between the two versions ?
>
> Say, I would like to add all origins and preferred origin of [event j,
> catalog_2] to a copy of [event i, catalog_1] I have made some experiments
> using :
>
> merges = obspy.core.event.catalog.Catalog()
> merges.events.append(catalog_1.events[ i ])
>
> for elt in catalog_2.events[ j ].origins:
>      merges.events[-1].origins.append(elt)
>
> merges.events[-1].preferred_origin_id = catalog_2.events[ j
> ].preferred_origin_id
>
> But I feel like going the wrong way... should I use the Event.update
> method ? If yes, how ?
>
> Regards
>
> Fred
> ◸*Fr**édérick Massin            *+41 44 63 - 38276 | Git
> <https://github.com/FMassin> | Blog <http://fredmassin.blogspot.com/> |
> Publications <https://www.researchgate.net/profile/Frederick_Massin>.
>
>
> _______________________________________________
> obspy-users mailing listobspy-users at lists.swapbytes.dehttp://lists.swapbytes.de/mailman/listinfo/obspy-users
>
>
>
> _______________________________________________
> obspy-users mailing list
> obspy-users at lists.swapbytes.de
> http://lists.swapbytes.de/mailman/listinfo/obspy-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.swapbytes.de/pipermail/obspy-users/attachments/20170406/fae7d707/attachment.html>


More information about the obspy-users mailing list