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 --- krebs/5pkgs/simple/realwallpaper/default.nix | 33 +++++++++++++++++++- .../simple/realwallpaper/get_constellations.py | 36 ++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 krebs/5pkgs/simple/realwallpaper/get_constellations.py (limited to 'krebs') diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index aafabb7b6..c9b2e76b6 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -271,6 +271,32 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' shade=15 ''} + ${pkgs.writers.writePython3 "get_constellations" { + libraries = [ pkgs.python3Packages.astropy ]; + } ./get_constellations.py} ${pkgs.fetchurl { + url = "https://raw.githubusercontent.com/ofrohn/d3-celestial/d2e20e104b86429d90ac8227a5b021262b45d75a/data/constellations.lines.json"; + sha256 = "0g71fdrnxvxd6pcqvihj2q9iaynrl7px45kzw6qm1kymynz6ckr9"; + }} > constellations.arcs + + xplanet --num_times 1 --geometry $xplanet_out_size \ + --output xplanet-krebs-stars-output.png --projection merc \ + -config ${pkgs.writeText "xplanet-krebs-stars.config" '' + [default] + + arc_thickness=1 + arc_file=constellations.arcs + + [earth] + "Earth" + map=daymap-final.png + night_map=nightmap-final.png + cloud_map=clouds.png + cloud_threshold=1 + cloud_gamma=10 + marker_file=marker_file + shade=15 + ''} + # trim xplanet output if needs_rebuild realwallpaper.png xplanet-output.png; then convert xplanet-output.png -crop $out_geometry \ @@ -278,7 +304,6 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' mv realwallpaper-tmp.png realwallpaper.png fi - # trim xplanet output if needs_rebuild realwallpaper-marker.png xplanet-marker-output.png; then convert xplanet-marker-output.png -crop $out_geometry \ realwallpaper-marker-tmp.png @@ -292,6 +317,12 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' mkdir -p archive convert realwallpaper-krebs.png archive/"$(date -Is)".jpg fi + + if needs_rebuild realwallpaper-krebs-stars.png xplanet-krebs-stars-output.png; then + convert xplanet-krebs-stars-output.png -crop $out_geometry \ + realwallpaper-krebs-stars-tmp.png + mv realwallpaper-krebs-stars-tmp.png realwallpaper-krebs-stars.png + fi } main "$@" 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)) -- cgit v1.2.3