#!/usr/bin/env python3 """Read the 2026 markers off NOAA GML's South Pole total-column plot (downloads/gml_plt1220_total_png/total.png). Axis calibration from the tick marks found by pixel: y ticks at rows 113 (400 DU) ... 624 (100 DU), 50 DU apart; x ticks at columns 124, 227, 330, 429, 532, 631, 734 = 1 Jul, 1 Aug, 1 Sep, 1 Oct, 1 Nov, 1 Dec, 31 Dec/1 Jan. Filled red squares = ozonesonde; open red squares = Dobson (GML's 'About the plot'). Needs Pillow. Usage: python3 -I measure_gml_plot.py (NOAA GML's plot, https://gml.noaa.gov/webdata/ozwv/ozsondes/spo/plt1220/total.png)""" import sys from datetime import date, timedelta from PIL import Image if hasattr(sys.stdout, "reconfigure"): sys.stdout.reconfigure(encoding="utf-8", newline="\n") im = Image.open(sys.argv[1]).convert("RGB") px = im.load() W, H = im.size red = lambda c: c[0] > 190 and c[1] < 90 and c[2] < 90 ticks = [124, 227, 330, 429, 532, 631, 734] starts = [date(2026, m, 1) for m in (7, 8, 9, 10, 11, 12)] + [date(2027, 1, 1)] def du(y): return 100 + (624 - y) / ((624 - 113) / 300) def when(x): for i in range(6): if ticks[i] <= x < ticks[i + 1]: f = (x - ticks[i]) / (ticks[i + 1] - ticks[i]) return starts[i] + timedelta(days=round(f * (starts[i + 1] - starts[i]).days)) filled, opened = [], [] for y in range(70, 655): for x in range(95, 760): ring = [(x + i, y + j) for i in range(-3, 4) for j in range(-3, 4) if max(abs(i), abs(j)) == 3] inner = [(x + i, y + j) for i in range(-2, 3) for j in range(-2, 3)] r_ring = sum(red(px[p]) for p in ring) r_in = sum(red(px[p]) for p in inner) if r_ring == len(ring) and r_in == len(inner): filled.append((x, y)) elif r_ring >= len(ring) - 2 and r_in <= 3: opened.append((x, y)) def cluster(pts): out = [] for p in pts: for c in out: if abs(c[0][0] - p[0]) <= 3 and abs(c[0][1] - p[1]) <= 3: c.append(p) break else: out.append([p]) return [(sum(q[0] for q in c) / len(c), sum(q[1] for q in c) / len(c)) for c in out] for name, pts in (("sonde (filled)", cluster(filled)), ("Dobson (open)", cluster(opened))): print(name) for x, y in sorted(pts): if x >= 330: print(f" {when(x)} ~{du(y):.0f} DU (x={x:.0f}, y={y:.0f})")