obspy.core.event.catalog.Catalog.write

Catalog.write(filename, format, **kwargs)[source]

Saves catalog into a file.

Parameters
  • filename (str) – The name of the file to write.

  • format (str) – The file format to use (e.g. "QUAKEML"). See the Supported Formats section below for a list of supported formats.

  • kwargs – Additional keyword arguments passed to the underlying plugin’s writer method.

Example

>>> from obspy import read_events
>>> catalog = read_events()
>>> catalog.write("example.xml", format="QUAKEML")  

Writing single events into files with meaningful filenames can be done e.g. using event.id

>>> for ev in catalog:  
...     filename = str(ev.resource_id) + ".xml"
...     ev.write(filename, format="QUAKEML") 

Supported Formats

Additional ObsPy modules extend the parameters of the write() method. The following table summarizes all known formats with write capability currently available for ObsPy.

Please refer to the Linked Function Call of each module for any extra options available.

Format

Used Module

Linked Function Call

CMTSOLUTION

obspy.io.cmtsolution

obspy.io.cmtsolution.core._write_cmtsolution()

CNV

obspy.io.cnv

obspy.io.cnv.core._write_cnv()

HYPODDPHA

obspy.io.hypodd

obspy.io.hypodd.pha._write_pha()

JSON

obspy.io.json

obspy.io.json.core._write_json()

KML

obspy.io.kml

obspy.io.kml.core._write_kml()

NLLOC_OBS

obspy.io.nlloc

obspy.io.nlloc.core.write_nlloc_obs()

NORDIC

obspy.io.nordic

obspy.io.nordic.core.write_select()

QUAKEML

obspy.io.quakeml

obspy.io.quakeml.core._write_quakeml()

SC3ML

obspy.io.seiscomp

obspy.io.seiscomp.event._write_sc3ml()

SCARDEC

obspy.io.scardec

obspy.io.scardec.core._write_scardec()

SHAPEFILE

obspy.io.shapefile

obspy.io.shapefile.core._write_shapefile()

ZMAP

obspy.io.zmap

obspy.io.zmap.core._write_zmap()