Skip to content
Snippets Groups Projects
Commit 04d8e9e9 authored by Kien Le's avatar Kien Le
Browse files

Override times() in DiscontinuousTrace

Override times() in DiscontinuousTrace to
parent 2b955c74
No related branches found
No related tags found
1 merge request!139Change the way RT130 data is read for better performance
...@@ -12,6 +12,8 @@ Maeva Pourpoint IRIS/PASSCAL ...@@ -12,6 +12,8 @@ Maeva Pourpoint IRIS/PASSCAL
import copy import copy
import os import os
from pathlib import Path
from typing import Optional, Union
import obspy.io.reftek.core as obspy_rt130_core import obspy.io.reftek.core as obspy_rt130_core
import warnings import warnings
...@@ -33,7 +35,29 @@ from sohstationviewer.model.reftek.rt130_experiment.reftek_helper import ( ...@@ -33,7 +35,29 @@ from sohstationviewer.model.reftek.rt130_experiment.reftek_helper import (
class DiscontinuousTrace(Trace): class DiscontinuousTrace(Trace):
def __init__(self, *args, times, **kwargs): def __init__(self, *args, times, **kwargs):
super().__init__(*args, **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): class Reftek130Exception(ObsPyException):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment