diff options
author | lassulus <lassulus@lassul.us> | 2021-05-02 17:37:10 +0200 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2021-05-02 17:37:10 +0200 |
commit | aec780247000278c7c46c7ff30f215009a79454c (patch) | |
tree | def04a9380e5ac2cbaec64e98c690639cea4bebf /krebs/5pkgs/simple/realwallpaper/get_constellations.py | |
parent | a9da6e0e5bc2e9d4b5141de39942f77e546a425f (diff) |
realwallpaper: add version with star constellations
Diffstat (limited to 'krebs/5pkgs/simple/realwallpaper/get_constellations.py')
-rw-r--r-- | krebs/5pkgs/simple/realwallpaper/get_constellations.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/krebs/5pkgs/simple/realwallpaper/get_constellations.py b/krebs/5pkgs/simple/realwallpaper/get_constellations.py new file mode 100644 index 000000000..5d8d3df5d --- /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)) |