Bases: obspy.core.util.attribdict.AttribDict
A container for additional header information of a ObsPy Trace object.
A Stats object may contain all header information (also known as meta data) of a Trace object. Those headers may be accessed or modified either in the dictionary style or directly via a corresponding attribute. There are various default attributes which are required by every waveform import and export modules within ObsPy such as obspy.mseed.
Parameters: | header (dict or Stats, optional) Dictionary containing meta information of a single Trace object. Possible keywords are summarized in the following Default Attributes section. |
---|
Basic Usage
>>> stats = Stats()
>>> stats.network = 'BW'
>>> stats['network']
'BW'
>>> stats['station'] = 'MANZ'
>>> stats.station
'MANZ'
Default Attributes
Notes
The attributes sampling_rate and delta are linked to each other. If one of the attributes is modified the other will be recalculated.
>>> stats = Stats()
>>> stats.sampling_rate
1.0
>>> stats.delta = 0.005
>>> stats.sampling_rate
200.0
The attributes starttime, npts, sampling_rate and delta are monitored and used to automatically calculate the endtime.
>>> stats = Stats()
>>> stats.npts = 60
>>> stats.delta = 1.0
>>> stats.starttime = UTCDateTime(2009, 1, 1, 12, 0, 0)
>>> stats.endtime
UTCDateTime(2009, 1, 1, 12, 0, 59)
>>> stats.delta = 0.5
>>> stats.endtime
UTCDateTime(2009, 1, 1, 12, 0, 29, 500000)
Note
The attribute endtime is currently calculated as endtime = starttime + (npts-1) * delta. This behaviour may change in the future to endtime = starttime + npts * delta.
The attribute endtime is read only and can not be modified.
>>> stats = Stats()
>>> stats.endtime = UTCDateTime(2009, 1, 1, 12, 0, 0)
Traceback (most recent call last):
...
AttributeError: Attribute "endtime" in Stats object is read only!
>>> stats['endtime'] = UTCDateTime(2009, 1, 1, 12, 0, 0)
Traceback (most recent call last):
...
AttributeError: Attribute "endtime" in Stats object is read only!
The attribute npts will be automatically updated from the Trace object.
>>> trace = Trace()
>>> trace.stats.npts
0
>>> trace.data = np.array([1, 2, 3, 4])
>>> trace.stats.npts
4
Attributes
__abstractmethods__ | frozenset() -> empty frozenset object |
__dict__ | |
__doc__ | str(object) -> string |
__hash__ | |
__module__ | str(object) -> string |
__weakref__ | list of weak references to the object (if defined) |
defaults | dict() -> new empty dictionary |
readonly | list() -> new empty list |
Public Methods
clear | |
copy | |
get | |
items | |
iteritems | |
iterkeys | |
itervalues | |
keys | |
pop | |
popitem | |
setdefault | |
update | |
values |
Private Methods
_pretty_str | Return better readable string representation of AttribDict object. |
Special Methods
__contains__ | |
__deepcopy__ | |
__delattr__ | |
__delitem__ | |
__eq__ | |
__getattr__ | |
__getitem__ | |
__getstate__ | |
__init__ | |
__iter__ | |
__len__ | |
__ne__ | |
__repr__ | |
__setattr__ | |
__setitem__ | |
__setstate__ | |
__str__ | Return better readable string representation of Stats object. |
__subclasshook__ |