Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read constellation boundaries more accurately (#547) #548

Merged
merged 1 commit into from
Feb 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 3 additions & 6 deletions builders/build_constellations.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,11 @@ def compute_constellation(ra, dec, sorted_ra, sorted_dec, sorted_consts, grid):
def extend(s):
"""Return a float for `s` extended to machine precision.

Takes a string like '13.6667', extends it to >30 digits by
duplicating the second-to-last character ('6' and not '7' because
the '7' in many cases will have been rounded), and passes it to
`float()`.
Takes a string like '13.6667', passes it to `float()`,
and snaps it to the nearest whole second.

"""
s = s[:-2] + 30 * s[-2:-1] + s[-1:]
return float(s)
return round(3600 * float(s)) / 3600.

# Some discarded code that I might want to revive someday: how to grow
# and shrink a list of segments as new ones supersede old ones on the
Expand Down
Binary file modified skyfield/data/constellations.npz
Binary file not shown.
6 changes: 6 additions & 0 deletions skyfield/tests/test_constellations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from skyfield.api import load_constellation_map, position_of_radec
from skyfield.timelib import Time, julian_date_of_besselian_epoch

def test_constellations():
lookup = load_constellation_map()
Expand All @@ -10,6 +11,11 @@ def test_constellations():
assert lookup(position_of_radec(4.65, 0)) == 'Eri'
assert lookup(position_of_radec(4.75, 0.3)) == 'Ori'

# exploit extend() bug, issue 547
B1875 = Time(None, julian_date_of_besselian_epoch(1875))
assert lookup(position_of_radec(18.1747, 39., epoch=B1875)) == 'Her'
assert lookup(position_of_radec(18.1753, 39., epoch=B1875)) == 'Lyr'

# Test vectorization.
assert list(
lookup(position_of_radec([4.65, 4.75], [0, 0.3]))
Expand Down