cosmotron_mcp.tools.bmode_rotation¶
run_bmode_rotation_ensemble_from_session ¶
run_bmode_rotation_ensemble_from_session(session_dir: str, n_rot: int = 100, backend: str = 'auto', n_batches: int | None = None) -> dict
Launch the random-rotation shape-noise ensemble (L2) as K parallel batch jobs — the near-definitive empirical B-mode covariance.
Randomly rotates the galaxy ellipticities and re-measures the spin-2 BB/EB
pseudo-Cℓ many times to build an EMPIRICAL noise power + covariance (the
KiDS/DES/HSC method), rather than trusting the over-precise analytic
covariance. NOT a GLASS re-simulation. Splits n_rot rotations into K
batches and submits ONE background job per batch (never one per rotation);
with backend="slurm" (and a site pinned in the session) the batches run on
the cluster. Poll every returned job_id with check_job; once all are
done call aggregate_bmode_ensemble_from_session. Only offer this when a
B-mode diagnosis returns COLORED_EXCESS / BENIGN_FLAG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_dir
|
str
|
Session directory. |
required |
n_rot
|
int
|
Total number of random rotations (default 100). |
100
|
backend
|
str
|
|
'auto'
|
n_batches
|
int | None
|
Override the batch count (default: core count). |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Source code in cosmotron_mcp/server.py
aggregate_bmode_ensemble_from_session ¶
Combine the finished rotation batches into an empirical B-mode noise power + covariance and re-run the null against it — the definitive (L2) verdict.
Call after every run_bmode_rotation_ensemble_from_session batch job is
done. Reads results/systematics/rotation_ensemble/batch_*.json, builds
the empirical mean (noise floor) + Hartlap-corrected covariance per spin-2 bin,
subtracts the empirical noise from the DATA B-modes, and χ²-tests against zero.
Writes results/covariance/covariance_ensemble_{BB,EB}.json and merges the
empirical p-values into results/systematics/bmode_diagnosis.json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_dir
|
str
|
Session directory. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
``{n_tests, n_fail, tests: [{bin, component, chi2, p_value, n_rot, |
dict
|
verdict}]}``. |