orbitsift 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. orbitsift/__init__.py +2 -0
  2. orbitsift/_native.py +13 -0
  3. orbitsift/ades.py +166 -0
  4. orbitsift/archives/__init__.py +244 -0
  5. orbitsift/archives/cadc.py +97 -0
  6. orbitsift/archives/decam_geom.json +1 -0
  7. orbitsift/archives/eso.py +213 -0
  8. orbitsift/archives/hsc_geom.json +2378 -0
  9. orbitsift/archives/ing.py +70 -0
  10. orbitsift/archives/listing.py +22 -0
  11. orbitsift/archives/noirlab.py +302 -0
  12. orbitsift/archives/ps1.py +59 -0
  13. orbitsift/archives/sdss.py +52 -0
  14. orbitsift/archives/smoka.py +369 -0
  15. orbitsift/blind.py +558 -0
  16. orbitsift/catalog.py +328 -0
  17. orbitsift/cli.py +2200 -0
  18. orbitsift/config.py +85 -0
  19. orbitsift/confirm.py +1030 -0
  20. orbitsift/data/nsc_dr2_k4m_ksb.csv.gz +0 -0
  21. orbitsift/dense.py +788 -0
  22. orbitsift/dynamics.py +235 -0
  23. orbitsift/expindex.py +456 -0
  24. orbitsift/extend.py +690 -0
  25. orbitsift/external.py +204 -0
  26. orbitsift/extract.py +148 -0
  27. orbitsift/growth.py +224 -0
  28. orbitsift/images.py +676 -0
  29. orbitsift/itf.py +154 -0
  30. orbitsift/known.py +716 -0
  31. orbitsift/link.py +509 -0
  32. orbitsift/lov.py +642 -0
  33. orbitsift/mcp_server.py +164 -0
  34. orbitsift/multiyear.py +409 -0
  35. orbitsift/net.py +265 -0
  36. orbitsift/orbit.py +614 -0
  37. orbitsift/plugins.py +97 -0
  38. orbitsift/precovery.py +187 -0
  39. orbitsift/presets/a2.json +85 -0
  40. orbitsift/presets/confirm_v1.json +190 -0
  41. orbitsift/presets/confirm_v2.json +236 -0
  42. orbitsift/presets/lostrec.json +74 -0
  43. orbitsift/recover.py +377 -0
  44. orbitsift/rubin.py +328 -0
  45. orbitsift/survey.py +268 -0
  46. orbitsift/tiles.py +58 -0
  47. orbitsift/unused.py +103 -0
  48. orbitsift/vet.py +304 -0
  49. orbitsift/workflow/__init__.py +5 -0
  50. orbitsift/workflow/models.py +103 -0
  51. orbitsift/workflow/sqlite.py +189 -0
  52. orbitsift-0.1.0.dist-info/METADATA +443 -0
  53. orbitsift-0.1.0.dist-info/RECORD +56 -0
  54. orbitsift-0.1.0.dist-info/WHEEL +4 -0
  55. orbitsift-0.1.0.dist-info/entry_points.txt +3 -0
  56. orbitsift-0.1.0.dist-info/licenses/LICENSE +28 -0
