#!/usr/bin/env python3 """Make a synthetic ComCat-like catalogue to check score_forecasts.py's code paths before any real data. python3 -I selftest_synthetic.py Events: a Poisson process, 1976 to November 2026, about 450 a year at magnitude 5.45 and above, with Gutenberg-Richter magnitudes (b = 1) and a short burst of smaller events after each one of magnitude 7 or more. It has nothing to do with real earthquakes; it only exercises the code. """ import datetime as dt import math import os import random import sys rng = random.Random(1) out = sys.argv[1] os.makedirs(out, exist_ok=True) t = dt.datetime(1976, 1, 1, tzinfo=dt.timezone.utc) end = dt.datetime(2026, 11, 1, tzinfo=dt.timezone.utc) rate = 450 / (365.25 * 86400) rows, n = [], 0 while t < end: t += dt.timedelta(seconds=rng.expovariate(rate)) m = 5.45 - math.log10(1 - rng.random()) n += 1 rows.append((t, m, f"syn{n}")) if m >= 7.0: for _ in range(rng.randint(1, 6)): n += 1 rows.append((t + dt.timedelta(hours=rng.uniform(0.1, 72)), 5.45 + rng.random() * (m - 6.4), f"syn{n}")) rows.sort() with open(os.path.join(out, "synthetic.csv"), "w", encoding="utf-8", newline="\n") as fh: fh.write("time,latitude,longitude,depth,mag,magType,id,type\n") for t, m, i in rows: if t < end: fh.write(f"{t.strftime('%Y-%m-%dT%H:%M:%S.000Z')},0,0,10,{m:.2f},mww,{i},earthquake\n") print(len(rows), "synthetic events")