obspy.realtime.rttrace.RtTrace.times¶
-
RtTrace.
times
(type='relative', reftime=None)¶ For convenient plotting compute a NumPy array with timing information of all samples in the Trace.
Time can be either:
- seconds relative to
trace.stats.starttime
(type="relative"
) or toreftime
- absolute time as
UTCDateTime
objects (type="utcdatetime"
) - absolute time as POSIX timestamps (
UTCDateTime.timestamp
type="timestamp"
) - absolute time as matplotlib numeric datetime (for matplotlib
plotting with absolute time on axes, see
matplotlib.dates
andmatplotlib.dates.date2num()
,type="matplotlib"
)
>>> from obspy import read, UTCDateTime >>> tr = read()[0]
>>> tr.times() # doctest: +NORMALIZE_WHITESPACE array([ 0.00000000e+00, 1.00000000e-02, 2.00000000e-02, ..., 2.99700000e+01, 2.99800000e+01, 2.99900000e+01])
>>> tr.times(reftime=UTCDateTime("2009-01-01T00")) array([ 20305203. , 20305203.01, 20305203.02, ..., 20305232.97, 20305232.98, 20305232.99])
>>> tr.times("utcdatetime") # doctest: +SKIP array([UTCDateTime(2009, 8, 24, 0, 20, 3), UTCDateTime(2009, 8, 24, 0, 20, 3, 10000), UTCDateTime(2009, 8, 24, 0, 20, 3, 20000), ..., UTCDateTime(2009, 8, 24, 0, 20, 32, 970000), UTCDateTime(2009, 8, 24, 0, 20, 32, 980000), UTCDateTime(2009, 8, 24, 0, 20, 32, 990000)], dtype=object)
>>> tr.times("timestamp") array([ 1.25107320e+09, 1.25107320e+09, 1.25107320e+09, ..., 1.25107323e+09, 1.25107323e+09, 1.25107323e+09])
>>> tr.times("matplotlib") array([ 733643.01392361, 733643.01392373, 733643.01392384, ..., 733643.01427049, 733643.0142706 , 733643.01427072])
Parameters: - type (str) – Determines type of returned time array, see above for valid values.
- reftime (obspy.core.utcdatetime.UTCDateTime) – When using a relative timing, the time used as the
reference for the zero point, i.e., the first sample will be at
trace.stats.starttime - reftime
(in seconds).
Return type: Returns: An array of time samples in an
ndarray
if the trace doesn’t have any gaps or aMaskedArray
otherwise (dtype
of array is eitherfloat
orUTCDateTime
).- seconds relative to