From 322952b1ee4bb31839f75724eedb36d181290f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Nu=C3=B1ez?= Date: Mon, 2 Oct 2023 14:00:47 +0200 Subject: [PATCH] update MTIE, TDEV analyzer results for plotting --- src/vse_sync_pp/analyzers/analyzer.py | 4 + src/vse_sync_pp/common.py | 7 +- tests/vse_sync_pp/analyzers/test_gnss.py | 16 +++ tests/vse_sync_pp/analyzers/test_phc2sys.py | 16 +++ tests/vse_sync_pp/analyzers/test_ppsdpll.py | 124 +++++++++++--------- tests/vse_sync_pp/analyzers/test_ts2phc.py | 16 +++ 6 files changed, 129 insertions(+), 54 deletions(-) diff --git a/src/vse_sync_pp/analyzers/analyzer.py b/src/vse_sync_pp/analyzers/analyzer.py index 3758dd9..041dcc4 100644 --- a/src/vse_sync_pp/analyzers/analyzer.py +++ b/src/vse_sync_pp/analyzers/analyzer.py @@ -432,6 +432,8 @@ def explain(self, data): '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 @@ -473,5 +475,7 @@ def explain(self, data): '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 diff --git a/src/vse_sync_pp/common.py b/src/vse_sync_pp/common.py index d16c200..41be59e 100644 --- a/src/vse_sync_pp/common.py +++ b/src/vse_sync_pp/common.py @@ -7,6 +7,7 @@ import json from decimal import Decimal +import numpy def open_input(filename, encoding='utf-8', **kwargs): @@ -20,11 +21,15 @@ def open_input(filename, encoding='utf-8', **kwargs): class JsonEncoder(json.JSONEncoder): - """A JSON encoder accepting :class:`Decimal` values""" + """A JSON encoder accepting :class:`Decimal` values + and arrays `numpy.ndarray` values + """ def default(self, o): """Return a commonly serializable value from `o`""" if isinstance(o, Decimal): return float(o) + if isinstance(o, numpy.ndarray): + return o.tolist() return super().default(o) diff --git a/tests/vse_sync_pp/analyzers/test_gnss.py b/tests/vse_sync_pp/analyzers/test_gnss.py index 5979463..0751162 100644 --- a/tests/vse_sync_pp/analyzers/test_gnss.py +++ b/tests/vse_sync_pp/analyzers/test_gnss.py @@ -318,6 +318,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, { @@ -357,6 +359,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, { @@ -396,6 +400,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, { @@ -435,6 +441,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, ) @@ -526,6 +534,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [0.], + 'tdev_taus': [1.], }, }, { @@ -573,6 +583,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [0.], + 'tdev_taus': [1.], }, }, { @@ -620,6 +632,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [0.], + 'tdev_taus': [1.], }, }, { @@ -667,6 +681,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [0.], + 'tdev_taus': [1.], }, }, ) diff --git a/tests/vse_sync_pp/analyzers/test_phc2sys.py b/tests/vse_sync_pp/analyzers/test_phc2sys.py index c0571f9..56294ba 100644 --- a/tests/vse_sync_pp/analyzers/test_phc2sys.py +++ b/tests/vse_sync_pp/analyzers/test_phc2sys.py @@ -297,6 +297,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, { @@ -336,6 +338,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, { @@ -375,6 +379,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, { @@ -414,6 +420,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, ) @@ -505,6 +513,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [0.], + 'tdev_taus': [1.], }, }, { @@ -552,6 +562,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [0.], + 'tdev_taus': [1.], }, }, { @@ -599,6 +611,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [0.], + 'tdev_taus': [1.], }, }, { @@ -646,6 +660,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [0.], + 'tdev_taus': [1.], }, }, ) diff --git a/tests/vse_sync_pp/analyzers/test_ppsdpll.py b/tests/vse_sync_pp/analyzers/test_ppsdpll.py index 9a5f600..662a4de 100644 --- a/tests/vse_sync_pp/analyzers/test_ppsdpll.py +++ b/tests/vse_sync_pp/analyzers/test_ppsdpll.py @@ -105,12 +105,12 @@ class TestTimeErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'analysis': { 'terror': { 'units': 'ns', - 'min': 1.0, - 'max': 1.0, - 'range': 0.0, - 'mean': 1.0, - 'stddev': 0.0, - 'variance': 0.0, + 'min': 1, + 'max': 1, + 'range': 0, + 'mean': 1, + 'stddev': 0, + 'variance': 0, }, }, }, @@ -195,12 +195,12 @@ class TestTimeErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'analysis': { 'terror': { 'units': 'ns', - 'min': 1.0, - 'max': 1.0, - 'range': 0.0, - 'mean': 1.0, - 'stddev': 0.0, - 'variance': 0.0, + 'min': 1, + 'max': 1, + 'range': 0, + 'mean': 1, + 'stddev': 0, + 'variance': 0, }, }, }, @@ -224,12 +224,12 @@ class TestTimeErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'analysis': { 'terror': { 'units': 'ns', - 'min': 1.0, - 'max': 1.0, - 'range': 0.0, - 'mean': 1.0, - 'stddev': 0.0, - 'variance': 0.0, + 'min': 1, + 'max': 1, + 'range': 0, + 'mean': 1, + 'stddev': 0, + 'variance': 0, }, }, }, @@ -321,6 +321,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0., 0., 0.], + 'mtie_taus': [1., 2., 3.], }, }, { @@ -370,6 +372,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0., 0., 0.], + 'mtie_taus': [1., 2., 3.], }, }, { @@ -419,6 +423,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0., 0., 0., 0.], + 'mtie_taus': [1., 2., 3., 4.], }, }, { @@ -457,6 +463,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, { @@ -467,20 +475,20 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'min-test-duration/s': 11, }, 'rows': ( - DPLLS(Decimal('1695047659.996251'), 3, 3, Decimal(1)), - DPLLS(Decimal('1695047660.996251'), 3, 3, Decimal(1)), - DPLLS(Decimal('1695047661.996251'), 3, 3, Decimal(1)), - DPLLS(Decimal('1695047662.996251'), 3, 3, Decimal(1)), - DPLLS(Decimal('1695047663.996251'), 3, 3, Decimal(1)), - DPLLS(Decimal('1695047664.996251'), 3, 3, Decimal(1)), - DPLLS(Decimal('1695047665.996251'), 3, 3, Decimal(1)), - DPLLS(Decimal('1695047666.996251'), 3, 3, Decimal(1)), - DPLLS(Decimal('1695047667.996251'), 3, 3, Decimal(1)), - DPLLS(Decimal('1695047668.996251'), 3, 3, Decimal(1)), - DPLLS(Decimal('1695047669.996251'), 3, 3, Decimal(1)), - DPLLS(Decimal('1695047670.996251'), 3, 3, Decimal(1)), - DPLLS(Decimal('1695047671.996251'), 3, 3, Decimal(1)), - DPLLS(Decimal('1695047672.996251'), 3, 3, Decimal(1)), + DPLLS(Decimal('1695047659.996251'), 3, 3, Decimal(0)), + DPLLS(Decimal('1695047660.996251'), 3, 3, Decimal(0)), + DPLLS(Decimal('1695047661.996251'), 3, 3, Decimal(0)), + DPLLS(Decimal('1695047662.996251'), 3, 3, Decimal(0)), + DPLLS(Decimal('1695047663.996251'), 3, 3, Decimal(0)), + DPLLS(Decimal('1695047664.996251'), 3, 3, Decimal(0)), + DPLLS(Decimal('1695047665.996251'), 3, 3, Decimal(0)), + DPLLS(Decimal('1695047666.996251'), 3, 3, Decimal(0)), + DPLLS(Decimal('1695047667.996251'), 3, 3, Decimal(0)), + DPLLS(Decimal('1695047668.996251'), 3, 3, Decimal(0)), + DPLLS(Decimal('1695047669.996251'), 3, 3, Decimal(0)), + DPLLS(Decimal('1695047670.996251'), 3, 3, Decimal(0)), + DPLLS(Decimal('1695047671.996251'), 3, 3, Decimal(0)), + DPLLS(Decimal('1695047672.996251'), 3, 3, Decimal(0)), ), 'result': True, 'reason': None, @@ -496,6 +504,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, ) @@ -586,6 +596,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [3.2684080872601985e-17], + 'tdev_taus': [1.], }, }, { @@ -635,6 +647,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [3.2684080872601985e-17], + 'tdev_taus': [1.], }, }, { @@ -645,28 +659,28 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'min-test-duration/s': 20, }, 'rows': ( - DPLLS(Decimal('1876878.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876879.28'), 3, 3, Decimal(0)), + DPLLS(Decimal('1876878.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876879.28'), 3, 3, Decimal(1)), # oops, missing sample - DPLLS(Decimal('1876881.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876882.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876883.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876884.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876885.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876886.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876887.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876888.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876889.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876890.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876891.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876892.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876893.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876894.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876895.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876896.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876897.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876898.28'), 3, 3, Decimal(0)), - DPLLS(Decimal('1876899.28'), 3, 3, Decimal(0)), + DPLLS(Decimal('1876881.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876882.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876883.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876884.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876885.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876886.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876887.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876888.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876889.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876890.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876891.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876892.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876893.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876894.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876895.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876896.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876897.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876898.28'), 3, 3, Decimal(1)), + DPLLS(Decimal('1876899.28'), 3, 3, Decimal(1)), ), 'result': False, 'reason': "short test samples", @@ -682,6 +696,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [2.2204460492503132e-17], + 'tdev_taus': [1.], }, }, { @@ -731,6 +747,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_taus': [1.], + 'tdev_samples': [3.2684080872601985e-17], }, }, ) diff --git a/tests/vse_sync_pp/analyzers/test_ts2phc.py b/tests/vse_sync_pp/analyzers/test_ts2phc.py index 4e241a8..54770c5 100644 --- a/tests/vse_sync_pp/analyzers/test_ts2phc.py +++ b/tests/vse_sync_pp/analyzers/test_ts2phc.py @@ -297,6 +297,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, { @@ -336,6 +338,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, { @@ -375,6 +379,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, { @@ -414,6 +420,8 @@ class TestMaxTimeIntervalErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'mtie_samples': [0.], + 'mtie_taus': [1.], }, }, ) @@ -505,6 +513,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [0.], + 'tdev_taus': [1.], }, }, { @@ -552,6 +562,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [0.], + 'tdev_taus': [1.], }, }, { @@ -599,6 +611,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [0.], + 'tdev_taus': [1.], }, }, { @@ -646,6 +660,8 @@ class TestTimeDeviationAnalyzer(TestCase, metaclass=AnalyzerTestBuilder): 'stddev': 0, 'variance': 0, }, + 'tdev_samples': [0.], + 'tdev_taus': [1.], }, }, )