obspy.io.quakeml.core.Pickler

class Pickler(nsmap=None)[source]

Bases: object

Serializes an ObsPy Catalog object into QuakeML format.

Public Methods

dump

Writes ObsPy Catalog into given file.

dumps

Returns QuakeML string of given ObsPy Catalog object.

Private Methods

Warning

Private methods are mainly for internal/developer use and their API might change without notice.

Pickler._add_namespace(ns)[source]
Pickler._amplitude(amp)[source]

Converts an Amplitude into etree.Element object.

Return type:

_Element

Pickler._arrival(arrival)[source]

Converts an Arrival into etree.Element object.

Return type:

_Element

Pickler._bool(value, root, tag, always_create=False, attrib=None)[source]
Pickler._comments(comments, element)[source]
Pickler._creation_info(creation_info, element)[source]
Pickler._custom(obj, element)[source]
Pickler._extra(obj, element)[source]

Add information stored in obj.extra as custom tags/attributes in non-quakeml namespace.

Pickler._focal_mechanism(focal_mechanism)[source]

Converts a FocalMechanism into etree.Element object.

Return type:

_Element

Pickler._get_namespace_map()[source]
Pickler._id(obj)[source]
Pickler._magnitude(magnitude)[source]

Converts an Magnitude into etree.Element object.

Return type:

_Element

Example

>>> from obspy.io.quakeml.core import Pickler
>>> from obspy.core.event import Magnitude
>>> from lxml.etree import tostring
>>> magnitude = Magnitude()
>>> magnitude.mag = 3.2
>>> el = Pickler()._magnitude(magnitude)
>>> print(tostring(el, encoding="utf-8",
...                xml_declaration=True).decode())                 
<?xml version='1.0' encoding='utf-8'?>
<magnitude ...<mag><value>3.2</value></mag>...</magnitude>
Pickler._moment_tensor(moment_tensor, element)[source]

Converts a MomentTensor into etree.Element object.

Return type:

_Element

Pickler._nodal_planes(obj, element)[source]

Converts a NodalPlanes into etree.Element object.

Return type:

_Element

Pickler._origin(origin)[source]

Converts an Origin into etree.Element object.

Return type:

_Element

Example

>>> from obspy.io.quakeml.core import Pickler
>>> from obspy.core.event import Origin
>>> from lxml.etree import tostring
>>> origin = Origin()
>>> origin.latitude = 34.23
>>> el = Pickler()._origin(origin)
>>> print(tostring(el, encoding="utf-8",
...                xml_declaration=True).decode())                 
<?xml version='1.0' encoding='utf-8'?>
<origin ...<latitude><value>34.23</value></latitude>...</origin>
Pickler._pick(pick)[source]

Converts a Pick into etree.Element object.

Return type:

_Element

Pickler._principal_axes(obj, element)[source]

Converts a PrincipalAxes into etree.Element object.

Return type:

_Element

Pickler._serialize(catalog, pretty_print=True)[source]

Converts a Catalog object into XML string.

Pickler._station_magnitude(magnitude)[source]

Converts an StationMagnitude into etree.Element object.

Return type:

_Element

Example

>>> from obspy.io.quakeml.core import Pickler
>>> from obspy.core.event import StationMagnitude
>>> from lxml.etree import tostring
>>> station_mag = StationMagnitude()
>>> station_mag.mag = 3.2
>>> el = Pickler()._station_magnitude(station_mag)
>>> print(tostring(el, encoding="utf-8",
...       xml_declaration=True).decode())                 
<?xml version='1.0' encoding='utf-8'?>
<stationMagnitude ...<value>3.2</value>...</stationMagnitude>
Pickler._station_magnitude_contributions(stat_contrib, element)[source]
Pickler._str(value, root, tag, always_create=False, attrib=None)[source]
Pickler._time(value, root, tag, always_create=False)[source]
Pickler._time_window(time_window, element)[source]
Pickler._value(quantity, error, element, tag, always_create=False)[source]
Pickler._waveform_id(obj, element, required=False)[source]
Pickler._waveform_ids(objs, element, required=False)[source]

Special Methods

Pickler.__delattr__(name, /)

Implement delattr(self, name).

Pickler.__dir__()

Default dir() implementation.

Pickler.__eq__(value, /)

Return self==value.

Pickler.__format__(format_spec, /)

Default object formatter.

Pickler.__ge__(value, /)

Return self>=value.

Pickler.__getattribute__(name, /)

Return getattr(self, name).

Pickler.__gt__(value, /)

Return self>value.

Pickler.__hash__()

Return hash(self).

Pickler.__init__(nsmap=None)[source]
Pickler.__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

Pickler.__le__(value, /)

Return self<=value.

Pickler.__lt__(value, /)

Return self<value.

Pickler.__ne__(value, /)

Return self!=value.

Pickler.__new__(**kwargs)
Pickler.__reduce__()

Helper for pickle.

Pickler.__reduce_ex__(protocol, /)

Helper for pickle.

Pickler.__repr__()

Return repr(self).

Pickler.__setattr__(name, value, /)

Implement setattr(self, name, value).

Pickler.__sizeof__()

Size of object in memory, in bytes.

Pickler.__str__()

Return str(self).

Pickler.__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).