obspy.core.event.header.MTInversionType

MTInversionType = Enum(["general", "zero trace", "double couple"])

Enumerated type (enum) implementation for Python.

Parameters:replace (dict, optional) Dictionary of keys which are replaced by values.

Example

>>> from obspy.core.util import Enum
>>> units = Enum(["m", "s", "m/s", "m/(s*s)", "m*s", "other"])

There are different ways to access the correct enum values:

>>> print(units.get('m/s'))
m/s
>>> print(units['S'])
s
>>> print(units.OTHER)
other
>>> print(units[3])
m/(s*s)
>>> units.xxx  
Traceback (most recent call last):
...
AttributeError: 'xxx'

Changing enum values will not work:

>>> units.m = 5  
Traceback (most recent call last):
...
NotImplementedError
>>> units['m'] = 'xxx'  
Traceback (most recent call last):
...
NotImplementedError

Calling with a value will either return the mapped enum value or None:

>>> print(units("M*s"))
m*s
>>> units('xxx')
>>> print(units(5))
other

The following enum allows replacing certain entries:

>>> units2 = Enum(["m", "s", "m/s", "m/(s*s)", "m*s", "other"],
...               replace={'meter': 'm'})
>>> print(units2('m'))
m
>>> print(units2('meter'))
m