"""Read the plotted points of Figure 13 (ellipticity vs orbital phase) from the figure's own vector drawing, as dumped by dump_fig_pdf.py. Usage: python3 -I extract_fig13.py Markers are filled closed paths; their colour is the current fill colour (rg). Axes are calibrated from the tick marks whose labels are drawn beside them: x ticks at phase 0.0 ... 1.0, y ticks at ellipticity 0.00 ... 0.12. The output starts with a credit line, as the figure is CC BY 4.0. """ import json import re import sys CREDIT = ("Adapted from Fig. 13 of Matthews et al. (2026), AJ 172, 184, doi:10.3847/1538-3881/ae953d, " "CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/): the 13 plotted points, read from the " "figure's vector drawing in the arXiv source files (arXiv:2608.02847v1) by Fact-Checked Science. " "Colours are the paper's.") COLOURS = { (1.0, 0.0, 0.0): "22 GHz (red)", (0.0, 0.544922, 1.0): "44 GHz (blue)", (0.0, 0.0, 0.0): "107-485 GHz (black)", } def main(): src, dst = sys.argv[1], sys.argv[2] t = open(src, encoding="utf-8").read() i = t.find("=== obj 5") j = t.find("=== obj 6") seg = t[i:j] toks = seg.split("\n") colour = None path = [] markers = [] xt = {} yt = {} last_line = None for line in toks: line = line.strip() m = re.fullmatch(r"([-\d.]+) ([-\d.]+) ([-\d.]+) rg", line) if m: colour = tuple(float(v) for v in m.groups()) continue m = re.fullmatch(r"([-\d.]+) ([-\d.]+) (m|l)", line) if m: x, y = float(m.group(1)), float(m.group(2)) if m.group(3) == "m": path = [(x, y)] else: path.append((x, y)) continue if line == "S" and len(path) == 2: last_line = list(path) (x0, y0), (x1, y1) = path # major x ticks on the bottom axis (y0 = 4158.71, length 55.27) if abs(y0 - 4158.71) < 0.5 and abs((y1 - y0) - 55.27) < 0.5 and x0 == x1: xt.setdefault("major", []).append(x0) # major y ticks on the left axis (x0 = 1421.01, length 77.95) if abs(x0 - 1421.01) < 0.5 and abs((x1 - x0) - 77.95) < 0.5 and y0 == y1: yt.setdefault("major", []).append(y0) path = [] continue if line == "f" and len(path) > 10: xs = [p[0] for p in path] ys = [p[1] for p in path] markers.append({ "colour": COLOURS.get(colour, str(colour)), "xc": (max(xs) + min(xs)) / 2, "yc": (max(ys) + min(ys)) / 2, "w": max(xs) - min(xs), "n": len(path), }) path = [] xmaj = sorted(xt.get("major", [])) ymaj = sorted(yt.get("major", [])) # labels: x 0.0..1.0 step 0.2 ; y 0.00..0.12 step 0.02 xlab = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0] ylab = [0.00, 0.02, 0.04, 0.06, 0.08, 0.10, 0.12] assert len(xmaj) == 6, xmaj assert len(ymaj) == 7, ymaj def fit(us, vs): n = len(us) mu, mv = sum(us) / n, sum(vs) / n b = sum((u - mu) * (v - mv) for u, v in zip(us, vs)) / sum((u - mu) ** 2 for u in us) a = mv - b * mu rms = (sum((a + b * u - v) ** 2 for u, v in zip(us, vs)) / n) ** 0.5 return a, b, rms ax, bx, rx = fit(xmaj, xlab) ay, by, ry = fit(ymaj, ylab) for mk in markers: mk["phase"] = round(ax + bx * mk["xc"], 4) mk["ellipticity"] = round(ay + by * mk["yc"], 4) mk["marker_diam_e"] = round(by * mk["w"], 4) res = { "credit": CREDIT, "x_ticks": xmaj, "y_ticks": ymaj, "x_cal_rms_phase": rx, "y_cal_rms_e": ry, "markers": markers, } with open(dst, "w", encoding="utf-8", newline="\n") as f: json.dump(res, f, indent=1) for mk in markers: print(f'{mk["colour"]:22s} phase={mk["phase"]:.4f} e={mk["ellipticity"]:.4f} (marker diam {mk["marker_diam_e"]:.4f} in e, n={mk["n"]})') print("x cal rms (phase):", rx, " y cal rms (e):", ry, " markers:", len(markers)) if __name__ == "__main__": main()