Commit f32a37f048
Verified · cmc
Layout: unified · split
scripts/make-skycultures.py +3 −3
| @@ -54,7 +54,7 @@ def license_section(md): | |||
| 54 | def load_hip(path): | 54 | def 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 | ||
| 127 | def main(): | 127 | def 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 | ||
| 133 | if __name__ == "__main__": | 133 | if __name__ == "__main__": |
scripts/make-tycho.py +2 −2
| @@ -21,7 +21,7 @@ from pathlib import Path | |||
| 21 | 21 | ||
| 22 | RES = Path(__file__).resolve().parent.parent / "Packages/MoonriseKit/Sources/SkyRenderer/Resources" | 22 | RES = Path(__file__).resolve().parent.parent / "Packages/MoonriseKit/Sources/SkyRenderer/Resources" |
| 23 | 23 | ||
| 24 | bright = json.load(open(RES / "bsc5.json")) | 24 | bright = json.load(open(RES / "bsc5.json", encoding="utf-8")) |
| 25 | cells = {} | 25 | cells = {} |
| 26 | for hr, ra, dec, v, *_ in bright: | 26 | for 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 | ||
| 41 | rows = [] | 41 | rows = [] |
| 42 | for r in csv.DictReader(open(sys.argv[1])): | 42 | for 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"]) |