How to read in quakeml file

I have a very simple question. I am completely new to python, and I would like to read in a file written with quakeml. My goal is to write earthquake pick times to a file. I can read the basic data in via read_events, but I suspect there’s more data and I need to invoke quakeml to read. Here’s the script I have written.

from obspy.core.event import read_events
cat = read_events('/Users/derek/Data/Active/MM_local_tomo/ncord_cat_1618.xml')
print(cat)
print(cat.__str__(print_all=True))

from obspy.io.quakeml import _read_quakeml
cat = _read_quakeml('/Users/derek/Data/Active/MM_local_tomo/ncord_cat_1618.xml')
print(cat)

When I do this, I get:

    from obspy.io.quakeml import _read_quakeml
ImportError: cannot import name '_read_quakeml' from 'obspy.io.quakeml' (/Users/derek/opt/anaconda3/lib/python3.9/site-packages/obspy/io/quakeml/__init__.py)

Can you please tell me what I am doing incorrectly? I’m sure it’s something superbasic. Thanks.

Hi @derek you want to use from obspy.io.quakeml.core import _read_quakeml. However, you are better off using read_events.

Like Adam said, there is no reason for you to use _read_quakeml. It is used internally by the high level routing read_events(), so that is all you need.

Thanks, I appreciate your advice to a newcomer!