From 60f6b75ab7e7f7e9b6484fdacc04bfa14daeecd5 Mon Sep 17 00:00:00 2001 From: loggger101 Date: Mon, 30 Nov 2026 14:06:59 -0500 Subject: [PATCH] Chart what the catalog is built from, and how few diameters are measured surveys.py draws the bodies each source survey supplies to AsteroidCatalog's latest release, across the whole catalog, and the share with a measured diameter (9.5%) against those estimated from brightness. refresh_counts.py keeps the release manifest's survey counts in counts.json ("catalog") and writes the README's sentence and alt text from them; check.py, the weekly refresh and the tests cover it like the other charts. It opens the Space economics charts, so they run in the pipeline's order. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/refresh-counts.yml | 3 +- README.md | 6 + docs/surveys-compact.svg | 54 +++++++++ docs/surveys.svg | 59 +++++++++ tools/README.md | 17 ++- tools/check.py | 4 +- tools/counts.json | 24 ++++ tools/panel.py | 2 +- tools/refresh_counts.py | 42 +++++-- tools/surveys.py | 173 +++++++++++++++++++++++++++ tools/test_tools.py | 24 ++++ 11 files changed, 396 insertions(+), 12 deletions(-) create mode 100644 docs/surveys-compact.svg create mode 100644 docs/surveys.svg create mode 100644 tools/surveys.py diff --git a/.github/workflows/refresh-counts.yml b/.github/workflows/refresh-counts.yml index 051aa25..2f83543 100644 --- a/.github/workflows/refresh-counts.yml +++ b/.github/workflows/refresh-counts.yml @@ -1,5 +1,5 @@ # Keeps the research-sources and agent-skills tiles, each repo's lines of code, the -# break-even, crossover, landform, sources, value and launch charts and the activity and languages panels in step with their repos, and the +# break-even, crossover, landform, sources, surveys, value and launch charts and the activity and languages panels in step with their repos, and the # flyby chart with NASA/JPL's close approaches for the week ahead, and the badges with shields.io's # drawing of each repo's latest release. The private repos' counts are # refreshed by running loc.py and refresh_activity.py locally. The activity panel runs to @@ -45,6 +45,7 @@ jobs: - run: python tools/crossover.py docs - run: python tools/landforms.py docs - run: python tools/sources.py docs + - run: python tools/surveys.py docs - run: python tools/value.py docs - run: python tools/launch.py docs - run: python tools/loc.py --public-only diff --git a/README.md b/README.md index 494931e..28416e0 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,12 @@ The first five repos work together to estimate whether an uncrewed asteroid mini +**What the catalog is built from.** The bodies each survey supplies to AsteroidCatalog's latest release, data-2026-11-13, out of its 1,580,325 asteroids. JPL SBDB knows every one of them; NEOWISE, the fewest, 143,015. Only 149,718 (9.5%) have a measured diameter; the rest are estimated from brightness and an assumed albedo. + +

+ What AsteroidCatalog's data-2026-11-13 release is built from: 1,580,325 asteroids. The bodies each source survey supplies: JPL SBDB 1,580,325 (100%); SsODNet 1,563,656 (98.9%); MP3C 1,335,052 (84.5%); NEOWISE 143,015 (9.0%). 149,718 (9.5%) have a measured diameter, the rest estimated from brightness; validation refused 275 rows. +

+ **What a kilogram is worth.** spacevalue's price for a kilogram of water, iron and platinum at each place you could deliver it, from its latest tables, on a log scale. A filled mark is sold or used where it is, which off Earth saves launching it there; an open one is flown home and sold, less the trip. Water is worth more than platinum on the Moon's surface and on the surface of Mars; on the surface of Mars, platinum is worth nothing, since the trip home costs more than it sells for.

