From 714eaee3d0d79cd1b0d9243fc4bea64518b22af4 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 2 May 2021 17:37:10 +0200 Subject: realwallpaper: add version with star constellations --- .../simple/realwallpaper/get_constellations.py | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 krebs/5pkgs/simple/realwallpaper/get_constellations.py (limited to 'krebs/5pkgs/simple/realwallpaper/get_constellations.py') diff --git a/krebs/5pkgs/simple/realwallpaper/get_constellations.py b/krebs/5pkgs/simple/realwallpaper/get_constellations.py new file mode 100644 index 00000000..5d8d3df5 --- /dev/null +++ b/krebs/5pkgs/simple/realwallpaper/get_constellations.py @@ -0,0 +1,36 @@ +from astropy.coordinates import SkyCoord, ITRS, representation +from astropy.time import Time +import json +import sys + + +def convert_to_itrs(coord): + c = SkyCoord(coord[0], coord[1], unit='degree', frame='icrs') + c_itrs = c.transform_to(ITRS(obstime=Time.now())) + rep = c_itrs.represent_as(representation.UnitSphericalRepresentation) + return [rep.lat.deg, rep.lon.deg] + + +def points_to_lines(points): + lines = [] + for x in range(len(points) - 1): + lines.append([points[x], points[x+1]]) + return lines + + +with open(sys.argv[1]) as f: + constellations = json.load(f)['features'] + +output = [] + +for const in constellations: + for line in const['geometry']['coordinates']: + transformed_line = [] + for point in line: + transformed_line.append(convert_to_itrs(point)) + + line_combined = points_to_lines(transformed_line) + for l in line_combined: # noqa + output.append(f'{l[0][0]} {l[0][1]} {l[1][0]} {l[1][1]} # {const["id"]}') # noqa + +print('\n'.join(output)) -- cgit v1.2.3