krz/moonrise

Night-sky companion for iPhone, Apple Watch and Vision Pro: what's up tonight, the Moon, planets, launches and missions, and a Library of the solar system. SwiftUI app with a Cloudflare Workers backend. astronomy cloudflare-workers ios night-sky space swiftui visionos watchos

Commit f32a37f048

f32a37f048bbe5c22263277e230ca5ccf56d046c

parent: 9335425c5d

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-01 05:45 UTC

Read and write catalog files as UTF-8 in data scripts

Ref #2

Layout: unified · split

scripts/make-skycultures.py +3 −3
@@ -54,7 +54,7 @@ def license_section(md):
54def load_hip(path): 54def load_hip(path):
55 """HIP number -> (RA, Dec, Vmag) from the VizieR TSV.""" 55 """HIP number -> (RA, Dec, Vmag) from the VizieR TSV."""
56 hip = {} 56 hip = {}
57 for line in open(path): 57 for line in open(path, encoding="utf-8"):
58 p = line.rstrip("\n").split("\t") 58 p = line.rstrip("\n").split("\t")
59 if len(p) == 4 and p[0].strip().isdigit() and p[1].strip() and p[2].strip(): 59 if len(p) == 4 and p[0].strip().isdigit() and p[1].strip() and p[2].strip():
60 hip[int(p[0])] = (float(p[1]), float(p[2]), float(p[3] or 99)) 60 hip[int(p[0])] = (float(p[1]), float(p[2]), float(p[3] or 99))
@@ -125,9 +125,9 @@ def culture(cid, name, hr_for):
125 125
126 126
127def main(): 127def main():
128 hr_for = hr_matcher(load_hip(sys.argv[1]), json.load(open(RES / "bsc5.json"))) 128 hr_for = hr_matcher(load_hip(sys.argv[1]), json.load(open(RES / "bsc5.json", encoding="utf-8")))
129 out = [culture(cid, name, hr_for) for cid, name in CULTURES] 129 out = [culture(cid, name, hr_for) for cid, name in CULTURES]
130 (RES / "skycultures.json").write_text(json.dumps(out, ensure_ascii=False, separators=(",", ":"))) 130 (RES / "skycultures.json").write_text(json.dumps(out, ensure_ascii=False, separators=(",", ":")), encoding="utf-8")
131 131
132 132
133if __name__ == "__main__": 133if __name__ == "__main__":
scripts/make-tycho.py +2 −2
@@ -21,7 +21,7 @@ from pathlib import Path
21 21
22RES = Path(__file__).resolve().parent.parent / "Packages/MoonriseKit/Sources/SkyRenderer/Resources" 22RES = Path(__file__).resolve().parent.parent / "Packages/MoonriseKit/Sources/SkyRenderer/Resources"
23 23
24bright = json.load(open(RES / "bsc5.json")) 24bright = json.load(open(RES / "bsc5.json", encoding="utf-8"))
25cells = {} 25cells = {}
26for hr, ra, dec, v, *_ in bright: 26for hr, ra, dec, v, *_ in bright:
27 cells.setdefault((int(dec), int(ra)), []).append((ra, dec, v)) 27 cells.setdefault((int(dec), int(ra)), []).append((ra, dec, v))
@@ -39,7 +39,7 @@ def in_bsc(ra, dec, v):
39 39
40 40
41rows = [] 41rows = []
42for r in csv.DictReader(open(sys.argv[1])): 42for r in csv.DictReader(open(sys.argv[1], encoding="utf-8")):
43 if not r["RAmdeg"] or not r["VTmag"]: 43 if not r["RAmdeg"] or not r["VTmag"]:
44 continue 44 continue
45 vt, ra, dec = float(r["VTmag"]), float(r["RAmdeg"]), float(r["DEmdeg"]) 45 vt, ra, dec = float(r["VTmag"]), float(r["RAmdeg"]), float(r["DEmdeg"])