Skip to content

Commit

Permalink
Add IERS DUT1 to Skyfield internal array builder
Browse files Browse the repository at this point in the history
For #452.
  • Loading branch information
brandon-rhodes committed Oct 15, 2020
1 parent 1013ec1 commit 25a5ed5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
.settings
.tox/
/dist/
/finals2000A.all
/skyfield/documentation/_build/
/tmp*
CometEls.txt
Expand Down
6 changes: 0 additions & 6 deletions bin/update-deltat

This file was deleted.

19 changes: 18 additions & 1 deletion builders/build_arrays.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/usr/bin/env python3

import argparse
import sys

from skyfield.api import load
from skyfield.data import iers
from numpy import array, savez_compressed

def main(argv):
parser = argparse.ArgumentParser(description='Save arrays to a file')
parser.parse_args(argv)

g = globals()
savez_compressed('nutation', **{key: g[key] for key in [
savez_compressed('skyfield/data/nutation', **{key: g[key] for key in [
'ke0_t',
'ke1',
'lunisolar_longitude_coefficients',
Expand All @@ -20,6 +25,18 @@ def main(argv):
'se0_t_1',
]})

f = load.open(iers.FINALS_URL)
mjd, dut1 = iers.parse_dut1_from_finals_all(f)
delta_t_recent, leap_dates, leap_offsets = (
iers.build_timescale_arrays(mjd, dut1)
)
savez_compressed(
'skyfield/data/iers',
delta_t_recent=delta_t_recent,
leap_dates=leap_dates,
leap_offsets=leap_offsets,
)

# ----------------------------------------------------------------------
# START of arrays that used to be inline in nutation.py
# ----------------------------------------------------------------------
Expand Down
15 changes: 10 additions & 5 deletions skyfield/data/iers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
"""Parse data files from https://www.iers.org/"""
"""Parse data files from the International Earth Rotation Service.
See:
https://datacenter.iers.org/eop.php
ftp://ftp.iers.org/products/eop/rapid/standard/
"""
import numpy as np
import re

FINALS_ALL_URL = 'ftp://ftp.iers.org/products/eop/rapid/standard/finals.all'
FINALS_URL = 'ftp://ftp.iers.org/products/eop/rapid/standard/finals2000A.all'
_DUT1 = re.compile(b'^......(.........) ' + b'.' * 42 + b'(.\d........)', re.M)
inf = float('inf')

Expand All @@ -16,12 +21,12 @@ def parse_dut1_from_finals_all(f):

def build_timescale_arrays(mjd, dut1):
big_jumps = np.diff(dut1) > 0.9
leap_second_indices = np.concatenate([[False], big_jumps])
delta_t = np.cumsum(leap_second_indices) - dut1 + 32.184 + 12.0
leap_second_mask = np.concatenate([[False], big_jumps])
delta_t = np.cumsum(leap_second_mask) - dut1 + 32.184 + 12.0
delta_t_recent = np.array([mjd + 2400000.5, delta_t])

leap_dates = 2400000.5 + np.concatenate([
[-inf], [41317.0, 41499.0, 41683.0], mjd[leap_second_indices], [inf],
[-inf], [41317.0, 41499.0, 41683.0], mjd[leap_second_mask], [inf],
])
leap_offsets = np.arange(8.0, len(leap_dates) + 8.0)
leap_offsets[0] = leap_offsets[1] = 10.0
Expand Down

0 comments on commit 25a5ed5

Please sign in to comment.