RF Eclectica Wiki

Try to learn something about everything, and everything about something - Thomas Huxley

User Tools

Site Tools


public:watches:watchcheck

Watchcheck Python code

I wrote a small python2 application to keep track of a watch/clock's daily rate error. It's a console-only mimic of an Android app that I use on my phone to track my watch timekeeping.

I wrote it mainly as a thought-experiment rather than as a fully functional piece of code.

You put the application in a directory specific to the watch and execute it from that directory. the data from each measurement is stored in a json file in the same directory.

watchcheck.py

Running it for the first time, with no previous records stored, looks like this:

Wire2waves WatchCheck.....
=========================

N : New Record
D : Delete Last
S : Stats
Q : Quit

Command > : n
New
Current Time = 10:18
Watch time 10:19
19
Press enter when seconds = 0

2022/05/04 10:19:30

Delta -30.2 seconds

and the first time-delta is stored in the error_list.json file like this:

[["2022/05/04 10:19:30", -30.179980039596558]]

Running it again, after only 10 minutes looks like this:

Command > : n
New
Current Time = 10:30
Watch time 10:30
30
Press enter when seconds = 0

2022/05/04 10:30:30

Delta -30.2 seconds
First record time  2022/05/04 10:19:30
First record delta  -30.1799800396

Previous record time  2022/05/04 10:19:30
Previous record delta  -30.1799800396

Latest record time  2022/05/04 10:30:30
Latest record delta  -30.1998269558

Overall elapsed time  0:11:00
Latest elapsed time  0:11:00

Latest delta change  -0.0198469161987
Latest elapsed time 660 seconds

Daily PPM : -30.071
Daily rate error: -2.6 s/d

Total Time 660 seconds
Total error  -0.0198469161987
Total PPM : -30.071
Total rate error: -2.6 s/d

========================================================
 Delta : -30.2 s | Rate : -2.6 s/d | Average : -2.6 s/d
========================================================

The error_list.json file now looks like:

[["2022/05/04 10:19:30", -30.179980039596558], ["2022/05/04 10:30:30", -30.199826955795288]]

There's also a small utility called watchstat.py that reads the error_list.json file to calculate and display the data

watchstat.py

Running watchstat.py on the newly updated error_list.json

gm4slv@laptop:~/watchcheck_damasko $ python watchstat.py
First record time  2022/05/04 10:19:30
First record delta  -30.1799800396

Previous record time  2022/05/04 10:19:30
Previous record delta  -30.1799800396

Latest record time  2022/05/04 10:30:30
Latest record delta  -30.1998269558

Overall elapsed time  0:11:00
Latest elapsed time  0:11:00

Latest delta change  -0.0198469161987
Latest elapsed time 660 seconds

Daily PPM : -30.071
Daily rate error: -2.6 s/d

Total Time 660 seconds
Total error  -0.0198469161987
Total PPM : -30.071
Total rate error: -2.6 s/d

========================================================
 Delta : -30.2 s | Rate : -2.6 s/d | Average : -2.6 s/d
========================================================

watchcheck.py also creates a log file on each run.

04/05/2022 09:30:30     -30.2           -2.6            -2.6

The fields are “date time”, current error, error in seconds per day since last record, average error in seconds per day since the start.

This mimics the behaviour of the Android Watchcheck app

John Pumford-Green Wed May 4 09:09:09 2022

Page Updated : 02/07/22 13:43 BST

public/watches/watchcheck.txt · Last modified: 02/07/22 13:43 BST by john