cosmotron_mcp.tools.systematics_checks¶
compute_cterm ¶
compute_cterm(session_dir: str, bin_index: int, n_bootstrap: int = 300, jobspec: dict | None = None) -> dict
Additive shear c-term for a spin-2 bin: c_k = ⟨w·e_k⟩/⟨w⟩ vs σ_e.
Weighted means from the bin's standardised FITS; seeded bootstrap errors
(deterministic). Gate statistic max(|c1|,|c2|)/σ_e vs cterm_sigma_e_max_frac.
Writes results/systematics/cterm_bin_{i:02d}.json. Spin-2 bins only (spin-0 → needs_input).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_dir
|
str
|
Session directory. |
required |
bin_index
|
int
|
Tomographic bin index (must be spin-2). |
required |
n_bootstrap
|
int
|
Number of bootstrap resamples for the error estimate. |
300
|
jobspec
|
dict | None
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
The c-term result dict, written to |
dict
|
|
Source code in cosmotron_mcp/server.py
compute_psf_leakage ¶
PSF-ellipticity leakage for a spin-2 bin (Heymans-style; no treecorr).
Catalogue-level weighted regression α per component PLUS a harmonic
shear×PSF-ellipticity cross-Cℓ contamination fraction (gate statistic
max_ℓ |α·Cℓ^{e,PSF}|/σ(Cℓ) vs template_contamination_max_frac). Builds the
PSF Q/U map from the same catalogue and reuses compute_systematics_cls.
Missing PSF_E1/PSF_E2 → status SKIPPED (not FAIL). Writes
results/systematics/psf_leakage_bin_{i:02d}.json. Spin-2 bins only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_dir
|
str
|
Session directory. |
required |
bin_index
|
int
|
Tomographic bin index (must be spin-2). |
required |
jobspec
|
dict | None
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
The PSF-leakage result dict, written to |
dict
|
|
Source code in cosmotron_mcp/server.py
run_systematics_check_job ¶
run_systematics_check_job(session_dir: str, bin_index: int, check: str = 'cterm', n_bootstrap: int = 300, jobspec: dict | None = None) -> dict
Submit compute_cterm/compute_psf_leakage as a non-blocking background job.
Use this instead of calling compute_cterm/compute_psf_leakage directly
when the bin's catalogue is large (tens of millions of objects) — the
in-process call can run long enough to exceed the client's request
timeout, which kills the WHOLE MCP connection (every cosmotron tool),
not just that one call. NON-BLOCKING — returns a job_id immediately;
poll with check_job(session_dir, job_id). Once done, re-call
compute_cterm/compute_psf_leakage/build_systematics_evidence — they
load the JSON this job already wrote instead of recomputing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_dir
|
str
|
Session directory. |
required |
bin_index
|
int
|
Tomographic bin index. |
required |
check
|
str
|
|
'cterm'
|
n_bootstrap
|
int
|
Forwarded to |
300
|
jobspec
|
dict | None
|
Optional resource dict, forwarded to |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
|