Compare commits
1 commit
main
...
use-bullet
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ad9773118 |
3 changed files with 28 additions and 42 deletions
|
|
@ -34,6 +34,7 @@ install_requires =
|
|||
platformdirs
|
||||
requests
|
||||
python-dateutil
|
||||
bulletind
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
|
|
|
|||
|
|
@ -23,16 +23,15 @@ DUT1_OFFSETS = str( # 19720601
|
|||
+i*66+h*52+g*67+f+p*103+o*56+n*68+m*69+l*107+k*82+j*72+i*67 # 19870518
|
||||
+h*63+g*113+f*63+e*51+o*11+n*60+m*59+l*121+k*71+j*71+i*67 # 19890531
|
||||
+h*57+g*93+f*61+e*48+d*12+n*41+m*44+l*46+k*61+j*66+i*47+h*45 # 19901231
|
||||
+g*15+q*32+p*44+o*41+n*48+m*74+l*49+k*45+j*44+i*40+h*37+g*38 # 19920625
|
||||
+f*50+e*5+o*60+n*49+m*40+l*40+k*38+j*38+i*36+h*39+g*25+q*31 # 19930919
|
||||
+p*50+o*41+n*41+m*43+l*41+k*39+j*40+i*39+s*24+r*57+q*43+p*41 # 19950120
|
||||
+o*39+n*38+m*35+l*37+k*43+j*69+i*44+h*42+g*37+q*4+p*51+o*45 # 19960523
|
||||
+n*44+m*69+l*70+k*50+j*54+i*53+h*40+g*49+f*18+p*59+o*53+n*52 # 19980206
|
||||
+m*57+l*48+k*53+j*127+i*70+h*30+r*62+q*79+p*152+o*82+n*106 # 20001026
|
||||
+m*184+l*125+k*217+j*133+i*252+h*161+g*392+f*322+e*290+n*116 # 20060927
|
||||
+m*154+l*85+k*83+j*91+i*168+h*105+g*147+f*105+e*42+o*70+n*91 # 20091111
|
||||
+m*154+l*119+k*84+j*217+i*126+h*176+g*97+f*91+e*52+o*116 # 20130130
|
||||
+n*98+m*70+l*133+k*91+j*91+i*77+h*140+g*91+f*84+e*70+d*34 # 20150910
|
||||
+n*72+m*76+l*66+k*53+j*56+i*105+h*77+g*45+q*25+p*63+o*91 # 20171129
|
||||
+n*154+m*105+l*190+k*118+j*105+i*807+j*376+k*351+l*86 # 20231007
|
||||
+g*15+q*32+p*44+o*41+n*48+m*68+l*56+k*35+j*168+f*119+n*49 # 19921125
|
||||
+m*35+l*49+k*112+h*56+q*98+o*42+n*42+m*77+k*35+j*71+s*237 # 19950315
|
||||
+n*21+m*28+l*45+k*46+j*56+i*49+h*35+g*32+p*52+o*49+n*35+m*84 # 19961002
|
||||
+l*56+k*63+j*63+i*42+h*49+g*49+f*5+p*79+o*42+n*49+m*63+l*35 # 19980506
|
||||
+k*42+j*98+i*105+h*36+r*62+q*84+p*140+o*84+n*98+m*189+l*133 # 20011003
|
||||
+k*217+j*133+i*252+h*161+g*392+f*322+e*290+n*116+m*154+l*85 # 20070314
|
||||
+k*83+j*91+i*168+h*105+g*147+f*105+e*112+n*91+m*154+l*119 # 20100602
|
||||
+k*84+j*217+i*126+h*176+g*97+f*91+e*52+o*116+n*98+m*70+l*133 # 20131120
|
||||
+k*91+j*91+i*77+h*140+g*91+f*84+e*70+d*34+n*78+m*70+l*66 # 20160323
|
||||
+k*53+j*56+i*105+h*77+g*45+q*25+p*63+o*91+n*154+m*105+l*190 # 20190116
|
||||
+k*118+j*105+i*807+j*376+k*346+l*98 # 20231014
|
||||
)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import pathlib
|
|||
from typing import Callable, List, Optional
|
||||
|
||||
import bs4
|
||||
import bulletind
|
||||
import click
|
||||
import platformdirs
|
||||
import requests
|
||||
|
|
@ -33,7 +34,6 @@ try:
|
|||
except (ImportError, NameError) as e:
|
||||
pass
|
||||
IERS_URL = "https://datacenter.iers.org/data/csv/finals2000A.all.csv"
|
||||
NIST_URL = "https://www.nist.gov/pml/time-and-frequency-division/atomic-standards/leap-second-and-ut1-utc-information"
|
||||
|
||||
|
||||
def update_iersdata( # pylint: disable=too-many-locals, too-many-branches, too-many-statements
|
||||
|
|
@ -51,6 +51,7 @@ def update_iersdata( # pylint: disable=too-many-locals, too-many-branches, too-
|
|||
offs = int(round(float(offs_str) * 10))
|
||||
if not offsets:
|
||||
table_start = datetime.date(1858, 11, 17) + datetime.timedelta(jd)
|
||||
# If the table starts after June 1, 1972 (it does), add the 1972 leap second
|
||||
if table_start > datetime.date(1972, 6, 1):
|
||||
when = datetime.date(1972, 6, 1)
|
||||
while when < datetime.date(1972, 7, 1):
|
||||
|
|
@ -62,18 +63,6 @@ def update_iersdata( # pylint: disable=too-many-locals, too-many-branches, too-
|
|||
table_start = datetime.date(1972, 6, 1)
|
||||
offsets.append(offs)
|
||||
|
||||
wwvb_text = requests.get(NIST_URL).text
|
||||
wwvb_data = bs4.BeautifulSoup(wwvb_text, features="html.parser")
|
||||
wwvb_dut1_table = wwvb_data.findAll("table")[2]
|
||||
assert wwvb_dut1_table
|
||||
meta = wwvb_data.find("meta", property="article:modified_time")
|
||||
assert isinstance(meta, bs4.Tag)
|
||||
wwvb_data_stamp = (
|
||||
datetime.datetime.fromisoformat(meta.attrs["content"])
|
||||
.replace(tzinfo=None)
|
||||
.date()
|
||||
)
|
||||
|
||||
def patch(patch_start: datetime.date, patch_end: datetime.date, val: int) -> None:
|
||||
off_start = (patch_start - table_start).days
|
||||
off_end = (patch_end - table_start).days
|
||||
|
|
@ -81,29 +70,26 @@ def update_iersdata( # pylint: disable=too-many-locals, too-many-branches, too-
|
|||
|
||||
wwvb_dut1: Optional[int] = None
|
||||
wwvb_start: Optional[datetime.date] = None
|
||||
for row in wwvb_dut1_table.findAll("tr")[1:][::-1]:
|
||||
cells = row.findAll("td")
|
||||
when = datetime.datetime.strptime(cells[0].text, "%Y-%m-%d").date()
|
||||
dut1 = cells[2].text.replace("s", "").replace(" ", "")
|
||||
dut1 = int(round(float(dut1) * 10))
|
||||
for data in bulletind.get_cached_bulletin_d_data():
|
||||
when = data.start_date
|
||||
dut1 = round(10 * data.dut1)
|
||||
if wwvb_dut1 is not None:
|
||||
assert wwvb_start is not None
|
||||
patch(wwvb_start, when, wwvb_dut1)
|
||||
wwvb_dut1 = dut1
|
||||
wwvb_start = when
|
||||
|
||||
# As of 2021-06-14, NIST website incorrectly indicates the offset of -600ms
|
||||
# persisted through 2009-03-12, causing an incorrect leap second inference.
|
||||
# Assume instead that NIST started broadcasting +400ms on January 1, 2009,
|
||||
# causing the leap second to occur on 2008-12-31.
|
||||
patch(datetime.date(2009, 1, 1), datetime.date(2009, 3, 12), 4)
|
||||
|
||||
# this is the final (most recent) wwvb DUT1 value broadcast. We want to
|
||||
# extend it some distance into the future, but how far? We will use the
|
||||
# modified timestamp of the NIST data.
|
||||
assert wwvb_dut1 is not None
|
||||
assert wwvb_start is not None
|
||||
patch(wwvb_start, wwvb_data_stamp + datetime.timedelta(days=1), wwvb_dut1)
|
||||
# this is the final (most recent) Bulletin D DUT1 value specified. We
|
||||
# might want to extend it some distance into the future, but how far? The
|
||||
# textual Bulletin D says something like "Bulletin D 136 should be issued
|
||||
# in August 2017" or "Bulletin D 143 should be issued in 2023" but this is
|
||||
# not in the xml format and thus not in the data from the bulletind
|
||||
# package. Historically, bulletins have even been published AFTER their
|
||||
# effective date. As such, transition immediately back to the IERS Bulletin
|
||||
# A data immediately after the last Bulletin D data and do _NOT_ patch any
|
||||
# additonal days. This is in contrast to previous behavior, where the NIST
|
||||
# data was propagated until the reported modification date of the scraped
|
||||
# web page.
|
||||
|
||||
with open(target_file, "wt", encoding="utf-8") as output:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue