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
Attributes
__abstractmethods__
__dict__
__doc__
__hash__
__module__
__reversed__
__slots__
__weakref__
list of weak references to the object (if defined)
defaults
do_not_warn_on
readonly
warn_on_non_default_key
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.
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
Private Methods
Warning
Private methods are mainly for internal/developer use and their API might change without notice.
Return better readable string representation of AttribDict object.
Special Methods
Default dir() implementation.
Return self==value.
Default object formatter.
Py3k hasattr() expects an AttributeError no KeyError to be raised if the attribute is not found.
This method is called when a class is subclassed.
Create and return a new object.
Helper for pickle.
Helper for pickle.
Return repr(self).
Size of object in memory, in bytes.
Return better readable string representation of Stats object.
Abstract classes can override this to customize issubclass().