Cookbook¶
Stub
Final content will be 12–15 self-contained recipes, each a few lines of code with a one-paragraph "why" header. Drawn from the test suite so they're known-good shapes.
Planned recipes:
- Count sources in a survey footprint —
IN_MOC+COUNT(*). - Nearest-neighbor crossmatch of two catalogs — the canonical
XMATCHexample. - All matches within 5″ —
mode => 'all'. - LEFT crossmatch to keep unmatched sources —
LEFT JOIN ... ON XMATCH(...). - Crossmatch filtered by
XMATCH_DISTANCE— distance in WHERE. - Top-10 closest matches per anchor source — XMATCH + ORDER BY
- LIMIT.
- 3-way join: crossmatch then ordinary join — XMATCH a catalog,
then
a.id = lc.object_idagainst a lightcurve table. - Self-crossmatch — find pairs within one catalog (aliasing the same table twice).
- Filter by a survey footprint —
WHERE IN_MOC(a, 'des_dr2'). - Sources outside a footprint —
WHERE NOT IN_MOC(a, 'des'). - Per-source aggregates with
HAVING—GROUP BY a.id HAVING COUNT(*) >= 2. - Materialize a heavy intermediate, then iterate —
s.materialize(...)+ cheap follow-ups. - Stream a huge result to parquet —
acid query --out. - Write a single parquet file —
r.write_parquet(path, layout="single"). - Run a query from the CLI from a
.sqlfile —acid query -f q.sql --db ....
Every recipe will lead with r.df() (pandas) for familiarity and end
with a one-line "Faster on big results: df = r.to_polars(); ..."
note when the recipe does work beyond inspection.