obspy.clients.arclink.Client.get_inventory

Dear obspy-users,

the function obspy.clients.arclink.Client.get_inventory returns a dictionary of inventory information.

Is there an easy and fast way to build a stationxml file from this dictionary?

Thanks for your help,

Gesa Petersen

Hi Gesa,

not from the `get_inventory()` method as this already parses the
original Arclink XML (which ObsPy could also read by now...) but you can
do it like this:

import io
import obspy
from obspy.clients.arclink import Client

client = Client(user="ObsPy")
t = obspy.UTCDateTime(2009, 1, 1)

with io.BytesIO() as buf:
    client.save_response(buf, "BW", "MANZ", "", "*", t, t+1, format="SEED")
    buf.seek(0, 0)
    inv = obspy.read_inventory(buf)

inv.write("out.xml", format="stationxml")

We could add this to the arclink client of course but the arclink
protocol will soon be deprecated so it is not really worthwhile for us
to do this.

In any case you should consider using the new ObsPy routing client:

https://docs.obspy.org/packages/obspy.clients.fdsn.html#basic-routing-clients-usage

This internally uses the FDSN web services which will continue to work
once arclink has been deprecated.

Cheers!

Lion

Thanks for the suggestions!