- upload a very small (but representative) sample of all the input data
- describe more precisely (and using the input variable names) the manipulation you want
- tell us exactly what the output should be for the sample input
Adjusting a timeseries for clock drift with exact known start and stop times
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Emily T. Griffiths
el 4 de En. de 2021
Editada: Emily T. Griffiths
el 4 de En. de 2021
Hello,
Apologies if this is an easy answer; I'm coming from other programming languages and can not figure out how to do this Matlab. I'm using 2017b, and I can't upgrade.
I deploy units to collect data for months at a time. Each file collected is timestamped. Some of the files are 3 hours long, some are 30 minutes. Some have duty cycles of no data collection, others record continuously. It varies based on the project.
Before each deployment we sync our recording units with a GPS clock to ensure that the time at the start of the deployment is accurate. This often happens right before the deployment, but can occur a few days before the unit is deployed depending on our preperation schedule. Therefore, there can be a few hours to a few days from that GPS time sync to the first timestamped file.
When we retrieve these units, we document the clock drift. Sometimes it's a few seconds, sometimes its a few minutes, but there's always some clock drift.
I would like to adjust the timestamps of the files to account for the clock drift, so the timestamps closer to GPS accurate.
For example:
%GPS Time stamp taken before deployment when the unit was synced with GPS time.
timeGPSreset=datetime('2019-03-19 09:47:30', 'Format','yyyy-MM-dd HH:mm:ss');
%Time unit stopped according to GPS
timeGPSstop=datetime('2019-08-12 09:19:40','Format','yyyy-MM-dd HH:mm:ss');
%Time unit stopped according to internal clock.
timeClockstop=datetime('2019-08-12 09:18:07','Format','yyyy-MM-dd HH:mm:ss');
%Timestamps of the files recorded. This unit was scheduled to start at midnight after it was deployed.
>> DateTime
DateTime =
2272×1 datetime array
28-Mar-2019 00:00:00
28-Mar-2019 01:00:00
28-Mar-2019 02:00:00
28-Mar-2019 03:00:00
28-Mar-2019 04:00:00
28-Mar-2019 05:00:00
28-Mar-2019 06:00:00
28-Mar-2019 07:00:00
28-Mar-2019 08:00:00
28-Mar-2019 09:00:00
28-Mar-2019 10:00:00
28-Mar-2019 11:00:00
28-Mar-2019 12:00:00
28-Mar-2019 13:00:00
28-Mar-2019 14:00:00
28-Mar-2019 15:00:00
28-Mar-2019 16:00:00
28-Mar-2019 17:00:00
28-Mar-2019 18:00:00
28-Mar-2019 19:00:00
28-Mar-2019 20:00:00
28-Mar-2019 21:00:00
...
29-Jun-2019 08:03:27
29-Jun-2019 09:03:27
29-Jun-2019 10:03:27
29-Jun-2019 11:03:27
29-Jun-2019 12:03:27
29-Jun-2019 13:03:27
29-Jun-2019 14:03:27
29-Jun-2019 15:03:27
29-Jun-2019 16:03:27
29-Jun-2019 17:03:27
29-Jun-2019 18:03:27
29-Jun-2019 19:03:27
29-Jun-2019 20:03:27
29-Jun-2019 21:03:27
29-Jun-2019 22:03:27
29-Jun-2019 23:03:27
30-Jun-2019 00:03:27
30-Jun-2019 01:03:27
30-Jun-2019 02:03:27
30-Jun-2019 03:03:27
30-Jun-2019 04:03:27
30-Jun-2019 05:03:27
30-Jun-2019 06:03:27
30-Jun-2019 07:03:27
30-Jun-2019 08:03:27
30-Jun-2019 09:03:27
30-Jun-2019 10:03:27
30-Jun-2019 11:03:27
30-Jun-2019 12:03:27
30-Jun-2019 13:03:27
30-Jun-2019 14:03:27
30-Jun-2019 15:03:27
I would have thought that I could interpolate to adjust the timeseries, but I can't seem to find a function that deals directly with datetime values. I've looked into using liner interpolation with datenum, but interp1 wants inputs of corresponding length, which I don't have. I just have the start and stop, and they don't directly line up.
Thoughts and/suggestions?
****** EDIT ********
OK, so I kept working on this. Please see solution below.
2 comentarios
the cyclist
el 4 de En. de 2021
Your statement, "I would like to adjust the timestamps of the files to account for the clock drift, so the timestamps closer to GPS accurate" does not make it fully clear (at least to me) what data manipulation you want to perform. Constant shift in all the data points in a vector, by some fixed offset? Different offsets, so that you have uniform spacing in the new vector?
I think that the best thing you could do here is
Then we can help you develop an algorithm, without any guesswork.
Respuesta aceptada
Emily T. Griffiths
el 4 de En. de 2021
Editada: Emily T. Griffiths
el 4 de En. de 2021
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Time Series Events en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!