From bd6dbfe27ebd6f62639eecd57fbdc67d75566d1f Mon Sep 17 00:00:00 2001 From: kienle <kienle@passcal.nmt.edu> Date: Wed, 9 Aug 2023 16:56:50 -0600 Subject: [PATCH] Override times() in DiscontinuousTrace Override times() in DiscontinuousTrace to --- .../model/reftek/from_rt2ms/core.py | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/sohstationviewer/model/reftek/from_rt2ms/core.py b/sohstationviewer/model/reftek/from_rt2ms/core.py index 4ca268642..00d27a172 100644 --- a/sohstationviewer/model/reftek/from_rt2ms/core.py +++ b/sohstationviewer/model/reftek/from_rt2ms/core.py @@ -12,6 +12,8 @@ Maeva Pourpoint IRIS/PASSCAL import copy import os +from pathlib import Path +from typing import Optional, Union import obspy.io.reftek.core as obspy_rt130_core import warnings @@ -33,7 +35,29 @@ from sohstationviewer.model.reftek.rt130_experiment.reftek_helper import ( class DiscontinuousTrace(Trace): def __init__(self, *args, times, **kwargs): super().__init__(*args, **kwargs) - self.times = times + self._times = times + + def times(self, type: str = "relative", + reftime: Optional[UTCDateTime] = None) -> np.ndarray: + """ + Override Trace.times(). Returns a numpy array of stored times data, + modified based on the argument "type". + :param type: the type of times data to return. For more information, + refer to Trace.times(). Note: this method does not implement + types 'utcdatetime' and 'matplotlib' because they are not going + to be useful. + :param reftime: the time used as a reference point when getting + relative time. If None, the start time of the trace is used as + the reference point. + :return: the requested array of time data, modified based on the type + requested. + """ + if type == 'utcdatetime' or type == 'matplotlib': + raise NotImplementedError + if type == 'relative': + return self._times - self.stats.starttime.timestamp + elif type == 'timestamp': + return self._times class Reftek130Exception(ObsPyException): -- GitLab