From 9bf159612223784dc0df01577b371c7da085eb7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Nu=C3=B1ez?= Date: Thu, 5 Oct 2023 17:21:48 +0200 Subject: [PATCH] more fixes --- src/vse_sync_pp/analyzers/analyzer.py | 28 +++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/vse_sync_pp/analyzers/analyzer.py b/src/vse_sync_pp/analyzers/analyzer.py index 937b4db..68fcff7 100644 --- a/src/vse_sync_pp/analyzers/analyzer.py +++ b/src/vse_sync_pp/analyzers/analyzer.py @@ -395,7 +395,11 @@ def _explain_common(self, data): return None def toplot(self): + self._generate_taus() yield from zip(self._taus, self._samples) + + def _generate_taus(self): + return NotImplementedError class TimeDeviationAnalyzerBase(TimeIntervalErrorAnalyzerBase): """Analyze Time Deviation (TDEV). @@ -414,12 +418,15 @@ def __init__(self, config): self._taus = None # TDEV samples self._samples = None + + def _generate_taus(self): + if self._samples is None: + self._taus, self._samples, errors, ns = allantools.tdev(self._lpf_signal, rate=self._rate, data_type="phase", taus=self._taus_list) # noqa def test(self, data): result = self._test_common(data) if result is None: - if self._samples is None: - self._taus, self._samples, errors, ns = allantools.tdev(self._lpf_signal, rate=self._rate, data_type="phase", taus=self._taus_list) # noqa + self._generate_taus() if out_of_range(self._taus, self._samples, self._accuracy, self._limit): return (False, "unacceptable time deviation") return (True, None) @@ -428,14 +435,11 @@ def test(self, data): def explain(self, data): analysis = self._explain_common(data) if analysis is None: - if self._samples is None: - self._taus, self._samples, errors, ns = allantools.tdev(self._lpf_signal, rate=self._rate, data_type="phase", taus=self._taus_list) # noqa + self._generate_taus() return { 'timestamp': self._timestamp_from_dec(data.iloc[0].timestamp), 'duration': data.iloc[-1].timestamp - data.iloc[0].timestamp, 'tdev': self._statistics(self._samples, 'ns'), - #'tdev_taus': self._taus.tolist(), - #'tdev_samples': self._samples.tolist(), } return analysis @@ -458,11 +462,14 @@ def __init__(self, config): # MTIE samples self._samples = None + def _generate_taus(self): + if self._samples is None: + self._taus, self._samples, errors, ns = allantools.mtie(self._lpf_signal, rate=self._rate, data_type="phase", taus=self._taus_list) # noqa + def test(self, data): result = self._test_common(data) if result is None: - if self._samples is None: - self._taus, self._samples, errors, ns = allantools.mtie(self._lpf_signal, rate=self._rate, data_type="phase", taus=self._taus_list) # noqa + self._generate_taus() if out_of_range(self._taus, self._samples, self._accuracy, self._limit): return (False, "unacceptable mtie") return (True, None) @@ -470,13 +477,10 @@ def test(self, data): def explain(self, data): analysis = self._explain_common(data) if analysis is None: - if self._samples is None: - self._taus, self._samples, errors, ns = allantools.mtie(self._lpf_signal, rate=self._rate, data_type="phase", taus=self._taus_list) # noqa + self._generate_taus() return { 'timestamp': self._timestamp_from_dec(data.iloc[0].timestamp), 'duration': data.iloc[-1].timestamp - data.iloc[0].timestamp, 'mtie': self._statistics(self._samples, 'ns'), - #'mtie_taus': self._taus.tolist(), - #'mtie_samples': self._samples.tolist(), } return analysis