obspy.core.trace.Stats
- class Stats(header={})[source]
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 aTrace
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 asobspy.io.mseed
.- Parameters
header (dict or
Stats
, optional) – Dictionary containing meta information of a singleTrace
object. Possible keywords are summarized in the following Default Attributes section.
Basic Usage
>>> stats = Stats() >>> stats.network = 'BW' >>> print(stats['network']) BW >>> stats['station'] = 'MANZ' >>> print(stats.station) MANZ
Default Attributes
sampling_rate
float, optionalSampling rate in hertz (default value is 1.0).
delta
float, optionalSample distance in seconds (default value is 1.0).
calib
float, optionalCalibration factor (default value is 1.0).
npts
int, optionalNumber of sample points (default value is 0, which implies that no data is present).
network
string, optionalNetwork code (default is an empty string).
location
string, optionalLocation code (default is an empty string).
station
string, optionalStation code (default is an empty string).
channel
string, optionalChannel code (default is an empty string).
starttime
UTCDateTime
, optionalDate and time of the first data sample given in UTC (default value is “1970-01-01T00:00:00.0Z”).
endtime
UTCDateTime
, optionalDate and time of the last data sample given in UTC (default value is “1970-01-01T00:00:00.0Z”).
Notes
The attributes
sampling_rate
anddelta
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
anddelta
are monitored and used to automatically calculate theendtime
.>>> 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)
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 theTrace
object.>>> trace = Trace() >>> trace.stats.npts 0 >>> trace.data = np.array([1, 2, 3, 4]) >>> trace.stats.npts 4
The attribute
component
can be used to get or set the component, i.e. the last character of thechannel
attribute.>>> stats = Stats() >>> stats.channel = 'HHZ' >>> stats.component 'Z' >>> stats.component = 'L' >>> stats.channel 'HHL'
Attributes
Public Methods
If key is not found, d is returned if given, otherwise KeyError is raised. |
|
as a 2-tuple; but raise KeyError if D is empty. |
|
Private Methods
Warning
Private methods are mainly for internal/developer use and their API might change without notice.
- Stats._cast_type(key, value)
Cast type of value to type required in _types dict.
- Parameters
key (str) – The key from __setattr__.
value – The value being set to key.
- Returns
value cast to correct type.
- Stats._pretty_str(priorized_keys=[], min_label_length=16)
Return better readable string representation of AttribDict object.
- Parameters
- Returns
String representation of current AttribDict object.
Special Methods
- Stats.__contains__(key)
- Stats.__delattr__(name)
- Stats.__delitem__(name)
- Stats.__dir__()
Default dir() implementation.
- Stats.__eq__(other)
- Stats.__format__(format_spec, /)
Default object formatter.
- Stats.__ge__(value, /)
Return self>=value.
- Stats.__getattr__(name, default=None)
Py3k hasattr() expects an AttributeError no KeyError to be raised if the attribute is not found.
- Stats.__getattribute__(name, /)
Return getattr(self, name).
- Stats.__gt__(value, /)
Return self>value.
- Stats.__init_subclass__()
This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
- Stats.__iter__()
- Stats.__le__(value, /)
Return self<=value.
- Stats.__len__()
- Stats.__lt__(value, /)
Return self<value.
- Stats.__ne__(value, /)
Return self!=value.
- Stats.__new__(**kwargs)
- Stats.__reduce__()
Helper for pickle.
- Stats.__reduce_ex__(protocol, /)
Helper for pickle.
- Stats.__repr__()
- Stats.__setattr__(key, value)
- Stats.__sizeof__()
Size of object in memory, in bytes.
- classmethod Stats.__subclasshook__(C)