This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / pkgs / realwallpaper / get_constellations.py
1.1 kB 41 lines
1from astropy.coordinates import SkyCoord, ITRS, representation 2from astropy.time import Time 3import json 4import sys 5 6 7def convert_to_itrs(coord): 8 c = SkyCoord(coord[0], coord[1], unit='degree', frame='icrs') 9 c_itrs = c.transform_to(ITRS(obstime=Time.now())) 10 rep = c_itrs.represent_as(representation.UnitSphericalRepresentation) 11 return [rep.lat.deg, rep.lon.deg] 12 13 14def points_to_lines(points): 15 lines = [] 16 for x in range(len(points) - 1): 17 lines.append([points[x], points[x+1]]) 18 return lines 19 20 21def main(): 22 with open(sys.argv[1]) as f: 23 constellations = json.load(f)['features'] 24 25 output = [] 26 27 for const in constellations: 28 for line in const['geometry']['coordinates']: 29 transformed_line = [] 30 for point in line: 31 transformed_line.append(convert_to_itrs(point)) 32 33 line_combined = points_to_lines(transformed_line) 34 for l in line_combined: # noqa 35 output.append(f'{l[0][0]} {l[0][1]} {l[1][0]} {l[1][1]} # {const["id"]}') # noqa 36 37 print('\n'.join(output)) 38 39 40if __name__ == "__main__": 41 main()