summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-01-18 09:37:00 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2021-01-18 09:37:00 +0100
commitac22b1deb81c5e314477f19238e39b518dfccbe0 (patch)
treedbdde212615f2f234ad0f958950b1e7a25113d85 /lib
parentc6aace4bc9e0c51248e9c003ba19a0cc67a64edd (diff)
refactor graph-based drift compensation into a separate function
Diffstat (limited to 'lib')
-rw-r--r--lib/lennart/DataProcessor.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/lennart/DataProcessor.py b/lib/lennart/DataProcessor.py
index 1f784b4..265ebce 100644
--- a/lib/lennart/DataProcessor.py
+++ b/lib/lennart/DataProcessor.py
@@ -222,7 +222,6 @@ class DataProcessor:
pelt = PELT(with_multiprocessing=False)
expected_transition_start_timestamps = sync_timestamps[::2]
transition_start_candidate_weights = list()
- compensated_timestamps = list()
drift = 0
for i, expected_start_ts in enumerate(expected_transition_start_timestamps):
@@ -266,6 +265,15 @@ class DataProcessor:
)
)
+ # TODO provide different algorithmes (shortest path, greedy, ...?) and use environment variables to decide
+ # which one should be used
+ return self.compensate_drift_graph(
+ sync_timestamps, transition_start_candidate_weights
+ )
+
+ def compensate_drift_graph(
+ self, sync_timestamps, transition_start_candidate_weights
+ ):
# Algorithm: Obtain the shortest path in a layered graph made up from
# transition candidates. Each node represents a transition candidate timestamp, and each layer represents a transition.
# Each node in layer i contains a directed edge to each node in layer i+1.
@@ -284,6 +292,7 @@ class DataProcessor:
nodes_by_transition_index = dict()
transition_by_node = dict()
+ compensated_timestamps = list()
for transition_index, candidates in enumerate(
transition_start_candidate_weights
@@ -399,6 +408,8 @@ class DataProcessor:
import json
from dfatool.utils import NpEncoder
+ expected_transition_start_timestamps = sync_timestamps[::2]
+
with open(os.getenv("DFATOOL_EXPORT_DRIFT_COMPENSATION"), "w") as f:
json.dump(
[