blob: 4454fa41136caf3c1d270e5a67cdf1ce02ce75ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
Data synchronisation
====================
Recorded data needs to be synchronized to link them before further processings.
The [TimeStampedBuffer](/argaze/#argaze.DataStructures.TimeStampedBuffer) class provides various methods to help in such task.
## Pop last before
![Pop last before](../../img/pop_last_before.png)
The code below shows how to use [pop_last_before](/argaze/#argaze.DataStructures.TimeStampedBuffer.pop_last_before) method in order to synchronise two timestamped data buffers with different timestamps:
``` python
from argaze import DataStructures
# Assuming A_data_record and B_data_record are [TimeStampedBuffer](/argaze/#argaze.DataStructures.TimeStampedBuffer) instances with different timestamps
for A_ts, A_data in A_data_record.items():
try:
# Get nearest B data before current A data and remove all B data before (including the returned one)
B_ts, B_data = B_data_record.pop_last_before(A_ts)
# No data stored before A_ts timestamp
except KeyError:
pass
```
## Pop last until
![Pop last until](../../img/pop_last_until.png)
The code below shows how to use [pop_last_until](/argaze/#argaze.DataStructures.TimeStampedBuffer.pop_last_until) method in order to synchronise two timestamped data buffers with different timestamps:
``` python
from argaze import DataStructures
# Assuming A_data_record and B_data_record are [TimeStampedBuffer](/argaze/#argaze.DataStructures.TimeStampedBuffer) instances with different timestamps
for A_ts, A_data in A_data_record.items():
try:
# Get nearest B data after current A data and remove all B data before
B_ts, B_data = B_data_record.pop_last_until(A_ts)
# No data stored until A_ts timestamp
except KeyError:
pass
```
## Get last before
![Get last before](../../img/get_last_before.png)
The code below shows how to use [get_last_before](/argaze/#argaze.DataStructures.TimeStampedBuffer.get_last_before) method in order to synchronise two timestamped data buffers with different timestamps:
``` python
from argaze import DataStructures
# Assuming A_data_record and B_data_record are [TimeStampedBuffer](/argaze/#argaze.DataStructures.TimeStampedBuffer) instances with different timestamps
for A_ts, A_data in A_data_record.items():
try:
# Get nearest B data before current A data
B_ts, B_data = B_data_record.get_last_before(A_ts)
# No data stored before A_ts timestamp
except KeyError:
pass
```
## Get last until
![Get last until](../../img/get_last_until.png)
The code below shows how to use [get_last_until](/argaze/#argaze.DataStructures.TimeStampedBuffer.get_last_until) method in order to synchronise two timestamped data buffers with different timestamps:
``` python
from argaze import DataStructures
# Assuming A_data_record and B_data_record are TimeStampedBuffer instances with different timestamps
for A_ts, A_data in A_data_record.items():
try:
# Get nearest B data after current A data
B_ts, B_data = B_data_record.get_last_until(A_ts)
# No data stored until A_ts timestamp
except KeyError:
pass
```
|