diff options
author | Théo de la Hogue | 2023-06-07 14:34:14 +0200 |
---|---|---|
committer | Théo de la Hogue | 2023-06-07 14:34:14 +0200 |
commit | c4552e04e1271a9210a934233beae5be1943d034 (patch) | |
tree | a44041e544bc700976237bfea9058ec06f9a2904 /docs/user_guide/timestamped_data/data_synchronisation.md | |
parent | bd9cd27c9d44c072164f564ffffeb22e37106b89 (diff) | |
download | argaze-c4552e04e1271a9210a934233beae5be1943d034.zip argaze-c4552e04e1271a9210a934233beae5be1943d034.tar.gz argaze-c4552e04e1271a9210a934233beae5be1943d034.tar.bz2 argaze-c4552e04e1271a9210a934233beae5be1943d034.tar.xz |
Writing User guide and use cases section.
Diffstat (limited to 'docs/user_guide/timestamped_data/data_synchronisation.md')
-rw-r--r-- | docs/user_guide/timestamped_data/data_synchronisation.md | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/docs/user_guide/timestamped_data/data_synchronisation.md b/docs/user_guide/timestamped_data/data_synchronisation.md new file mode 100644 index 0000000..4454fa4 --- /dev/null +++ b/docs/user_guide/timestamped_data/data_synchronisation.md @@ -0,0 +1,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 + +``` |