obspy.io.quakeml.core.Pickler
- class Pickler(nsmap=None)[source]
Bases:
object
Serializes an ObsPy Catalog object into QuakeML format.
Public Methods
Writes ObsPy Catalog into given file. |
|
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._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
- Pickler._magnitude(magnitude)[source]
Converts an Magnitude into etree.Element object.
- Return type
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
- Pickler._nodal_planes(obj, element)[source]
Converts a NodalPlanes into etree.Element object.
- Return type
- Pickler._origin(origin)[source]
Converts an Origin into etree.Element object.
- Return type
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._principal_axes(obj, element)[source]
Converts a PrincipalAxes into etree.Element object.
- Return type
- Pickler._station_magnitude(magnitude)[source]
Converts an StationMagnitude into etree.Element object.
- Return type
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>
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_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).