diff --git a/docs/surveys-compact.svg b/docs/surveys-compact.svg new file mode 100644 index 0000000..4955522 --- /dev/null +++ b/docs/surveys-compact.svg @@ -0,0 +1,54 @@ + + + + + + + + +9.5% +of 1.58M asteroids have a measured diameter +data-2026-11-13, by survey: +JPL SBDB + + + + +1.58M +SsODNet + + + + +1.56M +MP3C + + + + +1.34M +NEOWISE + + + + +143k +Measured diameters + + + + + +150k + +measured + +estimated + + diff --git a/docs/surveys.svg b/docs/surveys.svg new file mode 100644 index 0000000..9f5e206 --- /dev/null +++ b/docs/surveys.svg @@ -0,0 +1,59 @@ + + + + + + + + +9.5% +of the catalog's 1,580,325 asteroids have a measured diameter +AsteroidCatalog data-2026-11-13: the bodies each survey supplies, and the diameters. Validation refused 275 rows. +JPL SBDB orbits, brightness, and which body is which + + + + +1,580,325 +100% +SsODNet best-of-literature sizes, albedos, masses, spins and taxonomy + + + + +1,563,656 +98.9% +MP3C sizes, albedos, collisional families and proper elements + + + + +1,335,052 +84.5% +NEOWISE thermal-infrared sizes and albedos + + + + +143,015 +9.0% +Measured diameters the rest estimated from brightness + + + + + +149,718 +9.5% + +measured diameter + +estimated from its brightness (H) and an assumed albedo + + diff --git a/tools/README.md b/tools/README.md index 651cd04..1f03641 100644 --- a/tools/README.md +++ b/tools/README.md @@ -19,6 +19,7 @@ Mondays) fetches it again and redraws them. | crossover chart in Planetary science | `refresh_counts.py`, `crossover.py` | asteroid-belt-gradient's `results/summary.json` | weekly | | landform chart in Planetary science | `refresh_counts.py`, `landforms.py` | the Mars project's `score_metrics_v3_unet.json` and `_svm.json` | weekly | | sources chart in Space economics | `refresh_counts.py`, `sources.py` | General_Research's `sources.csv`: each source's domain and tier | weekly | +| surveys chart in Space economics | `refresh_counts.py`, `surveys.py` | the manifest of AsteroidCatalog's latest release | weekly | | value chart in Space economics | `refresh_counts.py`, `value.py` | the price tables in spacevalue's newest `prices-YYYY-MM-DD` release | weekly | | launch chart in Space economics | `refresh_counts.py`, `launch.py` | spacecost's `reference/launch_vehicles.csv` | weekly | | flyby chart | `refresh_flybys.py`, `flybys.py` | NASA/JPL's close-approach API | weekly | @@ -28,7 +29,7 @@ Run from the repo root. Fetch the data first (each writes `counts.json` and the alt text): ```bash -python tools/refresh_counts.py # research sources, agent skills, the catalog's size, economicspace's destinations, the paper's crossover fits, the sources by domain and tier, spacevalue's prices, spacecost's launch prices, the Mars maps' scores +python tools/refresh_counts.py # research sources, agent skills, the catalog's size and surveys, economicspace's destinations, the paper's crossover fits, the sources by domain and tier, the catalog's surveys and their wording, spacevalue's prices, spacecost's launch prices, the Mars maps' scores python tools/loc.py # lines of code and total lines per repo, and by language (--public-only skips the private two) python tools/refresh_activity.py # every commit of mine to each repo, by week, and the latest few (--public-only as above) python tools/refresh_flybys.py # NASA/JPL's close approaches to Earth for the week ahead @@ -43,6 +44,7 @@ python tools/breakeven.py docs # economicspace's cost per dollar earned python tools/crossover.py docs # where the belt turns from S-types to C-types, raw and corrected, plus -compact python tools/landforms.py docs # how the Mars project's U-Net and SVM score on each landform, plus -compact python tools/sources.py docs # General_Research's sources by domain, split by tier, plus -compact +python tools/surveys.py docs # the bodies each survey supplies to the catalog, and its measured diameters, plus -compact python tools/value.py docs # what a kilogram of water, iron and platinum is worth at each of spacevalue's destinations, plus -compact python tools/launch.py docs # what a kilogram to LEO costs on each rocket any buyer can book, from spacecost, plus -compact python tools/activity.py docs # every commit so far as orbits, plus -compact @@ -88,7 +90,7 @@ OneDrive lock can't leave a file cut off), and if the run stops part way, Ctrl+C every file it touched goes back as it was. The weekly workflow commits only `README.md`, `docs/` and `counts.json`, and fails rather than commit if anything else changed. -The wide panels (activity, languages, break-even, crossover, landforms, sources, value, launch, flybys, repo diagram) open with +The wide panels (activity, languages, break-even, crossover, landforms, sources, surveys, value, launch, flybys, repo diagram) open with `panel.background` from `panel.py`: the frame, the stars and the reduced-motion rule, which stops every class a panel names as animated. Change the frame there. `panel.keep_clear` then takes out the stars that would land on a panel's text or marks; the tiles place theirs @@ -188,6 +190,17 @@ with no domain or an unknown tier. The README's sentences above it (the total, t T1 and T2, and what the largest domain leans on) are written from the same counts. A new domain gets a name from its folder; `NAMES` in `sources.py` shortens the long ones. +`surveys.py` draws what AsteroidCatalog's latest release is built from: one bar for each +source survey, across the whole catalog, filled for the bodies it supplies (JPL's SBDB, the +backbone every row is keyed to, fills it), and below them the share of the catalog with a +measured diameter, gold, against the rest, hollow, which the catalog estimates from +brightness and an assumed albedo. Its headline is that share. `refresh_counts.py` reads it +all from the release's `manifest.json` (the same file the catalog tile's size comes from) +into `counts.json` (`"catalog"`), and stops if the release tag isn't a `data-` tag, a +survey supplies more bodies than the catalog holds, or a count is missing. What each survey +supplies is `SUPPLIES` in `surveys.py`, from the catalog's README; a new survey is drawn +without one. The README's sentence above the chart and its alt text follow a new release. + `value.py` draws what spacevalue's price tables say a kilogram is worth at each place they price it, from Earth's surface out to the surface of Mars, for three things an asteroid holds: water, iron and platinum (`MATERIALS` in `refresh_counts.py`). That is eight rows, one diff --git a/tools/check.py b/tools/check.py index a322e19..4c359eb 100644 --- a/tools/check.py +++ b/tools/check.py @@ -61,6 +61,7 @@ "crossover.py": ".", "landforms.py": ".", "sources.py": ".", + "surveys.py": ".", "value.py": ".", "launch.py": ".", "flybys.py": ".", @@ -142,6 +143,7 @@ def check_counts(readme): ("crossover", lambda m: m.update_readme(readme)), ("landforms", lambda m: m.update_readme(readme)), ("sources", lambda m: m.update_readme(readme)), + ("surveys", lambda m: m.update_readme(readme)), ("value", lambda m: m.update_readme(readme)), ("launch", lambda m: m.update_readme(readme)), ("flybys", lambda m: m.update_readme(readme)), @@ -153,7 +155,7 @@ def check_counts(readme): continue if rewritten != readme: rerun = {"activity": "refresh_activity", "languages": "loc", "breakeven": "refresh_counts", - "crossover": "refresh_counts", "landforms": "refresh_counts", "sources": "refresh_counts", "value": "refresh_counts", "launch": "refresh_counts", + "crossover": "refresh_counts", "landforms": "refresh_counts", "sources": "refresh_counts", "surveys": "refresh_counts", "value": "refresh_counts", "launch": "refresh_counts", "flybys": "refresh_flybys", "sparks": "refresh_activity"}.get(name, name) problems.append(f"README numbers differ from tools/counts.json (rerun {rerun}.py)") for repo, n in counts["loc"].items(): diff --git a/tools/counts.json b/tools/counts.json index d28550d..bb8d9ff 100644 --- a/tools/counts.json +++ b/tools/counts.json @@ -1496,5 +1496,29 @@ "svm": 0.4584 } ] + }, + "catalog": { + "release": "data-2026-11-13", + "rows": 1580325, + "measured_diameters": 149718, + "rejected_rows": 275, + "sources": [ + { + "name": "JPL SBDB", + "bodies": 1580325 + }, + { + "name": "SsODNet", + "bodies": 1563656 + }, + { + "name": "NEOWISE", + "bodies": 143015 + }, + { + "name": "MP3C", + "bodies": 1335052 + } + ] } } diff --git a/tools/panel.py b/tools/panel.py index 6132ba6..6cffecb 100644 --- a/tools/panel.py +++ b/tools/panel.py @@ -1,5 +1,5 @@ """The frame the profile's wide panels share: activity.py, breakeven.py, crossover.py, -flybys.py, landforms.py, languages.py, pipeline.py, sources.py, value.py and launch.py all start their SVG with `background`, and all but +flybys.py, landforms.py, languages.py, pipeline.py, sources.py, surveys.py, value.py and launch.py all start their SVG with `background`, and all but pipeline.py write their alt text into the README with `write_alt`. It draws the tiles' navy gradient in a rounded border, a field of still stars, and a few diff --git a/tools/refresh_counts.py b/tools/refresh_counts.py index 446cc80..fb7f412 100644 --- a/tools/refresh_counts.py +++ b/tools/refresh_counts.py @@ -15,6 +15,10 @@ - skills, skill_categories: the opening line of Hermes_Skills' README. - catalog_rows: the row count in the manifest of AsteroidCatalog's latest release, shown everywhere as millions to two places ("1.58M", "about 1.58 million"). +- catalog: from the same manifest, the release's tag, how many bodies each source survey + supplied, how many have a measured diameter and how many rows validation refused. + surveys.py draws it; this also writes that chart's alt text and the sentence above it, + so run surveys.py afterwards. - economics: the destinations table in economicspace's README, the latest full-catalog run for each place the pipeline delivers to (best cost per dollar of revenue, the winning asteroid, the median body's). breakeven.py draws it; this also writes that @@ -77,13 +81,14 @@ def live_counts(): if sources < 100: sys.exit(f"sources.csv has only {sources} rows; refusing to publish that") with urllib.request.urlopen(MANIFEST, timeout=30) as r: - rows = int(json.loads(r.read().decode("utf-8"))["rows"]) - if rows < 1_000_000: - sys.exit(f"AsteroidCatalog's latest manifest says {rows} rows; refusing to publish that") + catalog_manifest = r.read().decode("utf-8") + built = surveys(catalog_manifest) + rows = built["rows"] tag = price_release() manifest = download(tag, "manifest.json") tables = {dest: download(tag, f"mineral_value_catalog.{dest}.csv") for dest in json.loads(manifest)["destinations"]} return {"sources": sources, "research": research(registry), "skills": int(m[1]), "skill_categories": int(m[2]), "catalog_rows": rows, + "catalog": built, "economics": destinations(fetch("economicspace/main/README.md")), "belt": crossovers(fetch("asteroid-belt-gradient/main/results/summary.json")), "value": prices(tag, manifest, tables), @@ -96,6 +101,27 @@ def millions(rows): return f"{rows / 1e6:.2f}" +def surveys(manifest): + """What AsteroidCatalog's latest release is built from, from its manifest: {release, rows, + measured_diameters, rejected_rows, sources: [{name, bodies}]}, the sources in the + manifest's order (JPL first, the backbone every row is keyed to).""" + try: + m = json.loads(manifest) + data = {"release": str(m["release_tag"]), "rows": int(m["rows"]), "measured_diameters": int(m["measured_diameters"]), + "rejected_rows": int(m["rejected_rows"]), + "sources": [{"name": str(name), "bodies": int(n)} for name, n in m["sources"].items()]} + except (ValueError, KeyError, TypeError, AttributeError) as e: + sys.exit(f"AsteroidCatalog's latest manifest no longer says what it is built from in the form expected: {e!r}") + rows = data["rows"] + if rows < 1_000_000: + sys.exit(f"AsteroidCatalog's latest manifest says {rows} rows; refusing to publish that") + if (not re.fullmatch(r"data-\d{4}-\d{2}-\d{2}\w*", data["release"]) or len(data["sources"]) < 2 + or not all(s["name"] and 0 < s["bodies"] <= rows for s in data["sources"]) + or not 0 < data["measured_diameters"] <= rows or data["rejected_rows"] < 0): + sys.exit(f"AsteroidCatalog's latest manifest doesn't look right: {data}") + return data + + def destinations(readme): """The rows of economicspace's destinations table: [{dest, best, winner, median}]. Bold, code marks and footnote signs are dropped; the winner is the asteroid and its @@ -336,14 +362,16 @@ def main(): # counts.json also holds loc.py's line counts; keep them. data = json.loads(path.read_text(encoding="utf-8")) | counts write(path, json.dumps(data, indent=2) + "\n") - import breakeven, crossover, landforms, launch, sources, value # read the counts just written - for chart in (breakeven, crossover, landforms, sources, value, launch): + import breakeven, crossover, landforms, launch, sources, surveys, value # read the counts just written + for chart in (breakeven, crossover, landforms, sources, surveys, value, launch): write(readme_path, chart.update_readme(readme_path.read_text(encoding="utf-8"))) - print(" ".join(f"{k}={v}" for k, v in counts.items() if k not in ("economics", "belt", "research", "value", "launch", "mars"))) + print(" ".join(f"{k}={v}" for k, v in counts.items() if k not in ("economics", "belt", "research", "value", "launch", "mars", "catalog"))) print(" ".join(f"{r['dest']}={r['best']}" for r in counts["economics"])) print(" ".join(f"{r['sample']}={r['a50']}" for r in counts["belt"]["crossover"])) print(counts["value"]["release"], " ".join(f"{r['dest']}={r['prices']['water']}" for r in counts["value"]["rows"])) - print("Mars", " ".join(f"{m}={v['accuracy']}" for m, v in counts["mars"]["models"].items())) + print(counts["catalog"]["release"], " ".join(f"{s['name']}={s['bodies']}" for s in counts["catalog"]["sources"]), + f"measured={counts['catalog']['measured_diameters']}") + print("Mars"," ".join(f"{m}={v['accuracy']}" for m, v in counts["mars"]["models"].items())) print("spacecost", counts["launch"]["version"], " ".join(f"{r['name']}={r['usd_per_kg']}" for r in counts["launch"]["rows"][:5])) diff --git a/tools/surveys.py b/tools/surveys.py new file mode 100644 index 0000000..da47d25 --- /dev/null +++ b/tools/surveys.py @@ -0,0 +1,173 @@ +"""Generate the surveys chart (docs/surveys.svg, docs/surveys-compact.svg): what +AsteroidCatalog's latest release is built from, one bar for each source survey, and how +few of its asteroids have a measured diameter. + +Each survey's bar runs across the whole catalog, filled for the bodies that survey supplies, +the most first: JPL's SBDB is the backbone every row is keyed to, so it fills the track. +Below them, one bar splits the catalog's diameters into the measured (gold) and those the +catalog estimates from brightness and an assumed albedo (hollow), so the two read apart +without colour. On desktop each survey is named with what it supplies; phones get the names +and shorter counts. + +The numbers are refresh_counts.py's, read from the latest release's manifest.json and kept +in tools/counts.json ("catalog"), so this draws the same thing until a new release. When +the chart loads the bars grow from the left, a row at a time; with reduced motion they are +drawn finished. + +`surveys.svg` is for desktop widths. `surveys-compact.svg` drops the descriptions and uses +larger text, for phones; the README swaps it in with . +""" +import html +import json +import re +import sys +from pathlib import Path + +import panel + +FONT = "'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif" +BLUE, TEXT, DIM, GOLD, LABEL = "#5ba3dc", "#dbe3f5", "#7d8fb3", "#e8c27a", "#b9c6e4" +SMALL = panel.SMALL + +CATALOG = json.loads((Path(__file__).parent / "counts.json").read_text(encoding="utf-8"))["catalog"] +ROWS, RELEASE = CATALOG["rows"], CATALOG["release"] +SOURCES = sorted(CATALOG["sources"], key=lambda s: (-s["bodies"], s["name"])) +MEASURED = CATALOG["measured_diameters"] +# What each survey supplies, as the catalog's README says; a new one is drawn without. +SUPPLIES = { + "JPL SBDB": "orbits, brightness, and which body is which", + "SsODNet": "best-of-literature sizes, albedos, masses, spins and taxonomy", + "MP3C": "sizes, albedos, collisional families and proper elements", + "NEOWISE": "thermal-infrared sizes and albedos", +} + + +def pct(n, of=ROWS): + """A share as the profile writes it: 100%, 84.5%, 9.5%, and >99.9% for all but a few.""" + v = 100 * n / of + return "100%" if n == of else ">99.9%" if v >= 99.95 else f"{v:.1f}%" + + +def short(n): + """1580325 -> 1.58M, 143015 -> 143k: the counts phones get.""" + return f"{n / 1e6:.2f}M" if n >= 1e6 else f"{n / 1e3:.0f}k" if n >= 1e3 else f"{n}" + + +def sentence(data): + """The README's sentence on the chart, after its bold lead, from the numbers.""" + rows, srcs = data["rows"], sorted(data["sources"], key=lambda s: -s["bodies"]) + top, least = srcs[0], srcs[-1] + knows = "every one of them" if top["bodies"] == rows else f"{top['bodies']:,} of them" + return (f"The bodies each survey supplies to AsteroidCatalog's latest release, {data['release']}, out of its " + f"{rows:,} asteroids. {top['name']} knows {knows}; {least['name']}, the fewest, {least['bodies']:,}. " + f"Only {data['measured_diameters']:,} ({pct(data['measured_diameters'], rows)}) have a measured diameter; the " + f"rest are estimated from brightness and an assumed albedo.") + + +ALT = (f"What AsteroidCatalog's {RELEASE} release is built from: {ROWS:,} asteroids. The bodies each source survey " + "supplies: " + "; ".join(f"{s['name']} {s['bodies']:,} ({pct(s['bodies'])})" for s in SOURCES) + + f". {MEASURED:,} ({pct(MEASURED)}) have a measured diameter, the rest estimated from brightness; validation " + f"refused {CATALOG['rejected_rows']:,} rows.") + + +def background(w, h, seed): + return panel.background(w, h, seed, ALT, rules=panel.GROW, animated=("grow",)) + + +def render(w, seed, pad, big, size, row_gap, count_w, full): + small = size * SMALL + head = pad + big * 0.8 + top = head + size * 2.6 + size * 2.2 + gap = row_gap * 0.4 # between the surveys and the diameters + bottom = top + len(SOURCES) * row_gap + gap + size * 1.4 + h = round(bottom + size * 2.6 + pad * 0.7) + x0, track = pad, w - 2 * pad - count_w + bar = size * 0.7 + parts = [background(w, h, seed), f'', + f'{pct(MEASURED)}', + f'' + + html.escape(f"of the catalog's {ROWS:,} asteroids have a measured diameter" if full else + f"of {short(ROWS)} asteroids have a measured diameter", quote=False) + '', + f'' + + html.escape(f"AsteroidCatalog {RELEASE}: the bodies each survey supplies, and the diameters. " + f"Validation refused {CATALOG['rejected_rows']:,} rows." if full else + f"{RELEASE}, by survey:", quote=False) + ''] + + def row(y, k, name, about, segments, right): + """A label line, then a bar across the catalog: segments are (width share, style).""" + parts.append(f'{html.escape(name)}' + + (f' {html.escape(about)}' if full and about else "") + + '') + by = y + size * 0.55 + parts.append(f'') + parts.append(f'') + at = x0 + for share, style in segments: + width = track * share + if style == "hollow": + parts.append(f'') + else: + parts.append(f'') + at += width + 2 # a 2px gap between segments + parts.append("") + ty = by + bar / 2 + size * 0.35 + if full: + parts.append(f'{right[0]}') + parts.append(f'{right[1]}') + else: + parts.append(f'{right[0]}') + + for k, s in enumerate(SOURCES): + right = (f"{s['bodies']:,}", pct(s["bodies"])) if full else (short(s["bodies"]),) + row(top + k * row_gap, k, s["name"], SUPPLIES.get(s["name"], ""), [(s["bodies"] / ROWS, BLUE)], right) + dy = top + len(SOURCES) * row_gap + gap + right = (f"{MEASURED:,}", pct(MEASURED)) if full else (short(MEASURED),) + row(dy, len(SOURCES), "Measured diameters", "the rest estimated from brightness", + [(MEASURED / ROWS, GOLD), (1 - MEASURED / ROWS, "hollow")], right) + # What the diameter bar's two parts are. + ly = bottom + size * 1.9 + s = size * 0.8 + parts.append(f'') + parts.append(f'' + + ("measured diameter" if full else "measured") + '') + lx = pad + size * (11 if full else 6.4) + parts.append(f'') + parts.append(f'' + + ("estimated from its brightness (H) and an assumed albedo" if full else "estimated") + '') + parts.append("\n\n") + # Wider than the default margin: a star in the gap between a bar's end and its count + # reads as a mark beside the number. + return panel.keep_clear("\n".join(parts), pad=24) + + +def update_readme(readme): + """The README with this chart's alt text written in, and the sentence above it saying + what the release is built from, so the prose can't keep an old release's numbers. + refresh_counts.py calls it after refreshing the counts; check.py checks it.""" + readme = panel.write_alt(readme, "surveys.svg", ALT) + readme, n = re.subn(r"(?m)^(\*\*What the catalog is built from\.\*\* ).*$", lambda m: m[1] + sentence(CATALOG), readme) + if n != 1: + sys.exit(f"README's sentence above the surveys chart matched {n} times, expected 1") + return readme + + +def files(): + return { + "surveys.svg": render(1200, 61, 40, 52, 19, 62, 200, True), + "surveys-compact.svg": render(680, 62, 36, 60, 24, 66, 110, False), + } + + +def main(): + out = Path(sys.argv[1]) + out.mkdir(parents=True, exist_ok=True) + for file, svg in files().items(): + (out / file).write_text(svg, encoding="utf-8", newline="\n") + print(file) + + +if __name__ == "__main__": + main() diff --git a/tools/test_tools.py b/tools/test_tools.py index 6c3a8f0..836bb9e 100644 --- a/tools/test_tools.py +++ b/tools/test_tools.py @@ -157,6 +157,30 @@ def stops(name, f, *args): eq("README sentence follows", co.finding(co.CORRECTED, co.SNOW) in co.update_readme(profile), True) stops("README sentence gone", co.update_readme, profile.replace("Corrected, the turn sits", "Corrected, it sits")) +# What AsteroidCatalog's latest release is built from (refresh_counts.py) and what the +# chart says of it (surveys.py), so a new release can't leave the old counts in the prose. +def MANIFEST(**over): + return json.dumps({"release_tag": "data-2026-11-13", "rows": 1580325, "measured_diameters": 149718, "rejected_rows": 275, + "sources": {"JPL SBDB": 1580325, "SsODNet": 1563656, "NEOWISE": 143015, "MP3C": 1335052}} | over) +built = rc.surveys(MANIFEST()) +eq("manifest read", (built["release"], built["rows"], built["sources"][2]), ("data-2026-11-13", 1580325, {"name": "NEOWISE", "bodies": 143015})) +stops("too few rows", rc.surveys, MANIFEST(rows=900_000, sources={"JPL SBDB": 900_000, "MP3C": 1})) +stops("a source above the catalog", rc.surveys, MANIFEST(sources={"JPL SBDB": 1580325, "MP3C": 1580326})) +stops("no sources", rc.surveys, MANIFEST(sources={})) +stops("not a data release", rc.surveys, MANIFEST(release_tag="v0.13.2")) +stops("measured count gone", rc.surveys, json.dumps({k: v for k, v in json.loads(MANIFEST()).items() if k != "measured_diameters"})) +sv = load("surveys") +eq("catalog sentence", sv.sentence(built), + "The bodies each survey supplies to AsteroidCatalog's latest release, data-2026-11-13, out of its 1,580,325 " + "asteroids. JPL SBDB knows every one of them; NEOWISE, the fewest, 143,015. Only 149,718 (9.5%) have a measured " + "diameter; the rest are estimated from brightness and an assumed albedo.") +eq("no source knows them all", " JPL SBDB knows 1,500,000 of them; MP3C, the fewest, 2. Only " + in sv.sentence(rc.surveys(MANIFEST(sources={"JPL SBDB": 1500000, "MP3C": 2}))), True) +eq("short counts", [sv.short(n) for n in (1580325, 143015, 999)], ["1.58M", "143k", "999"]) +eq("shares", [sv.pct(n, 1580325) for n in (1580325, 1580324, 149718)], ["100%", ">99.9%", "9.5%"]) +eq("README sentence follows", sv.sentence(sv.CATALOG) in sv.update_readme(profile), True) +stops("README sentence gone", sv.update_readme, profile.replace("**What the catalog is built from.**", "**What it's built from.**")) + # The Mars project's landform scores (refresh_counts.py) and what the chart says of them # (landforms.py), so a rescored map can't leave the old words, and a score file that grows # a second held-out map, or scores the two on different polygons, stops the refresh.