Script for generating UT1-UTC graph
- Python 100%
The gnuplot-based method of generating the graph is described in README.md which should be enough for documenting the inspiration. |
||
|---|---|---|
| .gitignore | ||
| make-ut1-utc-graph.py | ||
| README.md | ||
Produces a UT1-UTC (also known as DUT1) graph.
Reads source data from finals.all file. If the file does not exist, downloads
it from US Naval Observatory website and saves it on disk. Subsequent runs of
the script will reuse the file. To force fetching a new copy, delete
finals.all file.
Saves the graph to Leapsecond.ut1-utc.svg file. Overwrites the file if
necessary.
Usage
If you’ve downloaded this repository, just execute the script. Otherwise, either clone it or download the script directly like so:
wget https://codeberg.org/mina86/make-ut1-utc-graph/raw/branch/master/make-ut1-utc-graph.py &&
python make-ut1-utc-graph.py
To regenerate the graph from fresh data delete the finals.all file:
[ -e finals.all ] && rm finals.all
python make-ut1-utc-graph.py
Other version
The script is based on the following procedure:
wget https://maia.usno.navy.mil/ser7/finals.all
cut -c 1-2,3-4,5-6,8-15,58,59-68 --output-delimiter " " \
finals.all > finals-cut.txt
grep "P" finals-cut.txt > finals-pred.txt
grep "I" finals-cut.txt > finals-iers.txt
cat >leapsecs.gnuplot <<EOF
set xdata time
set timefmt "%Y-%m-%d"
set format x "%Y"
set xrange ["1973-01-01":"2028-01-01"]
set yrange [-0.9:0.9]
set xtics "1970-01-01", 5 years
set mxtics time 1 year
set grid lt 3 lc 0
set terminal svg font "Arial,16"
set style line 1 lc rgb 'dark-green' lt 1
set style line 2 lc rgb 'red' lt 1
unset key
makedate(y,m,d,j) = sprintf("%04d-%02d-%02d", (j <= 51543 ? 1900 + y : 2000 + y), m, d)
set output 'Leapsecond.ut1-utc.svg'
plot \
'finals-iers.txt' \
using (makedate($1,$2,$3,$4)):($6) \
with lines linestyle 1 title 'Measured', \
'finals-pred.txt' \
using (makedate($1,$2,$3,$4)):($6) \
with lines linestyle 2 title 'Predicted'
set output
EOF
gnuplot leapsecs.gnuplot