@@ -0,0 +1,189 @@
1
+ """Single coordinator/local-disk SQLite backend; workers use coordinator RPC later.
2
+
3
+ Expired leases are quarantined, not reassigned: a lost connection is not proof
4
+ that a worker stopped. Only an operator/coordinator may release a blocked job.
5
+ """
6
+ from contextlib import contextmanager
7
+ import json
8
+ import math
9
+ import sqlite3
10
+ import time
11
+ import uuid
12
+
13
+ from .models import Job, Result, canonical, identifier
14
+
15
+
16
+ class Conflict(ValueError):
17
+ pass
18
+
19
+
20
+ class StaleLease(Conflict):
21
+ pass
22
+
23
+
24
+ class Queue:
25
+ def __init__(self, path):
26
+ self.db = sqlite3.connect(path, timeout=30, isolation_level=None)
27
+ self.db.row_factory = sqlite3.Row
28
+ self.db.execute("PRAGMA foreign_keys=ON")
29
+ self.db.execute("PRAGMA journal_mode=WAL")
30
+ version = self.db.execute("PRAGMA user_version").fetchone()[0]
31
+ if version not in (0, 1):
32
+ self.db.close()
33
+ raise ValueError("unsupported database version")
34
+ self.db.executescript('''
35
+ CREATE TABLE IF NOT EXISTS jobs (
36
+ id TEXT PRIMARY KEY, spec TEXT NOT NULL,
37
+ state TEXT NOT NULL CHECK(state IN ('queued','running','done','blocked')),
38
+ created REAL NOT NULL, result TEXT);
39
+ CREATE TABLE IF NOT EXISTS dependencies (
40
+ job TEXT REFERENCES jobs(id), dependency TEXT REFERENCES jobs(id),
41
+ PRIMARY KEY(job,dependency));
42
+ CREATE TABLE IF NOT EXISTS attempts (
43
+ token TEXT PRIMARY KEY, job TEXT NOT NULL REFERENCES jobs(id),
44
+ worker TEXT NOT NULL, started REAL NOT NULL, expires REAL NOT NULL,
45
+ ended REAL, outcome TEXT);
46
+ CREATE UNIQUE INDEX IF NOT EXISTS one_active_attempt ON attempts(job) WHERE ended IS NULL;
47
+ CREATE TABLE IF NOT EXISTS events (
48
+ sequence INTEGER PRIMARY KEY AUTOINCREMENT, job TEXT NOT NULL REFERENCES jobs(id),
49
+ at REAL NOT NULL, kind TEXT NOT NULL, detail TEXT NOT NULL);
50
+ CREATE INDEX IF NOT EXISTS job_state ON jobs(state,created);
51
+ PRAGMA user_version=1;
52
+ ''')
53
+
54
+ def close(self):
55
+ self.db.close()
56
+
57
+ @contextmanager
58
+ def _transaction(self):
59
+ self.db.execute("BEGIN IMMEDIATE")
60
+ try:
61
+ yield
62
+ self.db.execute("COMMIT")
63
+ except BaseException:
64
+ self.db.execute("ROLLBACK")
65
+ raise
66
+
67
+ def _event(self, job, kind, detail):
68
+ self.db.execute("INSERT INTO events(job,at,kind,detail) VALUES(?,?,?,?)",
69
+ (job, time.time(), kind, canonical(detail)))
70
+
71
+ def _enqueue(self, job):
72
+ # Snapshot mutable parameter dictionaries at the persistence boundary.
73
+ spec = canonical(job.to_dict())
74
+ job = Job.from_dict(json.loads(spec))
75
+ if self.db.execute("SELECT 1 FROM jobs WHERE id=?", (job.id,)).fetchone():
76
+ return job.id
77
+ for dep in job.dependencies:
78
+ if not self.db.execute("SELECT 1 FROM jobs WHERE id=?", (dep,)).fetchone():
79
+ raise Conflict("dependencies must already exist (DAG insertion order)")
80
+ self.db.execute("INSERT INTO jobs VALUES(?,?,'queued',?,NULL)", (job.id, spec, time.time()))
81
+ self.db.executemany("INSERT INTO dependencies VALUES(?,?)",
82
+ [(job.id, dep) for dep in set(job.dependencies)])
83
+ self._event(job.id, "enqueued", {})
84
+ return job.id
85
+
86
+ def enqueue(self, job):
87
+ with self._transaction():
88
+ return self._enqueue(job)
89
+
90
+ @staticmethod
91
+ def _duration(seconds):
92
+ if not isinstance(seconds, (int, float)) or not math.isfinite(seconds) or seconds <= 0:
93
+ raise ValueError("lease duration must be finite and positive")
94
+
95
+ def claim(self, worker, capabilities=(), lease_seconds=300):
96
+ identifier(worker)
97
+ self._duration(lease_seconds)
98
+ with self._transaction():
99
+ rows = self.db.execute('''SELECT * FROM jobs j WHERE state='queued' AND NOT EXISTS
100
+ (SELECT 1 FROM dependencies d JOIN jobs p ON d.dependency=p.id
101
+ WHERE d.job=j.id AND p.state!='done') ORDER BY created,id''')
102
+ for row in rows:
103
+ job = Job.from_dict(json.loads(row["spec"]))
104
+ if not set(job.requires).issubset(capabilities):
105
+ continue
106
+ token = uuid.uuid4().hex
107
+ now = time.time()
108
+ self.db.execute("INSERT INTO attempts VALUES(?,?,?,?,?,NULL,NULL)",
109
+ (token, job.id, worker, now, now + lease_seconds))
110
+ self.db.execute("UPDATE jobs SET state='running' WHERE id=?", (job.id,))
111
+ self._event(job.id, "claimed", {"worker": worker, "token": token})
112
+ return {"job": job.to_dict(), "id": job.id, "token": token,
113
+ "expires": now + lease_seconds}
114
+ return None
115
+
116
+ def _active(self, token):
117
+ row = self.db.execute('''SELECT a.*,j.state FROM attempts a JOIN jobs j ON j.id=a.job
118
+ WHERE token=?''', (token,)).fetchone()
119
+ if not row or row["ended"] is not None or row["state"] != "running" or row["expires"] <= time.time():
120
+ raise StaleLease("attempt no longer owns a live lease")
121
+ return row
122
+
123
+ def heartbeat(self, token, lease_seconds=300):
124
+ self._duration(lease_seconds)
125
+ with self._transaction():
126
+ self._active(token)
127
+ self.db.execute("UPDATE attempts SET expires=? WHERE token=?",
128
+ (time.time() + lease_seconds, token))
129
+
130
+ def complete(self, token, result: Result, followups=()):
131
+ followups = tuple(followups)
132
+ encoded = canonical(result.to_dict())
133
+ with self._transaction():
134
+ # Repeated delivery after a lost acknowledgement is safe, but differing
135
+ # results or a different followup list must never be silently accepted.
136
+ receipt = canonical({"result": json.loads(encoded), "followups": [j.id for j in followups]})
137
+ old = self.db.execute("SELECT outcome FROM attempts WHERE token=?", (token,)).fetchone()
138
+ if old and old["outcome"] == receipt:
139
+ return
140
+ row = self._active(token)
141
+ self.db.execute("UPDATE jobs SET state='done',result=? WHERE id=?", (encoded, row["job"]))
142
+ for job in followups:
143
+ self._enqueue(job)
144
+ self.db.execute("UPDATE attempts SET ended=?,outcome=? WHERE token=?",
145
+ (time.time(), receipt, token))
146
+ self._event(row["job"], "completed", {"token": token, "followups": [j.id for j in followups]})
147
+
148
+ def block(self, token, reason):
149
+ identifier(reason)
150
+ with self._transaction():
151
+ row = self._active(token)
152
+ self._block(row, reason)
153
+
154
+ def _block(self, row, reason):
155
+ self.db.execute("UPDATE jobs SET state='blocked' WHERE id=?", (row["job"],))
156
+ self.db.execute("UPDATE attempts SET ended=?,outcome=? WHERE token=?",
157
+ (time.time(), canonical({"blocked": reason}), row["token"]))
158
+ self._event(row["job"], "blocked", {"reason": reason, "token": row["token"]})
159
+
160
+ def quarantine_expired(self):
161
+ with self._transaction():
162
+ rows = self.db.execute("SELECT * FROM attempts WHERE ended IS NULL AND expires<=?",
163
+ (time.time(),)).fetchall()
164
+ for row in rows:
165
+ self._block(row, "lease_expired_execution_unknown")
166
+ return len(rows)
167
+
168
+ def release(self, job_id, *, evidence):
169
+ """Only after verifying the old process stopped or reconciling its outputs."""
170
+ identifier(evidence)
171
+ with self._transaction():
172
+ count = self.db.execute("UPDATE jobs SET state='queued' WHERE id=? AND state='blocked'",
173
+ (job_id,)).rowcount
174
+ if not count:
175
+ raise Conflict("only blocked jobs can be released")
176
+ self._event(job_id, "released", {"evidence": evidence})
177
+
178
+ def get(self, job_id):
179
+ row = self.db.execute("SELECT * FROM jobs WHERE id=?", (job_id,)).fetchone()
180
+ if not row:
181
+ raise KeyError(job_id)
182
+ return {**dict(row), "spec": json.loads(row["spec"]),
183
+ "result": json.loads(row["result"]) if row["result"] else None}
184
+
185
+ def events(self, after=0, limit=100):
186
+ if not 1 <= limit <= 1000:
187
+ raise ValueError("limit must be 1..1000")
188
+ return [{**dict(r), "detail": json.loads(r["detail"])} for r in self.db.execute(
189
+ "SELECT * FROM events WHERE sequence>? ORDER BY sequence LIMIT ?", (after, limit))]
@@ -0,0 +1,443 @@
1
+ Metadata-Version: 2.5
2
+ Name: orbitsift
3
+ Version: 0.1.0
4
+ Summary: Find slow moving objects (TNOs, Neptune Trojans, distant planets) in the NOIRLab Source Catalog DR2 and archival DECam images
5
+ Author: Gioele Cerati
6
+ License-Expression: BSD-3-Clause
7
+ License-File: LICENSE
8
+ Classifier: Intended Audience :: Science/Research
9
+ Classifier: License :: OSI Approved :: BSD License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
12
+ Requires-Python: >=3.10
13
+ Requires-Dist: astropy>=5.2
14
+ Requires-Dist: jplephem>=2.15
15
+ Requires-Dist: numpy>=1.23
16
+ Requires-Dist: scipy>=1.9
17
+ Requires-Dist: tomli>=2.0; python_version < '3.11'
18
+ Provides-Extra: mcp
19
+ Requires-Dist: mcp>=1.2; extra == 'mcp'
20
+ Provides-Extra: native
21
+ Requires-Dist: orbitsift-native; extra == 'native'
22
+ Provides-Extra: photutils
23
+ Requires-Dist: photutils>=2.0; extra == 'photutils'
24
+ Provides-Extra: plots
25
+ Requires-Dist: matplotlib>=3.5; extra == 'plots'
26
+ Provides-Extra: rebound
27
+ Requires-Dist: rebound>=4; extra == 'rebound'
28
+ Provides-Extra: test
29
+ Requires-Dist: pytest>=7; extra == 'test'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # OrbitSift
33
+
34
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24568670.svg)](https://doi.org/10.5281/zenodo.24568670)
35
+
36
+ https://github.com/user-attachments/assets/2a331002-414f-4be6-ad8a-e8838077b22a
37
+
38
+ OrbitSift finds distant, slow-moving Solar System objects (trans-Neptunian objects, Neptune Trojans,
39
+ Centaurs) in public archival data: the NOIRLab Source Catalog DR2 (NSC DR2) and archival DECam images.
40
+ It links single-night detections across nights with an exact parallax model, removes the chance
41
+ alignments, fits barycentric orbits, searches the catalogue and the image archive for more detections,
42
+ tests Neptune-Trojan candidates with an N-body integration, and writes observation reports in the MPC's
43
+ ADES format.
44
+
45
+ **Why it matters.** More than a decade of public DECam data contains distant objects that no survey has
46
+ reported: they were caught on a few scattered nights by programmes looking for something else. Finding
47
+ them needs no telescope time and no account, only care: most multi-night "movers" in a catalogue are
48
+ chance alignments. OrbitSift runs on a laptop against free public services, and every stage has a
49
+ measurable, testable rule.
50
+
51
+ ```
52
+ $ orbitsift run --tile 18.5 -7.5 --ident --outdir quick
53
+ 018-08: 7324 detections, 41 nights -> 2 links (>= 5 nights: 1) in 1.8 s
54
+ # nights dist rms" V RA Dec result
55
+ 0 5 37 0.015 21.2 18.5131 -7.5864 SURVIVES known nearby: 523735 (2014 QX441) (0"), (2014 SG378) (1695")
56
+ 1 4 37 0.514 20.5 18.4982 -7.9930 veto miss,crtrail
57
+ 1 of 2 links survive
58
+ ```
59
+
60
+ One public tile, 28,681 single-night catalogue objects, two candidate links: the chance alignment is
61
+ vetoed, and the real mover is the known TNO 2014 QX441, found blind on its 5 nights in 2018.
62
+
63
+ ## What it has found
64
+
65
+ OrbitSift is the software behind the OrbitSift Archival Survey, the author's own search of NSC DR2,
66
+ DECam images of 2020-2026 and Subaru HSC. The survey paper
67
+ ([arXiv:2611.14330](https://arxiv.org/abs/2611.14330)) is the reference for the method, the evidence
68
+ classes and the results; the registry is kept up to date at
69
+ [cerati.org/astronomy.html](https://cerati.org/astronomy.html). On 22 November 2026 it held **384 objects**:
70
+
71
+ - **6 candidate L4 Neptune Trojans** (librating in N-body integrations of their orbit clones) and
72
+ **9 Centaurs**;
73
+ - about 75 resonant or probably resonant objects, mostly plutinos and 2:1;
74
+ - classical, detached and scattered-disc objects, a few with a beyond 300 AU;
75
+ - 20 of the 384 were later matched to a designated object; they stay in the list, marked as such.
76
+
77
+ These are candidates. 38 have been reported to the MPC and are under review; the rest are not reported
78
+ yet. The page gives class, size range and a rounded orbit; positions and full orbits stay private until
79
+ designation.
80
+
81
+ To cite OrbitSift, cite the release archive on Zenodo
82
+ ([doi:10.5281/zenodo.24568670](https://doi.org/10.5281/zenodo.24568670)) and the survey paper; the paper
83
+ describing OrbitSift itself is coming soon on arXiv ([CITATION.cff](CITATION.cff)).
84
+
85
+ ## Validation
86
+
87
+ [docs/VALIDATION.md](docs/VALIDATION.md) scores OrbitSift on known, designated objects against JPL, with
88
+ every case listed, the misses included. It is generated by `python benchmarks/validate.py` from public
89
+ NSC DR2 data and JPL Horizons truth in `benchmarks/fixtures/validation` (offline; ~50 MB, not in the repository:
90
+ `python benchmarks/fixtures_bundle.py unpack BUNDLE` puts the bundle in place; the bundles are in the Zenodo
91
+ archive of the release, [doi:10.5281/zenodo.24568670](https://doi.org/10.5281/zenodo.24568670); `--refresh`
92
+ downloads it all again). Tiles and objects were picked from JPL predictions alone, before the linker ran.
93
+ The key numbers:
94
+
95
+ - **Blind linking:** 15 of 18 linkable known TNOs (25-96 AU) are linked; only 9 of 18 also pass the
96
+ vetoes (missing-night and Kepler vetoes cost real objects; see the report).
97
+ - **False links:** in 40.6 deg² of controls (each night's detections rotated, so nothing real lines up),
98
+ 0.30 links per deg² survive the vetoes, none with 5 or more nights.
99
+ - **Orbits from archival data alone:** on multi-year NSC DR2 arcs of 11 objects, median |Δa|/a = 0.01% and
100
+ |Δi| = 0.0002° from JPL; arcs under 70 days miss a by a median 20% (worst 81%).
101
+ - **Astrometry:** NSC DR2 positions are 0.13" rms per coordinate from JPL; forced measurements on the
102
+ DECam images 0.031" (12 CCDs).
103
+ - **Short arc + other archives:** `extend` grows a 27-day NSC DR2 arc of the Centaur 2015 BH518 to 1067
104
+ days with 10 new DECam and VST nights (0 false); |Δa|/a against JPL 2.0% -> 0.006%.
105
+ - **Uncertainties:** JPL's a, e, i fall inside OrbitSift's 68% sample interval in 68% of 111 cases, and
106
+ inside the 99.7% interval in only 93% (multi-year arcs are overconfident).
107
+
108
+ The report also covers precovery, Neptune-Trojan and plutino libration against the literature, and
109
+ objects beyond 55 AU. `pytest` runs a quick subset and fails below the floors in `THRESHOLDS`.
110
+
111
+ **Speed.** `python benchmarks/run.py` times the pipeline offline on cached NSC DR2 data and checks
112
+ every output bit for bit against golden files. Against the original implementation, with the optional
113
+ native kernels: orbit fit 18.8x faster (0.25 s), 1000 orbit samples 18x (0.6 s), linking a tile
114
+ 4.6-6.2x (0.9 s for the quickstart tile, 2.1 s for a 57-night tile). Outputs are identical with and
115
+ without the kernels.
116
+
117
+ ## Install
118
+
119
+ Python 3.10 or newer; on recent macOS use 3.11 or newer (the last SciPy wheels for 3.10 fail to load there).
120
+
121
+ ```bash
122
+ git clone https://github.com/gioelecerati/orbitsift.git
123
+ cd orbitsift
124
+ python -m venv .venv && . .venv/bin/activate
125
+ pip install -e . # core: numpy, scipy, astropy
126
+ pip install -e ".[plots]" # + matplotlib, for stamp montages and libration plots
127
+ pip install ./native # optional compiled kernels (needs Rust), same results, faster (link --mode dense:
128
+ # hundreds of times on crowded tiles);
129
+ # or a prebuilt wheel from the 'native wheels' workflow: pip install orbitsift_native-*.whl
130
+ pip install -e ".[mcp]" # optional MCP server for agents: orbitsift-mcp
131
+ ```
132
+
133
+ Downloads are cached in the platform cache directory (`~/Library/Caches/orbitsift`,
134
+ `~/.cache/orbitsift`, `%LOCALAPPDATA%\orbitsift\Cache`), or in `--cache-dir` / `$ORBITSIFT_CACHE`.
135
+ `ORBITSIFT_NATIVE=0` turns the kernels off ([native/README.md](native/README.md)).
136
+
137
+ ## Five-minute quickstart
138
+
139
+ The tile of RA 18-19, Dec -8..-7, where NSC DR2 has 41 nights and 2014 QX441 was observed on 5:
140
+
141
+ ```bash
142
+ orbitsift run --tile 18.5 -7.5 --ident --outdir quick # the output above
143
+ # the surviving link as ADES (your name; observers = who took the images)
144
+ orbitsift export-ades quick/018-08_vet.json -o qx441.psv --submitter "J. Smith" --observers "A. Observer" --allow-ids # designated: its NSC ids may be sent
145
+ orbitsift fit qx441.psv --samples 500 # barycentric orbit + uncertainty samples
146
+ orbitsift precover qx441.psv --max-tiles 8 # other nights in NSC DR2 (single-point candidates; see the guide)
147
+ orbitsift forced qx441.psv --start 2018-08-20 --end 2018-10-01 --plot # forced photometry on DECam CCDs
148
+ ```
149
+
150
+ Most of the time goes into the catalogue download and the static-source check (Data Lab TAP).
151
+ `examples/quickstart.py` does the catalogue part from Python; `examples/trojan_libration.py` reproduces
152
+ the Neptune-Trojan test offline after a one-time 32 MB download of the DE440s kernel.
153
+
154
+ ## How it works
155
+
156
+ ```mermaid
157
+ flowchart LR
158
+ A[NSC DR2 single-night objects<br/>and DECam exposures] --> B[link<br/>tile, 3x3 block, near/mid/far modes]
159
+ X[extract<br/>catalogue from CP images] -.-> B
160
+ B --> C[vet<br/>missing nights, cosmic rays, trails,<br/>intra-night, static, Kepler, known objects]
161
+ C --> D[fit<br/>barycentric orbit,<br/>uncertainty samples]
162
+ D --> E[precover<br/>catalogue search<br/>inside the orbit cloud]
163
+ D --> F[forced<br/>archival DECam CCDs,<br/>Gaia-tied PSF fits]
164
+ D --> J[extend<br/>other archives, 96 controls,<br/>leave one night out]
165
+ D --> G[libration / classify<br/>N-body Trojan test,<br/>dynamical class]
166
+ E --> H[export-ades<br/>file for a human to submit]
167
+ F --> H
168
+ J --> H
169
+ ```
170
+
171
+ | Stage | Command | What happens |
172
+ |---|---|---|
173
+ | Fetch | `fetch` | NSC DR2 objects seen on one night only, with Gaia DR3 / Legacy Survey DR10 crossmatch, and the DECam exposure list; rate-limited, retried, cached. |
174
+ | Clean | | Shape and flag cuts; objects with a Gaia or Legacy Survey counterpart are static and dropped. |
175
+ | Link | `link` | Bernstein & Khushalani (2000) motion with exact parallax: night pairs <= 40 days apart with a detection in between seed a closed-form distance; seeds are fitted and extended night by night. 30-150 AU, >= 4 nights by default; `--blocks 3` links over the 3x3 tiles around a tile (objects near 30 AU leave a tile within a season); `--near` covers 8-35 AU in any direction of motion; `--mode mid` 15-30 AU, `--mode far` 80-1500 AU; `--mode dense` (25-80 AU) is the anchor linker of the survey's production for crowded tiles, with an exposure cap and a clump mask (compiled core in `orbitsift-native`, Python fallback). |
176
+ | Vet | `vet` | Missing nights (deep exposures where the orbit predicts it but nothing is there), cosmic rays (threshold calibrated on known TNOs by depth margin), satellite trails, intra-night confirmation, static sources on other nights, and a bound two-body orbit within 0.2" rms. Optional known-object lookup (JPL sb_ident, two passes). |
177
+ | Orbit | `fit` | Barycentric two-body fit from any MPC site, light time, covariance; samples by statistical ranging (short arcs) or linear draws. |
178
+ | Precovery | `precover` | Exposures the orbit cloud crosses, weighted by detection probability; catalogue objects inside the cloud are refit with the arc and grown with companions. |
179
+ | Images | `forced` | Public archive CCDs that contain the prediction, one CCD at a time; Gaia-tied forced PSF photometry; static check on other nights; stamp montage. |
180
+ | Recover | `recover` | A known object with a short or old arc: its published astrometry seeds the multi-year growth stage, searched along its corridor over 2012-2019 (frozen rule of the survey, shift controls; native kernels). |
181
+ | Confirm | `confirm` | An independent image test of a candidate: local exposure tables (DECam, CFHT MegaCam, Subaru HSC) give the exposures its rows never used; forced photometry and a stack with local, null and twin control tracks; the rows checked on their own images; joint fit, leave-one-opposition-out, known-object check; a tiered verdict with frozen thresholds and the control rates beside it. Only exposure and file ids are sent. |
182
+ | Extend | `extend` | A short arc grown with other archives: CADC SSOIS lists the CFHT, DECam, VST, Pan-STARRS1, Subaru and Gemini exposures of the orbit clones; cutouts are stacked along the clones against 96 control tracks; PSF fits and a refit, repeated while the cloud shrinks. |
183
+ | Dynamics | `libration`, `classify` | Sun + 4 giants N-body of the orbit clones for 100 kyr: L4 / L5 librator, escaped, or other. `classify`: 10-Myr REBOUND run of the covariance clones and the Gladman/OSSOS classes (resonant p:q, Centaur, scattering, detached, classical). |
184
+ | Catalogue | `extract` | For DECam data the NSC DR2 does not cover: a single-epoch source catalogue from a Community Pipeline image and its data-quality mask. |
185
+ | Report | `export-ades` | ADES PSV of vetted links, forced measurements or `extend` points, with mid-exposure times and the right station per instrument; warnings for single-observation nights and astCat. |
186
+
187
+ Details and thresholds: [docs/method.md](docs/method.md). Settings: [docs/config.md](docs/config.md).
188
+ All commands: [docs/cli.md](docs/cli.md).
189
+
190
+ ## What it needs
191
+
192
+ Network access to free public services, no accounts: the Astro Data Lab TAP service (NSC DR2 objects and exposures,
193
+ about 2 MB per tile), the NOIRLab Astro Data Archive (DECam CCDs, about 32 MB each, one per exposure), Gaia DR3 and
194
+ Legacy Surveys DR10 crossmatches, JPL (SBDB, Horizons, sb_ident, the DE440s kernel, 32 MB once) and, for `extend`,
195
+ CADC SSOIS and the CADC, ESO, MAST, SDSS and ING archives. Everything downloaded is cached. Optional: Find_Orb
196
+ (`--backend findorb`), REBOUND (`pip install -e ".[rebound]"`, for `classify`), a SMOKA account (Subaru HSC frames;
197
+ OrbitSift writes the request, you send it). A laptop is enough for single tiles; a survey of thousands of tiles is a
198
+ matter of running tiles in parallel on several machines ([docs/guide-machines.md](docs/guide-machines.md)).
199
+
200
+ ## Guides
201
+
202
+ - [An end-to-end search on one tile](docs/guide-tile.md)
203
+ - [Extending a short arc](docs/guide-extend.md)
204
+ - [Other seasons along the line of variations](docs/guide-lov.md)
205
+ - [The known-object check at the designated objects' own dates](docs/guide-known-check.md)
206
+ - [Vetting and controls](docs/guide-vetting.md)
207
+ - [Building a single-epoch catalogue from images](docs/guide-catalogue.md)
208
+ - [Seeded recovery of a known object](docs/guide-recover.md)
209
+ - [Confirming a candidate on images it was never found on](docs/guide-confirm.md)
210
+ - [Running on several machines](docs/guide-machines.md)
211
+ - [Linking across years](docs/guide-multiyear.md)
212
+ - [The survey simulator: the selection function as a forward model](docs/guide-simulator.md)
213
+ - [Rubin Observatory data: alerts, Science Platform tables, images (plan and first part)](docs/RUBIN.md)
214
+
215
+ ## Rubin Observatory data
216
+
217
+ Rubin links moving objects itself, from pairs of detections per night within two weeks and for distances out to 10 au
218
+ (as documented). OrbitSift is for what that leaves: objects beyond 50-100 au, single detections per night, links across
219
+ seasons and years, and arc extension in other archives. `orbitsift rubin` turns the public alerts of a tile (Fink
220
+ broker, no account) into the tables the linkers read, and `link --rows` links them:
221
+
222
+ ```bash
223
+ orbitsift rubin --tile 329.5 -12.5 --start 2026-06-20 --end 2026-07-20 -o rubin
224
+ orbitsift --site X05 link --tile 329.5 -12.5 --rows rubin -o links.json # 1 link, 4 nights
225
+ orbitsift export-ades links.json --links 0 -o link0.psv --submitter "J. Smith" --observers "Rubin Observatory"
226
+ orbitsift known-check link0.psv # verdict known:2025 MQ350
227
+ ```
228
+
229
+ The adapter for Rubin Science Platform tables is written against the published schema and not tested on real data;
230
+ images through the Butler are a plan. The core vetoes do not run on these rows yet. All of it, with sources and
231
+ measured numbers: [docs/RUBIN.md](docs/RUBIN.md).
232
+
233
+ ## Extending a short arc
234
+
235
+ ```bash
236
+ orbitsift extend cand.psv --dry-run # the SSOIS searches it would make
237
+ orbitsift extend cand.psv --json # all archives; --archives cadc,noirlab to choose
238
+ ```
239
+
240
+ `extend` takes an arc of days to weeks and looks for the object in other archives. Each iteration draws
241
+ orbit clones from the fit, asks CADC SSOIS which images may hold them (only the clones' orbital elements
242
+ are sent, never the observations), and cuts the CCDs where the clones fall from the archives that allow
243
+ anonymous access: **CADC** (CFHT MegaCam, server-side cutouts), **NOIRLab** (DECam CP CCDs; raw Mosaic and
244
+ 90Prime frames of 2004-2016, calibrated here), **ESO** (raw VST/OmegaCAM, and raw VIMOS, WFI and EMMI with
245
+ night bias and flat from public frames), **MAST** (Pan-STARRS1 warps, only if the predicted V is <= 23.5;
246
+ points from single warps only if V <= 22), **SDSS** frames and the **ING** archive (INT WFC). Subaru HSC needs
247
+ a SMOKA account: `smoka` writes the request mail bodies for you to send and, once the raw frames are in your
248
+ SMOKA folder, reduces them (bias, flat, a Gaia DR3 TAN-SIP solution per CCD). Gemini exposures are listed
249
+ with instructions. No login is attempted and no credentials are read.
250
+
251
+ The cutouts are stacked along every clone (PSF matched filter, Gaia-tied WCS, Legacy Survey DR10 sources
252
+ masked) and the best clone must beat max(95th percentile, 1.5 x 90th percentile) of 96 control tracks (the
253
+ whole cloud shifted by 60-180"; a control on a star must not veto the object). On that
254
+ track each exposure gets a PSF fit; a point is kept at S/N >= 5, PSF width ratio 0.5-1.6 at S/N < 6 and 0.7-1.5 above, a magnitude
255
+ within 1 mag of the others and nothing at that sky position on other nights. The refit shrinks the
256
+ cloud, the next iteration reaches farther dates, and the loop ends when no new night comes in. A second
257
+ forced pass at the final orbit must find every point again. Every new night is then measured once more at an
258
+ orbit fitted without it, against the 96 controls (leave one night out; a night that survives this was predicted,
259
+ not only fitted; `--no-loo` skips it).
260
+ The verdict `consistent` needs >= 2 new nights whose static test ran (a night with no frame of another night at
261
+ that position does not count), rms <= 0.12", consistent magnitudes, the second pass and no night failing leave one
262
+ night out. It means the images agree with the orbit, not that the object is confirmed: the rate at which a false
263
+ link reaches `consistent` has not been measured (one benchmark object, no control arcs). The known-object check
264
+ stays yours.
265
+
266
+ Benchmark ([docs/VALIDATION.md](docs/VALIDATION.md), section 9, offline on ~11 MB of fixtures): from a 27-day,
267
+ 4-night NSC DR2 arc of the Centaur 2015 BH518, three iterations add 10 new nights (9 DECam, 1 VST), none false;
268
+ the arc grows to 1067 days and abs(Δa)/a against JPL drops from 2.0% to 0.006% (rms 0.087", all within 0.33" of
269
+ JPL; fixtures recorded 18 Nov 2026).
270
+
271
+ ## For agents
272
+
273
+ Every command has a machine interface: `--json` (one JSON document on stdout with explicit verdicts),
274
+ stable exit codes (0 result, 1 no result / not consistent, 2 bad input, 3 network, 4 internal),
275
+ `--dry-run` (queries, MB and time before fetching anything) and idempotent re-runs (an output made from
276
+ the same inputs is not recomputed). No prompts, and nothing is ever submitted.
277
+
278
+ ```bash
279
+ $ orbitsift run --tile 18.5 -7.5 --ident --outdir quick --json | jq -c '.result.links[] | [.index, .verdict]'
280
+ [0,"known:523735 (2014 QX441)"]
281
+ [1,"vetoed:miss,crtrail"]
282
+ ```
283
+
284
+ [AGENTS.md](AGENTS.md) has the rules an agent must follow (confirmation criteria, never submitting,
285
+ service limits), the workflow from a tile to a report, and the common pitfalls. `orbitsift-mcp`
286
+ serves the same commands as MCP tools.
287
+
288
+ ## Plugins
289
+
290
+ Detection sources, extra vetters, CLI commands and exporters can be added as ordinary Python packages
291
+ through entry points (`orbitsift.sources`, `orbitsift.vetters`, `orbitsift.commands`,
292
+ `orbitsift.exporters`), with no plugin framework. Vetters can only add vetoes or flags. `orbitsift
293
+ plugins` lists what is installed and why a plugin did not load. API and rules:
294
+ [docs/plugins.md](docs/plugins.md); a 40-line example (CSV exporter + vetter): [examples/plugin](examples/plugin).
295
+ The first official plugin, [plugins/satellites](plugins/satellites), fits orbits of irregular satellites of the giant
296
+ planets (`orbitsift satfit`, N-body with DE440s and REBOUND) and lists the known moons near them (`orbitsift satmoons`).
297
+ `orbitsift blindcheck` (core) searches registered FITS frames blind for any moving source and seals its notes (sha256)
298
+ before a prediction is compared with them.
299
+
300
+ ## Responsible use
301
+
302
+ OrbitSift **never submits anything** to the Minor Planet Center. Reporting is a human decision:
303
+
304
+ 1. **Check that the object is new**: `vet --ident`, then a wide search (JPL sb_ident or the MPC) on the
305
+ full arc. Objects with poor orbits can be degrees from their predicted place.
306
+ 2. **Confirm it**: at least two new nights fitted with the arc at rms <= 0.12", consistent magnitudes,
307
+ and the images (`forced --plot`): the source on the predicted spot each night, absent there on other
308
+ nights.
309
+ 3. **Archival data need approval**: reports from archival W84 (DECam) data need SARC approval. Contact
310
+ the archive's SARC member before you submit.
311
+ 4. **Avoid singletons**: the MPC discourages single observations per night; `export-ades` warns about
312
+ them. Keep each row's astCat (Gaia2 for NSC DR2 positions, Gaia3 for forced ones).
313
+ 5. **Write and check the file**: `export-ades` (observers = who took the images, from the FITS
314
+ `OBSERVER` keyword or the programme PI; you are the submitter and measurer). `--validate --email
315
+ ADDRESS` uses the MPC's validation-only endpoint.
316
+ 6. **Submit it yourself**, once, through the MPC's ADES submission page
317
+ (https://minorplanetcenter.net/submit_psv).
318
+
319
+ Be polite to the public services: OrbitSift spaces requests (1 s per host, at most 2 at a time, 1 for
320
+ JPL sb_ident) and caches everything. Keep those limits, run one process per service, and expect a large
321
+ survey to take days of wall time. Only public data are used: `forced` skips CCDs still in their
322
+ proprietary period.
323
+
324
+ ## Limitations
325
+
326
+ - **Depth.** NSC DR2 single exposures reach about V = 23-23.5; fainter movers are invisible to the
327
+ catalogue stage.
328
+ - **Cadence.** A tile needs >= 4 nights with a mover in the catalogue, 3 of them within 40 days; much of
329
+ the sky does not have that. Four-night links are mostly chance alignments that the vetoes must
330
+ remove; five or more nights are much more reliable.
331
+ - **Time span.** NSC DR2 stops in late 2019. Later DECam images are in the archive and `forced` uses them.
332
+ - **Data Lab load.** The TAP service is shared and is the bottleneck (20-200 s per tile, occasional
333
+ outages).
334
+ - **Orbits.** Two-body barycentric orbits are good to ~0.1" for TNOs over a few years, less so for
335
+ Centaurs or objects near a giant planet (`fit --backend findorb` fits with full perturbations). Short
336
+ arcs constrain distance and inclination, not a and e.
337
+ - **Known objects.** `--ident` uses JPL's fast two-body pass (~1' a decade from the orbit epoch).
338
+ - **`extend`.** It needs the archives' coverage (SSOIS) and anonymous access; VST raw frames are not
339
+ flat-fielded, PS1 warps are shallow, HSC/Suprime-Cam (often the deepest) are only listed, and DECam CCDs
340
+ missing from the NOIRLab HDU index are skipped. The stack needs a clone near the true track: clouds
341
+ longer than `--max-ext` (600") wait for a refit, so an arc must first reach nights within a few months.
342
+ - **Non-DECam data.** NSC DR2 also has Mosaic3 and 90Prime exposures; linking and vetting assume one
343
+ site (W84 by default), ADES export uses the right station per measurement.
344
+
345
+ ## Using peer-reviewed backends
346
+
347
+ The internal orbit fitter, integrator and forced measurement are the defaults (the search makes millions
348
+ of fits). For published results, three steps can be handed to established external codes, which
349
+ OrbitSift only calls:
350
+
351
+ ```bash
352
+ export ORBITSIFT_FINDORB=/path/to/fo # or put Find_Orb's fo on PATH
353
+ orbitsift fit cand.psv --backend findorb --json # orbit, covariance, rejected obs, fo version
354
+ orbitsift forced cand.psv --backend findorb --json # the confirmation refit with Find_Orb
355
+ pip install "orbitsift[rebound]"
356
+ orbitsift libration cand.psv --backend rebound --fit-backend findorb --json # WHFast, clones from fo's covariance
357
+ pip install "orbitsift[photutils]"
358
+ orbitsift forced cand.psv --measure photutils --backend findorb --json # positions and fluxes by photutils
359
+ ```
360
+
361
+ - **Find_Orb** (`--backend findorb`): build `fo` from https://github.com/Bill-Gray/find_orb and set
362
+ `JPL_FILENAME` (and `LINUX_JPL_FILENAME`) in `~/.find_orb/environ.dat` to a JPL DE440 file; OrbitSift
363
+ refuses a fit made without a DE ephemeris (exit 2). It writes the observations as ADES PSV (each
364
+ row's rmsRA/rmsDec as weights, else `[orbit] sigma`), runs `fo` in a temporary directory with your
365
+ Find_Orb settings (outlier rejection, perturbers) and returns the usual orbit JSON with
366
+ `backend: "findorb"` and `findorb` (version, ephemeris, perturbers, used/rejected observations, its own
367
+ elements and sigmas at the internal epoch). The state and covariance are at Find_Orb's epoch.
368
+ `--samples` are linear draws from its covariance. `precover` keeps the internal fitter. `fit` uses Find_Orb by
369
+ itself for arcs of 2 or more seasons (`[orbit] findorb_min_seasons`) when `fo` is installed (`--backend auto`, the default); without it the internal fit is
370
+ made and the result carries the warning `long_arc_internal_fit`. Single-season arcs stay internal.
371
+ - **REBOUND** (`libration --backend rebound`): the same bodies, masses, initial states and analysis as
372
+ the internal integrator, integrated with WHFast (step ~P_Jupiter/25), 30-100x faster here.
373
+ - **photutils** (`forced --measure photutils`): every forced measurement is made by photutils
374
+ (PSFPhotometry with a circular Gaussian PRF, LocalBackground, Background2D errors, aperture correction)
375
+ with the WCS from astropy.wcs: target centroid and flux, and the Gaia DR3 field-star centroids that tie
376
+ the position to Gaia; same output fields plus `backend: "photutils"` and its version. On 40 archival
377
+ CCDs (the 5 NSC DR2 detections of 2014 QX441 and 35 other forced measurements) it agrees with the
378
+ internal measurement to <= 0.015" (median 0.0002") and 0.90-1.06 in flux (median 1.01); on QX441 to
379
+ <= 0.005" and 0.2-0.7% (`tests/test_photutils.py`).
380
+ - Find_Orb and REBOUND are GPL. OrbitSift (BSD 3-Clause) contains no code of either: `fo` runs as a separate
381
+ program, REBOUND is an optional import. photutils (BSD-3) is an optional import too.
382
+ - Agreement on the Neptune Trojan 2005 TN53 (23 MPC observations, 2005-2007): Find_Orb and the internal
383
+ fit differ by 0.1-0.7 sigma in every element; REBOUND and the internal integrator give the same
384
+ libration centre and amplitude to 0.01 deg over 100 kyr (`tests/test_external.py`), and clones from
385
+ either fit give the same libration (centre 59.1 deg, amplitude 10.0 vs 9.9 deg).
386
+
387
+ Cite them when you use them: Find_Orb, Gray 2022, ascl:2202.016; REBOUND, Rein & Liu 2012, A&A 537,
388
+ A128; WHFast, Rein & Tamayo 2015, MNRAS 452, 376; JPL DE440, Park et al. 2021, AJ 161, 105; photutils,
389
+ Bradley et al., doi:10.5281/zenodo.596036 (cite the version you used); Astropy, Astropy Collaboration
390
+ 2022, ApJ 935, 167.
391
+
392
+ ## Acknowledging data and services
393
+
394
+ Cite the data and services you used and include their acknowledgement texts, **copying the official
395
+ wording from each provider's website**:
396
+
397
+ - **NSC DR2:** Nidever et al. 2021, AJ 161, 192 (and DR1: Nidever et al. 2018, AJ 156, 131); NSC pages
398
+ at https://datalab.noirlab.edu.
399
+ - **Astro Data Lab:** Fitzpatrick et al. 2014, SPIE 9149; Nikutta et al. 2020, Astronomy and Computing
400
+ 33, 100411.
401
+ - **DECam and the NOIRLab Astro Data Archive:** Flaugher et al. 2015, AJ 150, 150; the DECam / CTIO and
402
+ archive acknowledgements at https://noirlab.edu and https://astroarchive.noirlab.edu, and the
403
+ programme(s) whose images you used (PROPID in the FITS header).
404
+ - **Gaia DR3:** Gaia Collaboration, Vallenari et al. 2023, A&A 674, A1, and the DPAC acknowledgement
405
+ from https://www.cosmos.esa.int/gaia.
406
+ - **Legacy Surveys DR10** (static-source veto): Dey et al. 2019, AJ 157, 168; https://www.legacysurvey.org.
407
+ - **JPL** SBDB / Horizons / sb_ident: https://ssd.jpl.nasa.gov.
408
+ - **Method:** Bernstein & Khushalani 2000, AJ 120, 3323 (linking model).
409
+ - **External backends**, if used: Find_Orb (Gray 2022, ascl:2202.016), REBOUND (Rein & Liu 2012, A&A
410
+ 537, A128) with WHFast (Rein & Tamayo 2015, MNRAS 452, 376), MERCURIUS (Rein et al. 2019, MNRAS 485, 5490)
411
+ and IAS15 (Rein & Spiegel 2015, MNRAS 446, 1424), JPL DE440 (Park et al. 2021, AJ 161, 105), photutils
412
+ (Bradley et al., doi:10.5281/zenodo.596036).
413
+ - **Dynamical classes:** Gladman et al. 2008 (in The Solar System Beyond Neptune, 43); the DES variant:
414
+ Bernardinelli et al. 2022, ApJS 258, 41.
415
+ - **Other archives** used by `extend`: CADC and SSOIS (Gwyn et al. 2012, PASP 124, 579), CFHT MegaCam, ESO,
416
+ MAST and Pan-STARRS1, SDSS, the ING archive and SMOKA, each with its own acknowledgement.
417
+
418
+ ## Troubleshooting
419
+
420
+ - `CERTIFICATE_VERIFY_FAILED` (any service): Python's certificate bundle is missing or lacks the root the server
421
+ chains to. The python.org installers for macOS ship without one: run their `Install Certificates.command`, or point
422
+ Python at an up-to-date bundle, e.g. `export SSL_CERT_FILE="$(python -m certifi)"` after `pip install certifi`, or
423
+ your system's.
424
+
425
+ ## Development
426
+
427
+ ```bash
428
+ pip install -e ".[test,plots]"
429
+ pytest # offline tests (those that need the fixture bundle are skipped without it)
430
+ pytest -m network # tests against the live services
431
+ python benchmarks/run.py # offline timings; every output checked bit for bit against benchmarks/golden
432
+ ```
433
+
434
+ ## License
435
+
436
+ BSD 3-Clause, see [LICENSE](LICENSE). Changes: [CHANGELOG.md](CHANGELOG.md).
437
+
438
+ ## Workflow foundations
439
+
440
+ For integrations with worker fleets, the experimental [workflow library](docs/workflow.md)
441
+ provides versioned candidate/job/result records and a local SQLite coordinator with
442
+ exclusive leases, dependency tracking and atomic followup creation. It does not run
443
+ workers or promote completed jobs to scientific confirmations.