diff --git a/CLAUDE.md b/CLAUDE.md index a9750e7ca..40b3daab7 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -20,7 +20,10 @@ SP Validation is a Python package for validating weak-lensing catalogues (galaxy ## ASTRA and Lightcone first Build analysis stages (n(z) generation included) as ASTRA specs (`astra.yaml`) run with Lightcone (`lc`), and record analysis choices there as decisions, -using the `astra`/`lc` tools wherever they fit. +using the `astra`/`lc` tools wherever they fit. Decision-record tests +(`test_catalogue_match.py`, `test_nz_record.py`) verify `@sc [decision:...]` +tags and `Values:` pins against root `astra.yaml` and its sub-analyses, so run +`pytest -m "not slow"` inside the container after editing or moving ASTRA specs. ## Development Commands diff --git a/analyses/catalogue/astra.yaml b/analyses/catalogue/astra.yaml new file mode 100644 index 000000000..c8a05d67a --- /dev/null +++ b/analyses/catalogue/astra.yaml @@ -0,0 +1,445 @@ +# The catalogue section: from ShapePipe's run-1 snapshot to the calibrated +# shear sample, and the PSF and star catalogues beside it. +# +# Recipes run in this folder. A product given to the analysis (a sp.* fetch, +# or a HATS conversion made outside this repository) is read through its +# manifest, and commands name it by its data-root path, which the scripts +# resolve through sp_validation.data_roots. + +spec_version: "0.1.0" +label: Calibrated shear sample +description: >- + ShapePipe's run-1 snapshot (772,677,301 objects on 22,901 DR6 tiles) as a + HATS shape catalogue; the v2 HATS collection that adds PhotoPipe's DR6 + photometry and photo-z and PhotoPipe's spec-z matches to it, joined on the + DR6 object ID; the comprehensive catalogue of every object with every + ShapePipe and PhotoPipe column; and the calibrated cosmic-shear sample: + the galaxy selection, the DES weight table, the metacalibration response + of the weighted mean shear, the additive bias, and the calibrated shear + R⁻¹(g − c_e) of each selected galaxy. Metacalibration measures each galaxy + on five versions of its image, the branches: unsheared, and sheared by ±h + (h = 0.01) along each shear component. The PSF and star catalogues come + from the same snapshot. The tomographic bins, and the response of each bin, + are made in the redshifts section. + +analyses: + sp: + path: ../.. + +outputs: + shapes: + label: Run-1 shape catalogue (HATS) + type: data + format: json + description: >- + ShapePipe's final_cat_latest.hdf5 converted to a HATS catalogue at + HEALPix order 5 (data/v2.x/run1-snap3-hats/catalogue), with every + ShapePipe column. The conversion ran on Nibi with code outside this + repository, and its BUILD.json names the snapshot manifest's SHA-256 + it was made from, so it is fetched: the result is the manifest of what + arrived. + inputs: [sp.shapepipe_run1] + recipe: + command: >- + python -m sp_validation.fetch '${{unions_data}}/v2.x/run1-snap3-hats' + --version run1-snap3 --out {output} + resources: { cpus: 1, memory: 4GB, time_limit: 8h } + + collection: + label: The v2 HATS collection + type: data + format: hats + description: >- + The shapes with the DR6 object ID (OBJECT_ID = 10⁶ × tile + NUMBER) as + the primary catalogue, an OBJECT_ID index, and two extensions joined on + OBJECT_ID: PhotoPipe's dereddened GAaP u g r i z z2 photometry and BPZ + photo-z (dense, one row per shape), and PhotoPipe's spec-z matches + (sparse, 4,733,015 rows). The redshifts section takes the sources' + photometry and the calibrators' spectra from it, so sources and + calibrators share one photometry. config/assembly/v2.yaml names the + inputs and where the collection goes. + inputs: [sp.assembly_v2, shapes, sp.photopipe_dr6, sp.photopipe_specz] + recipe: + command: >- + python ../../scripts/assembly/build_collection.py {inputs.sp.assembly_v2} + --workers 60 + resources: { cpus: 60, memory: 320GB, time_limit: 1h } + + comprehensive_catalogue: + label: Comprehensive catalogue + type: data + format: hats + description: >- + Every run-1 object (772,677,301) with every ShapePipe column + (uncalibrated ngmix and metacal output, flags, mask bits) and every + PhotoPipe DR6 column, joined on (TILE_ID, NUMBER) = (tile, SeqNr); + PHOTOPIPE_STATUS is 0 for a joined row, 1 when the tile has no row with + that ID, 2 when the tile has no PhotoPipe file. HATS at HEALPix order 5: + the release's catalogs/comprehensive/. + inputs: [shapes, sp.photopipe_dr6] + recipe: + command: >- + python ../../scripts/assembly/join_photopipe.py + '${{unions_data}}/photopipe-dr6-extract' + --shapes '${{unions_data}}/v2.x/run1-snap3-hats/catalogue' + --output {output} --workers 24 + resources: { cpus: 32, memory: 500GB, time_limit: 8h } + + calibrated_catalogue: + label: Calibrated shear sample + type: data + format: dir + description: >- + The calibrated sample in the release layout. catalogs/calibrated/ is a + HATS catalogue (order 5) of every selected galaxy: RA, Dec, calibrated + e1, e2 = R⁻¹(g − c_e) with the whole sample's response, weight w_des, + e1_PSF, e2_PSF, SIZE_RATIO, SNR, N_EPOCH, TILE_KEY, TILE_ID, NUMBER. + Beside it: catalogs/response.json (R, R_shear, R_selection, R_joint, + c_e, c_g, branch populations and delete-one-tile jackknife covariance), + catalogs/des_weights.fits (the weight table), catalogs/response_sums.npz + (the per-tile, per-cell sums R and the table follow from), + catalogs/survey.json, masks/footprint-nside4096-ring.fits (the occupied + pixels) and provenance/calibrated_tile_accounting.json (every tile's + rows after each cut). The recipe file config/calibration/sample/v2.yaml + names the snapshot, the collection and the selection config. v2.0.0's + sample was built on Nibi by bound9_stream.py (sp_validation fbb2b3e8) + from the comprehensive HDF5 catalogue, not from the collection + (provenance/calibrated_BUILD.md); the selection and response are the + ones this recipe applies. + inputs: [sp.shapepipe_run1, collection, sp.selection_v2] + decisions: + [overlap_cut, selection_cuts, catalogue_match_tile_selection, + sample_wide_calibration, galaxy_weights, weight_table, + response_estimator, additive_bias, calibration_uncertainties, + leakage_correction] + recipe: + command: >- + python ../../scripts/calibration/calibrate_sample.py + ../../config/calibration/sample/v2.yaml --output {output} --workers 60 + resources: { cpus: 60, memory: 160GB, time_limit: 1h } + + response: + label: Response and additive bias of the sample + type: data + format: json + description: >- + catalogs/response.json of the calibrated sample: the weight scheme, the + 2 × 2 response R = R_shear + R_selection and the joint estimator R_joint, + the additive bias c_e (uncalibrated) and c_g (calibrated), the + population and weight sum of each metacal branch, the raw, preselected + and selected row counts, and the delete-one-tile jackknife covariance + of all of them. + inputs: [calibrated_catalogue] + recipe: + command: cp {inputs.calibrated_catalogue}/catalogs/response.json {output} + + weight_table: + label: DES weight table + type: data + format: fits + description: >- + The 20 × 20 table W(S/N, T/T_PSF) the sample is weighted with, and the + sample's occupancy of each cell. The image simulations are weighted + with it. + inputs: [calibrated_catalogue] + recipe: + command: cp {inputs.calibrated_catalogue}/catalogs/des_weights.fits {output} + + psf_catalogue: + label: PSF catalogue + type: data + format: json + description: >- + The 5,565,959 stars of the snapshot's shape catalogue with the PSF + model's ellipticity and size at each, HATS at order 5: the release's + catalogs/psf/. It is extracted from the shape catalogue and converted + to HATS outside this repository, so it is fetched and checked against + the release's MD5SUMS. + inputs: [sp.shapepipe_run1] + recipe: + command: >- + python -m sp_validation.fetch '${{unions_v2}}/v2.0.0/catalogs/psf' + --version v2.0.0 --md5sums '${{unions_v2}}/v2.0.0/MD5SUMS' --out {output} + resources: { cpus: 1, memory: 2GB, time_limit: 1h } + + star_catalogue: + label: Star catalogue + type: data + format: json + description: >- + ShapePipe's full_starcat_latest.hdf5 (11,194,784 stars, held-out and + training, with star and PSF-model moments per CCD, by EXPOSURE) as a + HATS catalogue at order 5: the release's catalogs/stars/. Converted + outside this repository, so it is fetched and checked against the + release's MD5SUMS. + inputs: [sp.shapepipe_run1] + recipe: + command: >- + python -m sp_validation.fetch '${{unions_v2}}/v2.0.0/catalogs/stars' + --version v2.0.0 --md5sums '${{unions_v2}}/v2.0.0/MD5SUMS' --out {output} + resources: { cpus: 1, memory: 2GB, time_limit: 1h } + +decisions: + overlap_cut: + label: Tile-overlap cut on the snapshot's tile set + rationale: >- + Neighbouring tiles share a strip of sky, so an object there is detected + and measured in both, and ShapePipe keeps both rows. Each object is kept + only on its own tile's side of the RA midpoint to each neighbour and + inside its tile's Dec range. A tile's neighbours are looked up among + every tile of the snapshot, so the cut does not depend on how the + catalogue is chunked, and a sample cannot be grown by appending tiles: + 297 tiles lost 39,781 galaxies when run 1 grew from 20,515 to 22,901 + tiles, each to a new neighbour. + options: + snapshot_tiles: + label: Neighbours among the snapshot's tiles + description: The same cut however the catalogue is read. + tiles_in_hand: + label: Neighbours among the tiles being processed + description: >- + Keeps both copies wherever the neighbour is in another batch; + correct only with the whole catalogue in memory at once. + + selection_cuts: + label: Galaxy selection + rationale: >- + config/calibration/mask_v2.0.yaml: SExtractor FLAGS ≤ 2 ignoring bit 16 + (incomplete aperture data, which preferentially flags large galaxies + and biases m in image simulations); the overlap cut; outside star + bodies, manual masks, MaxiMask and r-band gaps (mask bits 4, 8, 1024 + and 64; the star-halo bits 1 and 2 are not cut); N_EPOCH ≥ 2; + 15 ≤ mag ≤ 30; no ngmix moments failure, fitted at least once, and a + valid PSF ellipticity; then on each metacal branch 10 < S/N < 500 and + 0.707 < T/T_PSF < 9 with the branch's fit flag zero. The selection + config is the input, so this decision is attached to the sample it + makes. The release's catalogs/config_mask.yaml records these cuts as + they ran. + options: + bound_9_bit_16_ignored: + label: T/T_PSF < 9, FLAGS ignoring bit 16, no halo cut + description: The v2.0.0 selection. + bound_3_strict_flags: + label: T/T_PSF < 3, FLAGS ≤ 2 on every bit + description: >- + The v1 selection; drops large galaxies and biases m in image + simulations. + with_star_halos: + label: Also cut star halos (bits 1 and 2) + description: >- + Removes about 13% of the area; Paper III found the halo masking + added B-modes in v1. + + catalogue_match_tile_selection: + label: Tiles kept whatever their external paired fraction + rationale: >- + ShapePipe pairs each tile's detections with an external catalogue and + records the paired fraction. No tile is removed on it. On the v2.0.0 + selection all 18 measured tiles below 0.98 pairing yield no selected + galaxy, because the N_EPOCH ≥ 2 cut empties them, so a 0.98 cut would + remove nothing; stricter thresholds remove galaxies with no measured + improvement. Reassess if the N_EPOCH cut is relaxed. + Values: MIN_EXTERNAL_PAIRED_FRACTION = None; mask_v2.0.yaml#N_EPOCH = 2. + options: + no_cut: + label: No paired-fraction cut + description: The paired fraction is a diagnostic. + cut_below_0_99: + label: Reject tiles below 0.99 + description: >- + Removes 198 tiles and 675,307 selected galaxies (0.354% of the + sample). + cut_below_0_995: + label: Reject tiles below 0.995 + description: >- + Removes 3,072 tiles and 20,855,054 selected galaxies (10.92% of the + sample). + + sample_wide_calibration: + label: One weight table and one response for the whole sample + rationale: >- + The sample is weighted and calibrated as one population: one weight + table fitted on every selected galaxy of the snapshot, and the whole + sample's R and c_e applied to every row, not a table or response per + region of the footprint. A weight depends on a galaxy only through its + (S/N, size) cell, so the table and R follow from per-(tile, cell) sums + that add over chunks of the catalogue. Each tomographic bin's own + response is measured with this table held fixed, in the redshifts + section. + options: + one_for_the_sample: + label: One table and one response for the sample + refit_per_region: + label: Table and response per region of the footprint + description: >- + Follows depth variations, at the cost of noisier tables and a + response that changes across the footprint. + + galaxy_weights: + label: DES weight table evaluated on every branch + rationale: >- + Galaxies are weighted by a table W(S/N, size), with S/N = FLUX/FLUX_ERR + and size = T/T_PSF of the ngmix fit, fitted on the unsheared branch and + evaluated on every metacal branch at that branch's own S/N and size. A + galaxy's weight therefore changes under shear, and the response + includes that change. With unit weights the v2.0.0 sample has + R = 0.6889, against 0.7869 with the table. + options: + des_table_on_every_branch: + label: DES table at each branch's own S/N and size + frozen_weights: + label: Weights frozen at their unsheared values + description: Removes the weight response from R. + inverse_variance: + label: Inverse-variance weights from each branch's errors + excluded: >- + The v2 shape catalogue does not keep the sheared branches' error + columns. + unit: + label: Unit weights + description: Lower response and higher noise per galaxy. + + weight_table: + label: The DES weight table + rationale: >- + In each (S/N, size) cell, W = (Σ r)² / (n Σ |e|²/2) over the n galaxies + of the unsheared selection in it, with r the mean diagonal element of a + galaxy's response and e its unsheared ellipticity; 20 × 20 logarithmic + cells between the S/N and size cuts. A cell with fewer than 3 galaxies + takes the moments of the smallest square of cells centred on it that + holds 3. On the image-simulation grids, one cell of two galaxies + without this pooling inflated one grid's error on m2 fivefold. + options: + pooled_min_3: + label: 20 × 20 cells, sparse cells pooled to 3 galaxies + no_pooling: + label: No pooling + description: A sparse cell can carry an extreme weight. + pooled_min_10: + label: Sparse cells pooled to 10 galaxies + description: >- + Moves m in image simulations by up to 0.66σ for no gain in + stability. + + response_estimator: + label: Response of the weighted mean shear + rationale: >- + The catalogue's shear estimate is a weighted mean ⟨e⟩ = Σ w e / Σ w + over a selection, and R calibrates it. R = R_shear + R_selection: + R_shear is the weighted mean over the unsheared selection of each + galaxy's (e⁺ − e⁻)/2h; R_selection is the finite difference of the + weighted mean unsheared ellipticity under each sheared branch's own + selection and weights, each branch normalised by its own weight sum. + Shear moves galaxies across the cuts and changes their weights, so the + weight sum differs between branches; with separate normalisation R is + the derivative of the weighted mean it calibrates. The joint estimator + is computed beside it as a check. + options: + separate_normalisation: + label: R_shear + R_selection, each branch on its own weight sum + insights: [metacal_response, metacal_selection] + joint: + label: Each sheared branch's own ellipticity under its own selection + description: >- + Agrees with the chosen R to 0.03% on v2.0.0; kept as a diagnostic. + common_denominator: + label: One weight sum for both sheared branches + description: Drops the term from the change of the weight sum under shear. + ivw_shear_unweighted_selection: + label: Inverse-variance R_shear with unweighted R_selection + description: >- + The earlier sp_validation practice; it calibrates a mean other than + the weighted mean applied to the catalogue. + + additive_bias: + label: Additive bias subtracted once per calibrated sample + rationale: >- + c_e is the weighted mean unsheared, uncalibrated ellipticity of the + sample, and the calibrated shear is R⁻¹(e − c_e). No spatially varying + c is removed; patches of the footprint scatter around the global value + by about 3 × 10⁻⁴, which the validation section measures. + options: + global_mean: + label: One c_e per calibrated sample + not_subtracted: + label: Leave c in the catalogue + description: >- + Estimators must subtract it themselves; the setting for + constant-shear image simulations, where the mean is the signal. + + calibration_uncertainties: + label: Delete-one-tile jackknife with the response recomputed + rationale: >- + The errors of R and c are delete-one-tile jackknifes: each tile leaves + every metacal branch at once and R is recomputed for each deletion, + with the weight table refitted, so the error includes the response's + own noise and spatially correlated noise. + options: + tile_jackknife: + label: Delete-one-tile jackknife, response recomputed + object_bootstrap: + label: Object bootstrap with the response held fixed + description: Leaves out the response's own uncertainty and spatial correlations. + + leakage_correction: + label: No object-wise PSF-leakage correction + rationale: >- + [HARDCODED] The sample build has no leakage step: e1, e2 carry whatever + PSF leakage the shapes have, and e1_PSF, e2_PSF ride along so the PSF + systematics section can measure it (ρ and τ statistics, leakage α). + The v1 catalogue subtracted a binned object-wise correction. + options: + uncorrected: + label: Uncorrected, PSF ellipticity carried + object_wise: + label: Binned object-wise correction + description: >- + α(S/N, size) × e_PSF subtracted from each galaxy, as v1 + (calibration.get_alpha_leakage_per_object). + +prior_insights: + metacal_response: + claim: >- + Metacalibration measures the shear response of a weighted-mean shear + estimator from the survey images themselves, by shearing them by a + known amount. + evidence: + - doi: "10.48550/arXiv.1702.02600" + quote: + exact: "Our technique infers multiplicative shear calibration parameters by modifying the actual survey data to simulate the effects of a known shear." + metacal_selection: + claim: >- + The response of a selected sample has a selection term, measured by + applying the selection to the sheared images. + evidence: + - doi: "10.48550/arXiv.1702.02601" + quote: + exact: "In this work we introduce a formalism to correct for both shear response and selection biases." + +findings: + sample_size: + claim: >- + The v2.0.0 calibrated sample holds 191,016,178 galaxies of the + snapshot's 772,677,301 objects; 573,175,974 pass the cuts before the + metacal S/N and size cuts. + evidence: + - artifact: response + quote: { exact: "\"selected_rows\": 191016178" } + - artifact: response + quote: { exact: "\"raw_rows\": 772677301" } + - artifact: response + quote: { exact: "\"preselection\": 573175974" } + sample_response: + claim: >- + The v2.0.0 sample's response has diagonal 0.7858 and 0.7880, of which + the selection term is 0.0284 and 0.0291; c_e is 1.8 × 10⁻⁵ and + 1.09 × 10⁻⁴. + evidence: + - artifact: response + quote: { exact: "0.7857610750514785" } + - artifact: response + quote: { exact: "0.7879529463898727" } + - artifact: response + quote: { exact: "0.02837166269534242" } + - artifact: response + quote: { exact: "1.8385967562799894e-05" } diff --git a/analyses/covariance/astra.yaml b/analyses/covariance/astra.yaml new file mode 100644 index 000000000..570045633 --- /dev/null +++ b/analyses/covariance/astra.yaml @@ -0,0 +1,287 @@ +# The covariances of the data vectors: analytic (OneCovariance for ξ±, +# NaMaster for pseudo-Cℓ) and from the mock ensemble. +# +# The OneCovariance configuration is written by the workflow's covariance_ini +# rule (workflow/rules/covariance.smk) from the catalogue config's cov_th +# block and these decisions; run_onecovariance.py below stands for that rule +# and the OneCovariance call, which have no command-line entry point yet. +# The check of OneCovariance against the data's jackknife is in validation. + +spec_version: "0.1.0" +label: Covariance +description: >- + The covariance of every statistic in the data vector. ξ±: OneCovariance + (Reischke et al. 2025) at the fiducial cosmology, non-Gaussian with + super-sample covariance on the reporting grid and Gaussian on the + integration grid the B-mode statistics are built from, with the shape-noise + term from the measured pair counts. Pseudo-Cℓ: the NaMaster iNKA Gaussian + covariance. The mock ensemble gives an empirical covariance of every + statistic. + Covariances carry no blind. +tags: [covariance, onecovariance, namaster] + +analyses: + sp: + path: ../.. + catalogue: + path: ../catalogue + redshifts: + path: ../redshifts + footprint: + path: ../footprint + mocks: + path: ../mocks + +outputs: + cosmology_params: + label: Fiducial cosmological parameters + type: data + format: json + description: >- + The fiducial cosmology as the workflow reads it + (results/cosmology/planck18.json): cs_util.cosmo.PLANCK18 with + Ω_v = 1 − Ω_m. + decisions: [sp.fiducial_cosmology] + recipe: + command: >- + python -c "import json; from cs_util.cosmo import PLANCK18 as p; + json.dump(dict(p, Omega_v=1 - p['Omega_m']), open('{output}', 'w'), indent=2)" + + pair_counts: + label: Effective pair counts per bin pair + type: data + format: npz + description: >- + Weighted galaxy pair counts of every bin pair on the reporting and the + integration grids, from positions and weights only (no shapes, no + blind). OneCovariance takes its shape-noise term from them, which + carries the survey's real geometry and weight distribution in place of + an area and a mean density. + inputs: [sp.cat_config, catalogue.calibrated_catalogue] + recipe: + command: >- + python ../../workflow/scripts/measure_pair_counts.py + --cat-config {inputs.sp.cat_config} --ver SP_v2.0.0 --tomo + --grids 1.0,250.0,20 0.08,300.0,1000 --out {output} + resources: { cpus: 24, memory: 40GB, time_limit: 10h } + + xi_covariance: + label: ξ± covariance, reporting grid + type: data + format: dat + description: >- + The OneCovariance ξ± matrix of every bin pair on the reporting grid, + the covariance of ξ± in the analysis file, with the survey parameters + of the tomographic sample (per-bin n_eff and σ_e, area 4,582.17 deg², + footprint_tomo as the mask) and the tomographic n(z). + inputs: + - sp.cat_config + - redshifts.nz_tomo + - footprint.footprint_tomo + - pair_counts + - cosmology_params + decisions: [reporting_terms, shape_noise, survey_mask, covariance_power_spectrum, sp.fiducial_cosmology] + recipe: + command: >- + python ../../workflow/scripts/run_onecovariance.py + --cat-config {inputs.sp.cat_config} --ver SP_v2.0.0 --tomo + --nz {inputs.redshifts.nz_tomo} --mask {inputs.footprint.footprint_tomo} + --pair-counts {inputs.pair_counts} --cosmology {inputs.cosmology_params} + --theta 1.0 250.0 20 --terms {decisions.reporting_terms} + --shape-noise {decisions.shape_noise} --out {output} + resources: { cpus: 8, memory: 32GB, time_limit: 12h } + + xi_covariance_integration: + label: ξ± covariance, integration grid + type: data + format: dat + description: >- + The OneCovariance ξ± matrix on the integration grid, which the COSEBIs + and pure-mode operators propagate into the covariance of the B-mode + statistics. + inputs: + - sp.cat_config + - redshifts.nz_tomo + - footprint.footprint_tomo + - pair_counts + - cosmology_params + decisions: [integration_terms, shape_noise, survey_mask, covariance_power_spectrum, sp.fiducial_cosmology] + recipe: + command: >- + python ../../workflow/scripts/run_onecovariance.py + --cat-config {inputs.sp.cat_config} --ver SP_v2.0.0 --tomo + --nz {inputs.redshifts.nz_tomo} --mask {inputs.footprint.footprint_tomo} + --pair-counts {inputs.pair_counts} --cosmology {inputs.cosmology_params} + --theta 0.08 300.0 1000 --terms {decisions.integration_terms} + --shape-noise {decisions.shape_noise} --out {output} + resources: { cpus: 8, memory: 64GB, time_limit: 24h } + + pseudo_cl_covariance: + label: Pseudo-Cℓ covariance + type: data + format: fits + description: >- + The Gaussian covariance of the pseudo-Cℓ EE, EB and BB of every bin + pair (COVAR_EE_EE, COVAR_BB_BB, COVAR_EB_EB, ...), from NaMaster's + improved narrow-kernel approximation with the mode-coupled fiducial + spectra as input, at the fiducial cosmology (CAMB, HMCode2020 with + log T_AGN = 7.8). + inputs: + - sp.cat_config + - catalogue.calibrated_catalogue + - redshifts.bin_responses + - redshifts.nz_tomo + - cosmology_params + decisions: [cl_covariance_method, sp.fiducial_cosmology] + recipe: + command: >- + d=$(mktemp -d) && + python ../../workflow/scripts/generate_pseudo_cl_cov.py --ver SP_v2.0.0 + --cat-config {inputs.sp.cat_config} --nside 1024 --binning powspace + --nbins 32 --power 0.5 --tomo --gaussian-part {decisions.cl_covariance_method} + --cosmo-json {inputs.cosmology_params} --out "$d" && + mv "$d"/*.fits {output} + resources: { cpus: 12, memory: 16GB, time_limit: 3h } + + mock_covariance: + label: Mock-ensemble covariance + type: data + format: npz + description: >- + The sample covariance of every statistic of the data vector (ξ±, + pseudo-Cℓ, COSEBIs, pure E/B) across the mock ensemble, and its mean, + with the Hartlap factor its inverse needs. It tests the analytic + covariances and calibrates the null tests; the analysis file does not + use it. + inputs: [mocks.mock_statistics] + recipe: + command: >- + python ../../workflow/scripts/compute_glass_mock_covariance.py + --mocks {inputs.mocks.mock_statistics} --out {output} + resources: { cpus: 1, memory: 16GB, time_limit: 1h } + +decisions: + reporting_terms: + label: Terms of the reporting-grid ξ± covariance + rationale: >- + The covariance used for inference includes the connected + non-Gaussian term and super-sample covariance, which add to the + Gaussian term on the scales where the signal is measured. + options: + full: + label: Gaussian, non-Gaussian and super-sample + insights: [onecovariance] + gaussian: + label: Gaussian only + + integration_terms: + label: Terms of the integration-grid ξ± covariance + rationale: >- + The integration-grid covariance feeds the B-mode statistics, whose + covariance is noise-dominated; non-Gaussian terms act on the E-mode + signal. Paper II kept only the Gaussian part for every B-mode null + test, which makes the PTEs conservative. + options: + gaussian: + label: Gaussian only + full: + label: Gaussian, non-Gaussian and super-sample + jackknife: + label: Jackknife ξ± covariance with the Hartlap factor + description: >- + The B-mode statistics take the covariance of the part's own + patches, and every χ² its inverse enters carries the Hartlap + factor (sp_validation.b_modes.hartlap_factor). + insights: [hartlap] + + shape_noise: + label: Shape-noise term + rationale: >- + The noise term of the ξ± covariance needs the number of galaxy pairs + in each θ bin. Measured pair counts carry the real footprint, its + holes and the weight distribution; the analytic term assumes a uniform + density over the area. The two differ most on small scales and near + the mask edges. + options: + pair_counts: + label: Measured pair counts (pair_counts) + description: >- + On origin/edge and the v2.0.0 run's branch; not on develop. + analytic: + label: n_eff, σ_e and area of the sample + + survey_mask: + label: Survey geometry of the ξ± covariance + rationale: >- + OneCovariance takes the footprint's mask to compute the survey window + of the super-sample and Gaussian terms; without it only the area + enters. The tomographic covariance reads the binned sample's footprint. + options: + masked: + label: The footprint as the mask + area_only: + label: Area only + description: Paper III (v1.4) shows the unmasked covariance for comparison. + + covariance_power_spectrum: + label: Non-linear power spectrum of the analytic covariances + rationale: >- + HMCode2020 with baryonic feedback, at log T_AGN = 7.75 in the + OneCovariance configuration. The pseudo-Cℓ covariance and the GLASS + mocks use log T_AGN = 7.8. + options: + hmcode2020_feedback: + label: HMCode2020 with feedback + insights: [hmcode2020] + + cl_covariance_method: + label: Pseudo-Cℓ covariance + rationale: >- + NaMaster's iNKA gives the Gaussian covariance of the coupled + bandpowers on the real mask. The code can add the OneCovariance + non-Gaussian terms to it (calculate_pseudo_cl_g_ng_cov), or take the + Gaussian part from OneCovariance as well; in v1.4 the iNKA and + OneCovariance Gaussian terms differed by about 25 %. + options: + inka: + label: iNKA Gaussian (NaMaster) + insights: [namaster] + inka_plus_onecov: + label: iNKA Gaussian plus OneCovariance non-Gaussian + onecov: + label: OneCovariance Gaussian and non-Gaussian + +prior_insights: + onecovariance: + claim: >- + OneCovariance computes the Gaussian, non-Gaussian and super-sample + covariance of projected large-scale-structure observables. + evidence: + - doi: "10.48550/arXiv.2410.06962" + quote: + exact: "incorporating all Gaussian, non-Gaussian, and super-sample covariance terms" + + hartlap: + claim: >- + The inverse of a covariance estimated from a finite number of + realisations is biased and needs the Hartlap factor. + evidence: + - doi: "10.48550/arXiv.astro-ph/0608064" + quote: + exact: "We find that the inverse of the maximum-likelihood estimator of the covariance is biased" + + hmcode2020: + claim: >- + HMCode2020 models the non-linear matter power spectrum with baryonic + feedback set by the AGN temperature. + evidence: + - doi: "10.48550/arXiv.2009.01858" + quote: + exact: "the power spectrum response to feedback is matched at the < 1 per cent level for z < 1" + + namaster: + claim: NaMaster is a validated public implementation of the pseudo-Cℓ framework. + evidence: + - doi: "10.48550/arXiv.1809.09603" + quote: + exact: "This paper presents NaMaster, a public, validated" diff --git a/analyses/data_vectors/astra.yaml b/analyses/data_vectors/astra.yaml new file mode 100644 index 000000000..142b98358 --- /dev/null +++ b/analyses/data_vectors/astra.yaml @@ -0,0 +1,356 @@ +# The blinded two-point data vectors of the tomographic sample and the SACC +# file that carries them with their covariance. +# +# Measurement scripts read the catalogue through the SP_v2.0.0 entry of the +# catalogue config (sp.cat_config): its paths, columns and blind. The +# catalogue, n(z), footprint and blind outputs are listed as inputs so that a +# change to any of them makes these outputs stale. Numeric settings (θ grids, +# patch and mode counts) are written into the commands; the decision that +# sets each one is attached to the output. + +spec_version: "0.1.0" +label: Data vectors +description: >- + ξ±(θ) on two angular grids, COSEBIs, pure-mode E/B correlation functions + and pseudo-Cℓ for every pair of the four tomographic bins, each blinded as + it is measured, and the SACC file that joins them with the ρ/τ PSF + statistics and their covariances. Every E-mode statistic is shifted by the + UNIONS blind before it is written (sp_validation.blinding); B-modes, EB and + the covariances are not. Universe v2_0_0 is the release's + data_vector/SP_v2.0_tomo.sacc (3,680 points). +tags: [two-point, cosmic-shear, blinded] + +analyses: + sp: + path: ../.. + catalogue: + path: ../catalogue + redshifts: + path: ../redshifts + footprint: + path: ../footprint + covariance: + path: ../covariance + psf_systematics: + path: ../psf_systematics + +outputs: + xi_reporting: + label: ξ± on the reporting grid + type: data + format: sacc + description: >- + TreeCorr ξ±(θ) of every tomographic bin pair on the reporting grid, + blinded, as a SACC part. With patches, the part carries the + jackknife covariance it was measured with; the analysis file replaces + it with the OneCovariance matrix (data_vector). Each bin's shear is + calibrated by its own response and has its weighted mean subtracted + (redshifts.sample_calibration). + inputs: + - sp.cat_config + - catalogue.calibrated_catalogue + - redshifts.bin_responses + - redshifts.nz_tomo + - sp.blind + decisions: [xi_reporting_grid, xi_jackknife_patches, redshifts.sample_calibration, sp.blinding] + recipe: + command: >- + d=$(mktemp -d) && + python ../../workflow/scripts/run_2pcf.py --ver SP_v2.0.0 + --min-sep 1.0 --max-sep 250.0 --nbins 20 --npatch 100 --tomo + --grid reporting --cat-config {inputs.sp.cat_config} --out "$d" && + mv "$d"/*.sacc {output} + resources: { cpus: 24, memory: 30GB, time_limit: 6h } + + xi_integration: + label: ξ± on the integration grid + type: data + format: sacc + description: >- + ξ±(θ) of every bin pair on the fine logarithmic grid the COSEBIs and + pure-mode transforms integrate over, blinded, without patches. An + intermediate: it is not in the analysis file. + inputs: + - sp.cat_config + - catalogue.calibrated_catalogue + - redshifts.bin_responses + - redshifts.nz_tomo + - sp.blind + decisions: [integration_grid, redshifts.sample_calibration, sp.blinding] + recipe: + command: >- + d=$(mktemp -d) && + python ../../workflow/scripts/run_2pcf.py --ver SP_v2.0.0 + --min-sep 0.08 --max-sep 300.0 --nbins 1000 --npatch 1 --tomo + --grid integration --cat-config {inputs.sp.cat_config} --out "$d" && + mv "$d"/*.sacc {output} + resources: { cpus: 24, memory: 40GB, time_limit: 10h } + + cosebis: + label: COSEBIs + type: data + format: sacc + description: >- + COSEBIs E_n and B_n of every bin pair from the integration-grid ξ± + over the configuration-space scale cut, with the Gaussian + OneCovariance ξ± matrix of the same grid pushed through the same + kernel as their covariance. E_n inherit the blind of ξ±. + inputs: [xi_integration, covariance.xi_covariance_integration, sp.blind] + decisions: [cosebis_modes, config_scale_cut, sp.blinding] + recipe: + command: >- + python ../../workflow/scripts/cv_cosebis.py + --xi {inputs.xi_integration} + --cov {inputs.covariance.xi_covariance_integration} + --nmodes 20 --scale-cut 12 83 --out {output} + resources: { cpus: 24, memory: 48GB, time_limit: 10h } + + pure_eb: + label: Pure-mode E/B correlation functions + type: data + format: sacc + description: >- + ξ±^E, ξ±^B and the ambiguous components of every bin pair on the + reporting bins, from the integration-grid ξ± by the linear operator of + Schneider et al. (2022), with the integration-grid covariance pushed + exactly through it. The covariance block is rank-deficient (E, B and + ambiguous modes share the same ξ±). + inputs: [xi_integration, covariance.xi_covariance_integration, sp.blind] + decisions: [pure_eb_method, xi_reporting_grid, config_scale_cut, sp.blinding] + recipe: + command: >- + python ../../workflow/scripts/cv_pure_eb.py + --xi {inputs.xi_integration} + --cov {inputs.covariance.xi_covariance_integration} + --min-sep 1.0 --max-sep 250.0 --nbins 20 --scale-cut 12 83 + --out {output} + resources: { cpus: 1, memory: 8GB, time_limit: 20m } + + pseudo_cl: + label: Pseudo-Cℓ + type: data + format: sacc + description: >- + NaMaster pseudo-Cℓ EE, EB and BB of every bin pair with their + bandpower windows, blinded (EE). The shear field is evaluated at the + galaxy positions or on a HEALPix map (cl_estimator); the noise bias is + subtracted (noise_bias); e2 is multiplied by −1 before NaMaster, the + UNIONS sign convention. + inputs: + - sp.cat_config + - catalogue.calibrated_catalogue + - redshifts.bin_responses + - redshifts.nz_tomo + - covariance.cosmology_params + - sp.blind + decisions: [cl_estimator, cl_binning, noise_bias, redshifts.sample_calibration, sp.blinding] + recipe: + command: >- + d=$(mktemp -d) && + python ../../workflow/scripts/generate_pseudo_cl.py --ver SP_v2.0.0 + --cat-config {inputs.sp.cat_config} --nside 1024 + --binning {decisions.cl_binning} --nbins 32 --power 0.5 --tomo + --cell-method {decisions.cl_estimator} + --noise-bias {decisions.noise_bias} + --cosmo-json {inputs.covariance.cosmology_params} --out "$d" && + mv "$d"/*.sacc {output} + resources: { cpus: 12, memory: 32GB, time_limit: 2h } + + data_vector: + label: Tomographic data vector (SACC) + type: data + format: sacc + description: >- + The analysis file: ξ± on the reporting grid, pseudo-Cℓ, COSEBIs, pure + E/B and the ρ/τ statistics in that order, with one block-diagonal + covariance. ξ± takes the non-Gaussian OneCovariance matrix and + pseudo-Cℓ the NaMaster Gaussian matrix (EE, BB, EB auto-blocks; the + cross-spectrum blocks are dropped); the other parts keep the + covariance they were born with. Every part must carry the catalogue's + blind. v2.0.0's is data_vector/SP_v2.0_tomo.sacc of the release (MD5 + 5aad93e5d6704ebebc4535d71ed1d1bd), made on Fir on 16 Nov 2026 by + analyses/cosmo-val-v2-tomo-perbin (code 51f96128, branch + run/remeasure-tomo-perbin). + inputs: + - xi_reporting + - covariance.xi_covariance + - pseudo_cl + - covariance.pseudo_cl_covariance + - cosebis + - pure_eb + - psf_systematics.rho_tau_part + - sp.blind + decisions: [sp.blinding] + recipe: + command: >- + python ../../workflow/scripts/assemble_sacc.py --version SP_v2.0.0 + --blind unions + --xi-reporting {inputs.xi_reporting} + --xi-cov {inputs.covariance.xi_covariance} + --pseudo-cl {inputs.pseudo_cl} + --pseudo-cl-cov {inputs.covariance.pseudo_cl_covariance} + --cosebis {inputs.cosebis} --pure-eb {inputs.pure_eb} + --rho-tau {inputs.psf_systematics.rho_tau_part} + --out {output} + resources: { cpus: 1, memory: 8GB, time_limit: 20m } + +decisions: + xi_reporting_grid: + label: ξ± reporting grid + rationale: >- + 20 logarithmic bins over 1–250 arcmin carry the ξ± that enter the + analysis file and the bins the pure-mode functions are reported on. + TreeCorr bins with bin_slop set so each bin's tolerance is 0.01 of its + width (b_target). + options: + log20_1_250: + label: 20 log bins, 1–250 arcmin + + xi_jackknife_patches: + label: Jackknife patches of the reporting ξ± + rationale: >- + The reporting ξ± is measured on K-means patches so that it carries a + jackknife covariance. The analysis file replaces that covariance with + OneCovariance, so the patches serve the check of OneCovariance against + the jackknife (covariance.jackknife_comparison); without them the part + carries the shot-noise diagonal. + options: + npatch_100: + label: 100 patches + npatch_1: + label: No patches + description: Shot-noise variance only; what the mock measurements use. + + integration_grid: + label: ξ± integration grid + rationale: >- + COSEBIs and the pure-mode functions are integrals of ξ± over the + fiducial angular range, so ξ± is measured on a fine logarithmic grid + that extends beyond it; the mocks are measured on the same grid, node + for node. Paper II's v1.4 analysis integrated over 0.5–300 arcmin. + options: + log1000_0p08_300: + label: 1000 log bins, 0.08–300 arcmin + log1000_0p5_300: + label: 1000 log bins, 0.5–300 arcmin + description: The grid of Paper II (v1.4.6.3) and papers/bmodes. + + config_scale_cut: + label: Configuration-space scale cut + rationale: >- + The angular range of the COSEBIs and of the B-mode PTEs of the + pure-mode functions. 12–83 arcmin is Paper II's fiducial: the lower cut + excludes most intra-CCD pair separations (MegaCam's CCDs span about + 6–14 arcmin), where v1.4's B-mode contamination concentrated. The + cosmo_val config also scans COSEBIs over 1, 2, 5, 10, 15 and 20–250 + arcmin. + options: + arcmin_12_83: + label: 12–83 arcmin + arcmin_1_250: + label: 1–250 arcmin, the full reporting range + + cosebis_modes: + label: COSEBIs modes + rationale: >- + The E-mode signal saturates by n ≈ 5–6, so the first six modes carry + most of the cosmological information; the B-mode null test uses all 20. + options: + n20: + label: n ≤ 20 + insights: [cosebis_complete] + n6: + label: n ≤ 6 + description: The information-carrying modes, as for inference. + + pure_eb_method: + label: Pure-mode E/B decomposition + rationale: >- + The pure-mode correlation functions are a fixed linear operator on the + finely binned ξ± over a finite angular range, so they need no + extrapolation or model and their covariance is exact. + options: + schneider22: + label: Schneider et al. (2022), from the binned ξ± + insights: [pure_mode_cfs] + + cl_estimator: + label: Pseudo-Cℓ field construction + rationale: >- + The catalogue-based estimator evaluates the spin-2 transforms of the + shear and weights at the source positions, avoiding the pixel window, + aliasing and the Poisson noise of sparsely filled pixels. + options: + catalog: + label: Catalogue-based (Wolz et al. 2025) + insights: [catalog_pseudo_cl] + map: + label: HEALPix map + description: Pixelised shear map at nside 1024 (cell_method map). + + cl_binning: + label: Pseudo-Cℓ bandpowers + rationale: >- + 32 bandpowers spaced in ℓ^0.5 between ℓ = 8 and 2048 (ℓmax = 2 nside at + nside 1024), following DES (Doux et al. 2022). The code also bins + linearly (2040 bands, for the harmonic COSEBIs) and logarithmically. + options: + powspace: + label: 32 bands spaced in ℓ^0.5, 8 ≤ ℓ ≤ 2048 + insights: [namaster] + linear: + label: Linear bands + excluded: >- + The 2040-band linear binning serves the harmonic COSEBIs, not the + analysis bandpowers. + logspace: + label: Logarithmic bands + + noise_bias: + label: Pseudo-Cℓ noise bias + rationale: >- + The shape-noise bias of the pseudo-Cℓ is subtracted analytically from + the weighted ellipticities (Nicola et al. 2021), which accounts for + number-density variation across the sky; random rotations of the + shapes (100 realisations) estimate the same term numerically. + options: + analytic: + label: Analytic + randoms: + label: Random rotations + +prior_insights: + cosebis_complete: + claim: >- + COSEBIs are complete orthogonal sets of E/B-mode integrals over a + finite angular range, so they hold all the E/B-separable information + of ξ± on that range. + evidence: + - doi: "10.48550/arXiv.1002.2136" + quote: + exact: "Complete Orthogonal Sets of E-/B-mode Integrals (COSEBIs)" + + pure_mode_cfs: + claim: >- + Pure-mode correlation functions separate ξ± on a finite interval into + pure E, pure B and ambiguous parts directly from the data. + evidence: + - doi: "10.48550/arXiv.2110.09774" + quote: + exact: "These pure-mode correlation functions can thus be obtained directly from the data without extrapolation or modeling" + + catalog_pseudo_cl: + claim: >- + Estimating the harmonic transforms at the source positions makes the + pseudo-Cℓ immune to pixelisation and aliasing. + evidence: + - doi: "10.48550/arXiv.2407.21013" + quote: + exact: "The resulting estimator is immune to small-scale pixelization effects and aliasing" + + namaster: + claim: NaMaster is a validated public implementation of the pseudo-Cℓ framework. + evidence: + - doi: "10.48550/arXiv.1809.09603" + quote: + exact: "This paper presents NaMaster, a public, validated" diff --git a/analyses/footprint/astra.yaml b/analyses/footprint/astra.yaml new file mode 100644 index 000000000..6a26dbfb5 --- /dev/null +++ b/analyses/footprint/astra.yaml @@ -0,0 +1,163 @@ +# The footprint section: the footprints of the full and tomographic samples, +# their survey statistics, and the structural masks as delivered. + +spec_version: "0.1.0" +label: Footprints and survey statistics +description: >- + The footprint of the calibrated sample and of its tomographic sample as + HEALPix maps at nside 4096 (RING, 0.86′ pixels), the area, effective number + density and shape noise of each sample over them, and the structural masks + the selection's mask bits come from. The covariance and mock sections take + their survey geometry and noise from here. + +analyses: + sp: + path: ../.. + catalogue: + path: ../catalogue + redshifts: + path: ../redshifts + +outputs: + structural_masks: + label: Structural masks + type: data + format: json + description: >- + The mask group's DR6 masks as components, one boolean healsparse map + per bit at nside 131072: 1 and 2 star halos, 4 bright stars, 8 manual, + 64 r-band, 1024 MaxiMask, and the coverage bits 16, 32, 128, 256 and + 2048 as delivered. ShapePipe writes the same bits into its MASK_* + columns, which the selection cuts on; the bit-8 map also masks the PSF + stars, which lack that column. The result is the manifest of the + release's masks/structural/, checked against its MD5SUMS. + recipe: + command: >- + python -m sp_validation.fetch '${{unions_v2}}/v2.0.0/masks/structural' + --version v2.0.0 --md5sums '${{unions_v2}}/v2.0.0/MD5SUMS' --out {output} + resources: { cpus: 1, memory: 2GB, time_limit: 2h } + + footprint: + label: Footprint of the calibrated sample + type: data + format: fits + description: >- + The nside-4096 RING pixels holding at least one galaxy of the + calibrated sample (uint8), written by the sample build at the recipe's + footprint_nside. + inputs: [catalogue.calibrated_catalogue] + decisions: [footprint_definition] + recipe: + command: >- + cp {inputs.catalogue.calibrated_catalogue}/masks/footprint-nside4096-ring.fits + {output} + + footprint_tomo: + label: Footprint of the tomographic sample + type: data + format: fits + description: >- + The occupied nside-4096 pixels of the galaxies on tiles that hold at + least one galaxy in bins 1–4 (header SAMPLE = 'TOM_BIN_ID>0 tiles'). + Tiles whose galaxies all fall outside the bins, mostly tiles without + PhotoPipe photometry or with incomplete photometry, leave the + tomographic footprint whole. + inputs: [redshifts.tomographic_sample] + decisions: [footprint_definition, tomographic_footprint] + recipe: + command: >- + mkdir -p fp && python ../../workflow/scripts/footprint_masks.py + {inputs.redshifts.tomographic_sample}/catalogs/calibrated fp + && mv fp/tomo.fits {output} + resources: { cpus: 32, memory: 128GB, time_limit: 1h } + + survey: + label: Survey statistics on the full footprint + type: data + format: json + description: >- + Rows, area, and n_eff, σ_e, Σw and Σw² of the whole sample and of each + bin over the full footprint. Each sample's σ_e is that of its own + calibrated shear as cosmo_val measures it (a bin's R_k⁻¹ R_all e minus + its weighted mean). + inputs: [redshifts.tomographic_sample, footprint, footprint_tomo] + recipe: + command: >- + mkdir -p stats && python ../../workflow/scripts/survey_stats.py + {inputs.redshifts.tomographic_sample} stats && mv stats/survey.json {output} + resources: { cpus: 32, memory: 128GB, time_limit: 1h } + + survey_tomo: + label: Survey statistics on the tomographic footprint + type: data + format: json + description: >- + The tomographic footprint's area and tile count, and each bin's n_eff, + σ_e, Σw and Σw² over it, with the ratio of analytic to measured + shape-noise variance at nside 256 on both footprints. + inputs: [redshifts.tomographic_sample, footprint, footprint_tomo] + recipe: + command: >- + mkdir -p stats && python ../../workflow/scripts/survey_stats.py + {inputs.redshifts.tomographic_sample} stats && mv stats/survey_tomo.json {output} + resources: { cpus: 32, memory: 128GB, time_limit: 1h } + +decisions: + footprint_definition: + label: Footprint from occupied pixels at nside 4096 + rationale: >- + A footprint is the set of nside-4096 pixels holding at least one + galaxy, and areas and densities are taken over those pixels. At about 7 + galaxies per arcmin² a pixel inside the survey is empty by chance about + 0.6% of the time, so the area is slightly underestimated, and holes + smaller than a pixel are not resolved. It needs only the catalogue. + options: + occupied_nside_4096: + label: Occupied pixels, nside 4096 + coverage_and_masks: + label: ShapePipe coverage maps with the structural masks + description: >- + The geometric footprint, independent of galaxy density; needs the + coverage maps and masks at nside 131072 degraded with a coverage + threshold. + + tomographic_footprint: + label: Tomographic footprint by tile + rationale: >- + The tomographic sample covers less sky than the full one, because + tiles without PhotoPipe photometry, or whose galaxies all fail the BPZ + range or gold, have no binned galaxy. Its footprint keeps every + occupied pixel of a tile holding a binned galaxy, so a pixel within a + binned tile is not lost because none of its few galaxies landed in a + bin. At the binned sample's 5.1 galaxies per arcmin² a pixel holds 3.8 + binned galaxies on average, so a footprint of pixels holding one would + lose about 2% of its interior pixels by chance. + options: + binned_tiles: + label: Occupied pixels of tiles holding a binned galaxy + binned_pixels: + label: Pixels holding a binned galaxy + description: Empties about 2% of interior pixels by chance. + full_footprint: + label: The full sample's footprint + description: >- + Counts as survey area the tiles with no binned galaxy, which lowers + every bin's n_eff. + +findings: + survey_area: + claim: >- + The v2.0.0 calibrated sample covers 5,223 deg² with n_eff = 6.91 + arcmin⁻² and σ_e = 0.289 per component; its tomographic sample covers + 4,582 deg² on 19,034 of the 22,200 tiles that hold a galaxy. + evidence: + - artifact: survey + quote: { exact: "\"area_deg2\": 5223.409980599079" } + - artifact: survey + quote: { exact: "\"n_eff\": 6.913058645076713" } + - artifact: survey + quote: { exact: "\"sigma_e\": 0.28898648795041854" } + - artifact: survey_tomo + quote: { exact: "\"area_deg2\": 4582.166071505111" } + - artifact: survey_tomo + quote: { exact: "\"tomographic\": 19034" } diff --git a/analyses/inference/astra.yaml b/analyses/inference/astra.yaml new file mode 100644 index 000000000..d1ec35a2f --- /dev/null +++ b/analyses/inference/astra.yaml @@ -0,0 +1,231 @@ +# Cosmological inference from the blinded data vector with CosmoSIS. +# +# Not yet run on v2. The v2_0_0 selections are the settings of the committed +# CosmoSIS templates (cosmo_inference/cosmosis_config/templates/, made for +# the v1.4.6.3 2D analysis); the m and Δz priors come from the +# shear_calibration and redshifts sections instead of the templates' v1.4 +# numbers. SACC-based tomographic inference is PR #461 (open, +# feat/inference-leg); develop's converter reads single-bin ξ± FITS files. + +spec_version: "0.1.0" +label: Inference +description: >- + The posterior of the cosmological parameters given the blinded + tomographic data vector: the SACC converted to a CosmoSIS 2pt FITS file, + a nested-sampling chain over the cosmological, intrinsic-alignment, + baryonic, shear-calibration, redshift and PSF-leakage parameters, and its + summary. Since the data vector is blinded, so are the constraints. Not yet + run on v2. +tags: [inference, cosmosis] + +analyses: + sp: + path: ../.. + data_vectors: + path: ../data_vectors + redshifts: + path: ../redshifts + shear_calibration: + path: ../shear_calibration + psf_systematics: + path: ../psf_systematics + +outputs: + cosmosis_data: + label: CosmoSIS data file + type: data + format: fits + description: >- + The data vector's statistic chosen for inference, every bin pair in + type-major order with the covariance permuted to match, one n(z) + column per bin, and the ρ/τ statistics with their covariance for the + PSF-systematics term. + inputs: [data_vectors.data_vector, redshifts.nz_tomo] + decisions: [inference_statistic] + recipe: + command: >- + python ../../cosmo_inference/scripts/cosmosis_fitting.py + --sacc {inputs.data_vectors.data_vector} + --statistic {decisions.inference_statistic} --out {output} + + chain: + label: Posterior chain + type: data + format: txt + description: >- + The nested-sampling chain of CosmoSIS (CSL fork UNIONS-WL b7b1552a): + CAMB with the chosen non-linear model, NLA intrinsic alignments, + additive Δz shifts per bin, a multiplicative bias per bin and the + additive PSF term ξ_sys built from the ρ/τ statistics, with a + Gaussian likelihood at fixed covariance and the angular cuts of the + template. + inputs: + - cosmosis_data + - sp.cosmosis_pipeline + - sp.cosmosis_values + - sp.cosmosis_priors + - shear_calibration.shear_bias + - redshifts.realisations + - psf_systematics.leakage_fit + decisions: + - sampler + - nonlinear_model + - ia_model + - ia_prior + - psf_leakage_model + - m_prior + - dz_prior + - cosmology_priors + - inference_scale_cut + recipe: + command: >- + python ../../cosmo_inference/scripts/run_cosmosis.py + --data {inputs.cosmosis_data} --pipeline {inputs.sp.cosmosis_pipeline} + --values {inputs.sp.cosmosis_values} --priors {inputs.sp.cosmosis_priors} + --m-bias {inputs.shear_calibration.shear_bias} + --nz-realisations {inputs.redshifts.realisations} + --leakage {inputs.psf_systematics.leakage_fit} + --sampler {decisions.sampler} --out {output} + resources: { cpus: 192, memory: 300GB, time_limit: 48h } + + constraints: + label: Parameter constraints + type: table + format: json + description: >- + Marginal summaries of S8, Ω_m and the nuisance parameters from the + chain: the weighted mean and 68 % interval, and the 2D-marginal mode + for S8 and Ω_m. Blinded. + inputs: [chain] + recipe: + command: >- + python ../../cosmo_inference/scripts/chain_postprocessing.py + --chain {inputs.chain} --out {output} + +decisions: + inference_statistic: + label: Statistic for inference + rationale: >- + ξ± is the configuration-space data vector; pseudo-Cℓ needs the + bandpower windows in the likelihood (not yet supported by the + converter); COSEBIs compress ξ± into a few modes. The templates fit ξ±. + options: + xi_pm: + label: ξ± + pseudo_cl: + label: Pseudo-Cℓ + cosebis: + label: COSEBIs + + sampler: + label: Sampler + rationale: >- + Nested sampling gives the evidence and handles the projection effects + of a many-parameter posterior. The templates use PolyChord with 192 + live points; PR #461 runs Nautilus, which v1.4's 2D analysis used as a + consistency check. + options: + polychord: + label: PolyChord, 192 live points + nautilus: + label: Nautilus + + nonlinear_model: + label: Non-linear matter power spectrum + rationale: >- + HMCode2020 models baryonic feedback with one parameter, log T_AGN, + marginalised over a uniform 7.3–8.0. In v1.4 Halofit and HMCode + without feedback were robustness checks. + options: + hmcode2020_feedback: + label: HMCode2020, log T_AGN ~ U(7.3, 8.0) + halofit: + label: Halofit + hmcode2020_no_feedback: + label: HMCode2020 without baryonic feedback + + ia_model: + label: Intrinsic-alignment model + rationale: >- + The non-linear alignment model with amplitude A_IA and no redshift + dependence. TATT's higher-order terms are not modelled. + options: + nla: + label: NLA, η_IA = 0 + none: + label: No intrinsic alignments + + ia_prior: + label: Prior on A_IA + rationale: >- + A direct measurement of red and blue galaxies' alignments gives + A_IA = 0.83 ± 0.39; the templates double the width to 0.7. A flat prior + lets A_IA trade against S8. + options: + gaussian_0p83_0p7: + label: A_IA ~ N(0.83, 0.7) + flat: + label: A_IA ~ U(−5, 5) + + psf_leakage_model: + label: PSF systematics in the model + rationale: >- + The additive ξ_sys from α and β times the ρ statistics is added to the + model, with α and β sampled under Gaussian priors from the leakage fit + (η fixed at zero). The template's priors are v1.4's single-bin values; + four bins need one α and β per bin. + options: + gaussian_alpha_beta: + label: α, β sampled with Gaussian priors from the leakage fit + flat_alpha_beta: + label: α, β sampled with flat priors + none: + label: No ξ_sys term + + m_prior: + label: Multiplicative-bias prior + rationale: >- + A Gaussian prior per bin on the residual multiplicative bias m from + the image simulations (shear_calibration.shear_bias), which rescales each + ξ±_ij by (1 + m_i)(1 + m_j). + options: + image_sims_gaussian: + label: Gaussian per bin from shear_calibration.shear_bias + none: + label: m = 0 + + dz_prior: + label: Redshift uncertainty + rationale: >- + Each bin's n(z) is shifted by Δz_i with a Gaussian prior whose width + comes from the n(z) realisations; alternatively the realisations are + marginalised directly, or compressed into the few n(z) modes the data + can see (sp_validation.nz.modes). + options: + gaussian_shift: + label: Additive Δz per bin, Gaussian prior from the realisations + realisations: + label: Marginalise over the n(z) realisations + modes: + label: Likelihood-aware n(z) modes + + cosmology_priors: + label: Sampled cosmological parameters and priors + rationale: >- + ω_c, ω_b, h, n_s and S8 are sampled with KiDS-Legacy's prior ranges + and a BBN Gaussian on ω_b (0.0244 ± 0.00038); τ_reio = 0.0544, + Σm_ν = 0.06 eV, w = −1. + options: + kids_legacy: + label: KiDS-Legacy ranges with a BBN prior on ω_b + + inference_scale_cut: + label: Angular range of ξ± in the likelihood + rationale: >- + The templates cut ξ± to 12–83 arcmin, the range that passed the v1.4 + B-mode tests. In v1.4, 5–83 arcmin also passed and gave a worse fit. + options: + arcmin_12_83: + label: 12–83 arcmin + arcmin_5_83: + label: 5–83 arcmin diff --git a/analyses/mocks/astra.yaml b/analyses/mocks/astra.yaml new file mode 100644 index 000000000..f70e4f92c --- /dev/null +++ b/analyses/mocks/astra.yaml @@ -0,0 +1,206 @@ +# The GLASS mock ensemble: digital twins of the data with a known lensing +# signal, measured exactly as the data are. +# +# Each ensemble output is a directory with one file per seed. + +spec_version: "0.1.0" +label: Mocks +description: >- + An ensemble of lognormal GLASS skies (Tessore et al. 2023) at the fiducial + cosmology through the tomographic n(z), turned into shear catalogues that + share the data's geometry, and measured with the data's code and settings. + Painted mocks keep the real catalogue's positions, weights, PSF columns + and the modulus of each calibrated ellipticity, rotate each ellipticity to + a random angle and shear the GLASS sky onto it; sampled mocks draw + galaxies on the footprint with each bin's n_eff and σ_e. Every mock + statistic is sealed under a throwaway mock blind, so mocks and data pass + through the same concealment. The ensemble gives the empirical covariance, + the calibration of the null tests and the known-answer recovery tests. +tags: [mocks, glass, lognormal] + +analyses: + sp: + path: ../.. + catalogue: + path: ../catalogue + redshifts: + path: ../redshifts + footprint: + path: ../footprint + +outputs: + mock_blind: + label: Mock blind + type: data + format: json + description: >- + A throwaway blind drawn for the mocks + (python -m sp_validation.blinding init). Its shift is known, so the + blinded mock statistics can be compared with the input truth after + removing it. + recipe: + command: >- + d=$(mktemp -d) && python -m sp_validation.blinding init mock-ensemble + --registry "$d" && mv "$d"/mock-ensemble.blind.json {output} + + skies: + label: GLASS skies + type: data + format: npz + description: >- + One lognormal convergence sky per seed: matter shells to z = 3 from + the fiducial cosmology (CAMB, HMCode2020 with log T_AGN = 7.8, σ8 + rescaled), projected through the tomographic n(z) of each bin. Each + seed's kappa_alm.npz and its realised spectra beside the shell + theory. + inputs: [redshifts.nz_tomo] + decisions: [mock_count, shell_thickness, limber, sp.fiducial_cosmology] + recipe: + command: >- + mkdir -p {output} && for s in $(seq 1 100); do + python ../../scripts/glass_mock/paint_catalogue.py maps + --nz {inputs.redshifts.nz_tomo} --seed $s --nside 4096 --dx 120 + --zmax 3.0 --output {output}/seed_$(printf %05d $s) + --cache {output}/cache || exit 1; done + resources: { cpus: 28, memory: 160GB, time_limit: 400h } + + painted_catalogues: + label: Painted catalogues + type: data + format: h5 + description: >- + The calibrated catalogue painted with each seed's sky: real positions, + weights, bins and PSF columns; each ellipticity's modulus rotated to a + random angle and sheared by γ (not reduced shear) evaluated exactly at + the galaxy by a non-uniform spherical-harmonic transform. e2 is −1 + times HEALPix γ2, the UNIONS convention. + inputs: [skies, catalogue.calibrated_catalogue] + decisions: [mock_count] + recipe: + command: >- + mkdir -p {output} && for s in $(seq 1 100); do + n=$(printf %05d $s); + python ../../scripts/glass_mock/paint_catalogue.py paint + --input {inputs.catalogue.calibrated_catalogue} --maps {inputs.skies}/seed_$n + --seed $s --shear gamma --output {output}/seed_$n.h5 || exit 1; done + resources: { cpus: 16, memory: 32GB, time_limit: 100h } + + sampled_catalogues: + label: Sampled catalogues + type: data + format: fits + description: >- + Galaxies drawn on the tomographic footprint from each seed's matter + and lensing shells, with each bin's n_eff and per-component σ_e, a + linear galaxy bias of 1.2 and a photo-z scatter of 0.03(1 + z), by + scripts/glass_mock/make_glass_sim.py. + inputs: [redshifts.nz_tomo, footprint.footprint_tomo, sp.cat_config] + decisions: [mock_count, shell_thickness, limber, sp.fiducial_cosmology] + recipe: + command: >- + mkdir -p {output} && for s in $(seq 1 100); do + python ../../scripts/glass_mock/make_glass_sim.py + -c {output}/glass_v2_tomo.yaml -s $((1000 + s)) -N $s || exit 1; done + resources: { cpus: 24, memory: 64GB, time_limit: 100h } + + mock_catalogues: + label: Mock catalogues + switch: mock_method + cases: + painted: painted_catalogues + sampled: sampled_catalogues + + mock_statistics: + label: Mock data vectors + type: data + format: sacc + description: >- + Each mock's tomographic data vector, measured by the data's code with + the data's settings (the θ grids, COSEBIs modes and scale cut, + pure-mode operator, pseudo-Cℓ estimator and bandpowers of + data_vectors), without patches, and sealed under the mock blind; one + SACC per seed with the analytic covariance of the data. + inputs: [mock_catalogues, mock_blind, redshifts.nz_tomo, sp.cat_config] + decisions: [mock_count] + recipe: + command: >- + python ../../workflow/scripts/measure_mock_ensemble.py + --catalogues {inputs.mock_catalogues} --blind {inputs.mock_blind} + --cat-config {inputs.sp.cat_config} --out {output} + resources: { cpus: 48, memory: 90GB, time_limit: 200h } + +decisions: + mock_method: + label: How the mock galaxies are made + rationale: >- + A painted mock is a digital twin of the data: it keeps the real + positions, weights, bins and shape-noise distribution, so the scatter + across seeds is the variance conditional on the survey's geometry, and + its PSF columns allow leakage to be injected. A sampled mock draws + galaxies from n_eff and σ_e per bin on the footprint, which is cheaper + and ignores the real positions and weights. + options: + sampled: + label: Sampled galaxies on the footprint + description: >- + The ensemble beside v2.0.0 + (analyses/mock-ensemble-sampled-alltiles, 100 mocks), made for the + earlier n(z) and bins (v2.0.0-old-nz), not for v2.0.0's. + painted: + label: Painted on the calibrated catalogue + description: >- + sp_validation.mocks.painted; the seed-1 known-answer gate passed + on the first calibrated v2 sample (analyses/mock-ensemble-tomo). + precomputed_v1_4: + label: The v1.4.6.3 GLASS suite (350 mocks) + excluded: Made for the v1.4.6.3 catalogue, footprint and n(z). + + mock_count: + label: Ensemble size + rationale: >- + The ensemble sets how well the mock covariance and the tails of the + null-test distributions are resolved: a variance from N mocks is good + to √(2/N), 14 % at N = 100, and an empirical PTE cannot resolve tails + below about 1/N. Paper II used 350 v1.4 mocks. + options: + n100: + label: 100 mocks + n20: + label: 20 mocks + n350: + label: 350 mocks + + shell_thickness: + label: GLASS shell thickness + rationale: >- + The lognormal matter field is drawn in comoving shells; thinner shells + follow the lensing kernel more closely at a higher cost. The v2 + ensemble uses 120 Mpc; GlassMockConfig defaults to 200 Mpc. + options: + dx_120: + label: 120 Mpc + insights: [glass] + dx_200: + label: 200 Mpc + + limber: + label: Shell spectra + rationale: >- + The angular spectra of the matter shells are computed in the Limber + approximation, or exactly (slower), which matters on the largest + scales. + options: + limber: + label: Limber + exact: + label: Exact (non-Limber) shell spectra + +prior_insights: + glass: + claim: >- + GLASS draws lognormal matter shells and integrates the weak-lensing + fields along the line of sight. + evidence: + - doi: "10.48550/arXiv.2302.01942" + quote: + exact: "the weak lensing fields are subsequently computed by a line-of-sight integration" diff --git a/analyses/psf_systematics/astra.yaml b/analyses/psf_systematics/astra.yaml new file mode 100644 index 000000000..6d7ab2bb0 --- /dev/null +++ b/analyses/psf_systematics/astra.yaml @@ -0,0 +1,215 @@ +# PSF systematics: the ρ/τ statistics of the survey and the PSF-leakage fit +# they feed, the object-wise leakage regression, and the four diagnostics +# that judge ShapePipe's decisions on a 27-tile patch of DR6. +# +# The patch diagnostics are made today by the ShapePipe patch testbed's +# compare/compare.py (analyses/shapepipe-patch-testbed on Fir), across +# ShapePipe's universes. Their recipes below name the module they belong in. + +spec_version: "0.1.0" +label: PSF systematics +description: >- + How the PSF enters the shear. ρ statistics correlate PSF-model residuals at + star positions; τ statistics correlate each bin's galaxy shapes with them. + Fitting τ with ρ templates gives the leakage α (shear ∝ PSF ellipticity), + β and η of each bin, from which the additive ξ_sys follows. The object-wise + regression measures α against S/N and size. On a 27-tile patch, four + diagnostics compare ShapePipe's universes: PSF residuals on reserve stars, + ρ/τ, the selected galaxies and object-matched shape shifts against the + baseline. ρ and τ carry no cosmological signal and are not blinded. +tags: [psf, systematics, rho-tau, leakage] + +analyses: + sp: + path: ../.. + catalogue: + path: ../catalogue + redshifts: + path: ../redshifts + +outputs: + rho_tau_part: + label: ρ and τ statistics (SACC part) + type: data + format: sacc + description: >- + ρ_0…ρ_5 of the PSF catalogue's stars (PSF-only, shared by all bins) + and τ_0, τ_2, τ_5 of each tomographic bin, on the reporting grid, with + their covariance: the jackknife of ρ over 100 patches and the τ + covariance of tau_covariance. The ρ/τ block of the data vector. + inputs: + - sp.cat_config + - catalogue.calibrated_catalogue + - redshifts.bin_responses + - catalogue.star_catalogue + - catalogue.psf_catalogue + decisions: [tau_covariance, catalogue.leakage_correction] + recipe: + command: >- + python ../../workflow/scripts/run_rho_tau.py --ver SP_v2.0.0 + --cat-config {inputs.sp.cat_config} --min-sep 1.0 --max-sep 250.0 + --nbins 20 --npatch 100 --tomo + --cov-estimate-method {decisions.tau_covariance} --out {output} + resources: { cpus: 48, memory: 64GB, time_limit: 6h } + + leakage_fit: + label: PSF-leakage α, β, η per bin + type: metric + format: json + description: >- + Per tomographic bin, the fit of τ_{0,2,5} by α, β and η times the ρ + templates (τ_0 = αρ_0 + βρ_2 + ηρ_5, τ_2 = αρ_2 + βρ_1 + ηρ_4, + τ_5 = αρ_5 + βρ_4 + ηρ_3, ξ+ components): the parameters, their errors, + the fit's χ², degrees of freedom and PTE. v2.0.0's values were computed + by the run's report script (analyses/cosmo-val-v2-tomo-perbin/report/ + figures.py, report/summary.json `leakage`) from the data vector's ρ/τ + block. + inputs: [rho_tau_part] + decisions: [leakage_fit_method] + recipe: + command: >- + python ../../workflow/scripts/cv_rho_tau_fits.py + --rho-tau {inputs.rho_tau_part} --method {decisions.leakage_fit_method} + --out {output} + resources: { cpus: 1, memory: 16GB, time_limit: 2h } + + objectwise_leakage: + label: Object-wise leakage regression + type: data + format: json + description: >- + Weighted regression of each galaxy's shear on its PSF ellipticity in + bins of S/N and size ratio, and the scale-dependent α(θ) from ρ/τ: + where in the sample the leakage sits. + inputs: + - sp.cat_config + - catalogue.calibrated_catalogue + - rho_tau_part + recipe: + command: >- + python ../../workflow/scripts/cv_objectwise_leakage.py --ver SP_v2.0.0 + --cat-config {inputs.sp.cat_config} --rho-tau {inputs.rho_tau_part} + --out {output} + resources: { cpus: 12, memory: 30GB, time_limit: 3h } + + # ShapePipe's diagnostics, on the 27 south-cap tiles of the ShapePipe patch + # testbed (chosen to span sharp and typical seeing). Each reads ShapePipe's + # outputs by pin to its baseline_run1 universe (declared on sp as shapepipe). + psf_residuals: + label: PSF model residuals on reserve stars + type: figure + format: png + description: >- + Star-minus-model size and ellipticity on the 20 % reserve stars held + out of the PSFEx fit, against flux, seeing, g−i colour and position on + the CCD. Judges star selection, PSF sampling, chromaticity and model + complexity. Reads sp.shapepipe.star_catalogue#baseline_run1 by pin. + inputs: [sp.shapepipe.star_catalogue#baseline_run1] + recipe: + command: >- + python -m sp_validation.patch stars + --stars {inputs.sp.shapepipe.star_catalogue#baseline_run1} + --out {output} + + rho_tau_statistics: + label: ρ and τ statistics on the patch + type: figure + format: png + description: >- + ρ statistics of the reserve stars' PSF-model residuals and τ + correlations of the patch's galaxy shapes with them, the additive PSF + systematics the shear inherits from a ShapePipe choice. Reads + sp.shapepipe.final_cat#baseline_run1 and + sp.shapepipe.star_catalogue#baseline_run1 by pin. + inputs: + - sp.shapepipe.final_cat#baseline_run1 + - sp.shapepipe.star_catalogue#baseline_run1 + recipe: + command: >- + python -m sp_validation.patch rho_tau + --cat {inputs.sp.shapepipe.final_cat#baseline_run1} + --stars {inputs.sp.shapepipe.star_catalogue#baseline_run1} + --out {output} + + galaxy_sample: + label: Selected galaxies on the patch + type: table + format: csv + description: >- + The number, size and S/N distribution of galaxies with a shape + measurement, per tile: what a change to detection, masking or shape + measurement does to the sample. Reads + sp.shapepipe.final_cat#baseline_run1 by pin. + inputs: [sp.shapepipe.final_cat#baseline_run1] + recipe: + command: >- + python -m sp_validation.patch galaxies + --cat {inputs.sp.shapepipe.final_cat#baseline_run1} + --out {output} + + shape_shifts: + label: Shape shifts against the baseline + type: figure + format: png + description: >- + Object-matched differences in calibrated shape and PSF quantities + between a ShapePipe universe and baseline_run1, with the metacal + response, against S/N and size. Against baseline_run1 itself it is the + reproduction check of the patch. Reads + sp.shapepipe.final_cat#baseline_run1 by pin. + inputs: [sp.shapepipe.final_cat#baseline_run1] + recipe: + command: >- + python -m sp_validation.patch shapes + --run {inputs.sp.shapepipe.final_cat#baseline_run1} + --baseline {inputs.sp.shapepipe.final_cat#baseline_run1} + --out {output} + +decisions: + tau_covariance: + label: Covariance of the τ statistics + rationale: >- + τ is a cross-correlation of galaxy shapes with PSF residuals, whose + analytic Gaussian covariance follows from the measured ρ, the shape + noise and the pair counts. The jackknife needs many patches for the + ~60 τ points of a bin; the simulation estimate draws 300 Gaussian + realisations and needs the Hartlap factor. + options: + th: + label: Analytic + jk: + label: Jackknife + sim: + label: Simulations (300, Hartlap-corrected) + + leakage_fit_method: + label: Fit of the leakage parameters + rationale: >- + τ = (α, β, η) · ρ is linear in the parameters, so a least-squares fit + with ρ held fixed and the τ covariance as weight gives them and their + errors directly. The errors-in-variables fit (PR #454) fits ρ and τ + jointly on their jackknife, which accounts for the noise of the ρ + templates; MCMC samples the same likelihood as the least-squares fit. + options: + lsq: + label: Least squares in τ, ρ fixed + insights: [tau_leakage] + eiv: + label: Joint errors-in-variables fit of ρ and τ + description: >- + PR #454 (open, origin/edge). The v2.0.0 run configured + rho_tau_method eiv, but its DAG made no fit product; the per-bin + values of v2.0.0 are the least-squares fit. + emcee: + label: MCMC (emcee) on the least-squares likelihood + +prior_insights: + tau_leakage: + claim: >- + The τ statistics constrain the PSF-leakage α, β and η of a shape + catalogue against the ρ statistics of its PSF model; α arises from an + imperfect deconvolution of the PSF. + evidence: + - doi: "10.48550/arXiv.2011.03408" + quote: + exact: "from errors in the deconvolution of the PSF model from the galaxy" diff --git a/analyses/redshifts/astra.yaml b/analyses/redshifts/astra.yaml new file mode 100644 index 000000000..c7961bed3 --- /dev/null +++ b/analyses/redshifts/astra.yaml @@ -0,0 +1,426 @@ +# The redshifts section: tomographic bins, their n(z) by SOM direct +# calibration, the n(z) realisations, and the response of each bin. +# +# config/calibration/nz/v2.yaml (sp.nz_v2) is the recipe sp_validation.nz +# runs: it names the inputs and sets every value of the calibration, and its +# `@sc [decision:redshifts.*]` tags name the decisions below. The script reads only +# that file, so the decisions are attached to the outputs it makes. + +spec_version: "0.1.0" +label: Tomographic bins and n(z) +description: >- + The source redshift distributions of the tomographic analysis. Sources and + calibrators share one photometry, PhotoPipe's run on the DR6 detections: + the sources are the calibrated sample's rows with their photometry from the + v2 collection by DR6 object ID, the calibrators are DEEP2 and DEEP3 spectra + in the EGS from the collection's spec-z extension. A self-organising map + trained on the calibrators transfers their redshifts to the sources of each + of four BPZ bins; within each bin, a gold selection keeps the SOM groups + whose spectra agree with their sources' BPZ. An ensemble of 2,000 + realisations perturbs the calibration's inputs to give its uncertainty. + The calibration rests on one spectroscopic field. The bins then get their + own metacalibration response, with the sample's weight table held fixed. + +analyses: + sp: + path: ../.. + catalogue: + path: ../catalogue + +outputs: + nz_calibration: + label: SOM direct calibration + type: data + format: dir + description: >- + Everything sp_validation.nz.pipeline writes: nz_tomo.txt, nz_nontomo.txt, + tom_bin.parquet, realisations.npz, ensemble_inputs.npz, calibrators.npz, + som_model.npz, calibration_arrays.npz, summary.json and recipe.yaml (the + recipe, byte for byte). The recipe names the sources (the released + calibrated catalogue) and the collection by data-root path. + inputs: + [sp.nz_v2, catalogue.calibrated_catalogue, catalogue.collection, + sp.photopipe_specz] + decisions: + [source_photometry_join, tomographic_bins, calibrator_set, + photometry_as_delivered, z2_offset, som_map, gold_selection, + grid_step, ensemble_terms, sp.fiducial_cosmology] + recipe: + command: >- + python ../../scripts/calibration/calibrate_nz.py {inputs.sp.nz_v2} + --output {output} --workers 32 + resources: { cpus: 32, memory: 256GB, time_limit: 4h } + + nz_tomo: + label: Tomographic n(z) + type: data + format: txt + description: >- + z on a Δz = 0.05 grid over [0, 5] and one density per bin, each + integrating to the bin's share of the retained shear weight + (cosmo_val's shear.redshift_path). + inputs: [nz_calibration] + recipe: + command: cp {inputs.nz_calibration}/nz_tomo.txt {output} + + nz_nontomo: + label: Non-tomographic n(z) + type: data + format: txt + description: The sum of the bins, the n(z) of every TOM_BIN_ID > 0 galaxy. + inputs: [nz_calibration] + recipe: + command: cp {inputs.nz_calibration}/nz_nontomo.txt {output} + + tom_bin: + label: Each galaxy's bin + type: data + format: parquet + description: >- + OBJECT_ID, TOM_BIN_ID (1 to 4, 0 for a galaxy in no bin) and ZBAND, + row-aligned with the calibrated catalogue. + inputs: [nz_calibration] + recipe: + command: cp {inputs.nz_calibration}/tom_bin.parquet {output} + + realisations: + label: n(z) realisations + type: data + format: npz + description: >- + 2,000 draws of every bin at once, (draws, bins, z), each of unit + integral and recentred on the delivered n(z). + inputs: [nz_calibration] + recipe: + command: cp {inputs.nz_calibration}/realisations.npz {output} + + nz_summary: + label: Calibration summary + type: data + format: json + description: >- + The bin edges; each bin's mean redshift, shear weight before and after + gold, gold fraction and calibrator count; the photometry match of the + sources by shear weight; and the retention after the BPZ range and gold. + inputs: [nz_calibration] + recipe: + command: cp {inputs.nz_calibration}/summary.json {output} + + tomographic_sample: + label: Calibrated sample with its bins + type: data + format: dir + description: >- + The calibrated sample with each row's TOM_BIN_ID, and catalogs/ + response.json with each bin's record under bins: R, its shear and + selection parts, c_e and the delete-one-tile jackknife covariance, + measured with the sample's weight table held fixed and each galaxy's + bin held fixed across the metacal branches (bins come from the saved + SOM model, so galaxies that only a sheared branch selects get one too). + provenance/bin_response_checks.json records that the bins are those of + tom_bin and that the bins' sums add to the sample's. + inputs: [catalogue.calibrated_catalogue, nz_calibration] + decisions: [sample_calibration] + recipe: + command: >- + cp -r {inputs.catalogue.calibrated_catalogue} {output} + && mkdir -p {output}/nz {output}/provenance + && cp {inputs.nz_calibration}/tom_bin.parquet {output}/nz/ + && cp {inputs.nz_calibration}/som_model.npz {output}/provenance/nz_som_model.npz + && cp {inputs.nz_calibration}/calibration_arrays.npz {output}/provenance/nz_calibration_arrays.npz + && cp {inputs.nz_calibration}/recipe.yaml {output}/provenance/nz_recipe.yaml + && python ../../scripts/calibration/bin_responses.py + ../../config/calibration/sample/v2.yaml --output {output} --workers 64 + resources: { cpus: 64, memory: 256GB, time_limit: 1h } + + bin_responses: + label: Response of each bin + type: data + format: json + description: >- + catalogs/response.json of the tomographic sample: the whole sample's + record and, under bins, each bin's. + inputs: [tomographic_sample] + recipe: + command: cp {inputs.tomographic_sample}/catalogs/response.json {output} + +decisions: + source_photometry_join: + label: Source photometry joined on the DR6 object ID + rationale: >- + Each catalogue row takes PhotoPipe photometry and BPZ from the + collection by OBJECT_ID = 10⁶ × tile + NUMBER, an exact integer key. A + row with no DR6 number, or an ID the collection lacks, keeps NaN + photometry and gets no bin; summary.json reports its share of the + shear weight. + Values: nz.inputs.OBJECT_ID = "OBJECT_ID". + options: + object_id: + label: Join on OBJECT_ID + description: Unmatched rows are counted, never guessed. + exact_position: + label: Exact RA/Dec match + description: >- + Depends on two catalogues writing the same bits for a position; a + rounding difference silently drops or mismatches rows. + + tomographic_bins: + label: Four equal-weight bins in BPZ + rationale: >- + Four bins cut on the DR6 BPZ point estimate Z_B within [0.10, 1.20), + lower edges included. Each run places the three inner edges at the + shear-weight quartiles of its sources with complete photometry and BPZ + in range, before gold, and records them in summary.json; the + calibrators are split by the same edges. Gold then removes a different + share of each bin, so the delivered bins hold only roughly equal + weight. Equal weight gives the bins comparable signal-to-noise; the + range is where BPZ on ugriz is usable. + Values: v2.yaml#bins.count = 4; v2.yaml#bins.range = [0.1, 1.2]. + options: + equal_weight_quartiles: + label: Equal shear weight, recomputed per run + fixed_edges: + label: Fixed edges 0.10/0.37/0.55/0.76/1.20 + description: >- + The shear-weight quartiles of the first calibration, kept fixed. + Bins stay comparable between runs but drift from equal weight. + equal_number: + label: Equal galaxy number + description: Quantiles of galaxy count rather than shear weight. + fixed_width: + label: Fixed-width bins + description: >- + As KiDS-1000: Δz_B = 0.2 over 0.1–0.9 and a fifth bin over 0.9–1.2. + som_cell_assignment: + label: Bins assigned by SOM cell + excluded: >- + Needs a wide-field SOM and a deep-field transfer this calibration + does not have. + + calibrator_set: + label: DEEP2 and DEEP3 spectra in the EGS + rationale: >- + Calibrators are a selection on the collection's spec-z extension, so + they share the sources' photometry: DEEP2 and DEEP3 spectra whose + position lies in the EGS (RA 213–217°, Dec 51.5–54°), each kept once, + with z > 0.002 (removing stars) and complete ugriz after the z2 fill. + DEEP2 also covers Field 2 (RA 252°, Dec 35°), which DEEP2 preselected + by BRI colour to z > 0.7; a SOM trained on both would calibrate the low + bins on a sample missing low-z galaxies. No redshift-quality cut is + applied: the compilation gives every DEEP2/3 entry confidence 0.99. One + field means no field-to-field variance beyond the ensemble's + line-of-sight term, and no model of the spectroscopic selection. + Values: v2.yaml#inputs.calibrators.surveys = ["deep2_final", "deep3_final"]; + v2.yaml#inputs.calibrators.field = {"ra": [213.0, 217.0], "dec": [51.5, 54.0]}; + v2.yaml#inputs.calibrators.z_min = 0.002. + options: + deep2_deep3_egs: + label: DEEP2 + DEEP3 in the EGS + deep2_both_fields: + label: DEEP2 in the EGS and Field 2, with DEEP3 + description: >- + In SOM groups shared with the EGS, Field 2's spec-z sit higher by + +0.44, +0.31, +0.14 and +0.017 in bins 1–4, and adding it moves + bin 3's mean z by +0.039. + add_desi_dr1: + label: Add DESI DR1 spectra on the same tiles + description: About 36,000 spectra with their own targeting. + + photometry_as_delivered: + label: PhotoPipe photometry used as delivered + rationale: >- + [HARDCODED] Sources and calibrators take PhotoPipe's magnitudes with no + stellar-locus or zero-point correction; the code has no correction + step. The EGS sits off the DR6 stellar locus (+0.035 in g−r, +0.055 in + i−z) and DR6 tiles carry 9–28 mmag zero-point errors in colour; these + enter the ensemble as its zero-point term. Correcting the EGS by the + full stellar offset would raise ⟨z⟩ by up to +0.018, +0.005, +0.007 and + +0.013 in bins 1–4. The photometry is PhotoPipe's to correct. + Values: none. + options: + as_delivered: + label: As delivered + correct_egs: + label: Correct the EGS only + description: >- + Galaxies follow only 0.6–0.9 of a stellar offset, so this + over-corrects. + per_tile_stellar_locus: + label: Per-tile stellar-locus correction of sources and calibrators + + z2_offset: + label: z2 fills an undetected z + rationale: >- + Where z is undetected, the second z exposure (z2) fills it after a + constant offset (−0.1105 mag), for sources and calibrators alike; + canonical z takes precedence. Without it the sources measured only in + z2, a third of the gold weight, lack complete photometry and leave + every bin. + Values: v2.yaml#z2_offset = -0.1104888916015625. + options: + offset_z2: + label: z2 plus a constant offset + canonical_only: + label: Canonical z only + description: Drops the z2-only sources. + + som_map: + label: 101 × 101 SOM on the calibrators, 2,000 groups + rationale: >- + A planar 101 × 101 batch SOM, 60 epochs from a PCA initialisation, seed + 42, trained on the calibrators alone on the ten pairwise ugriz colours + and r, each standardised. Ward clustering merges its 10,201 cells into + 2,000 groups of about five spectra, the unit of the calibration weights + and of the gold test; each source goes to its nearest cell with no + distance cut. + Values: v2.yaml#som.side = 101; v2.yaml#som.epochs = 60; + v2.yaml#som.seed = 42; v2.yaml#groups = 2000. + options: + calibrator_trained_101: + label: 101 × 101 on the calibrators, 2,000 groups + insights: [som_gold_sample] + train_on_sources: + label: Train on the sources + description: Most cells then hold no spectrum. + no_grouping: + label: Calibrate per cell + description: About one spectrum per cell; noisier weights. + + gold_selection: + label: Gold groups at max(0.4, 5 × NMAD) + rationale: >- + Within a bin, a SOM group is gold when it holds an in-bin spectrum and + its spectra's mean spec-z agrees with its sources' weighted mean BPZ + within max(0.4, 5 × NMAD(spec-z − BPZ)) over every calibrator; sources + outside gold get TOM_BIN_ID 0. Most of gold's loss is groups with no + in-bin spectrum, not the agreement test. The factor's range enters the + ensemble. + Values: v2.yaml#gold_qc.floor = 0.4; v2.yaml#gold_qc.nmad_factor = 5. + options: + floor_0_4_nmad_5: + label: max(0.4, 5 × NMAD) + insights: [som_gold_sample] + support_only: + label: Every group with an in-bin spectrum + description: No agreement test. + + grid_step: + label: n(z) on a Δz = 0.05 grid + rationale: >- + The weighted spectra are deposited linearly on a grid of step 0.05 over + [0, 5], which keeps each bin's mass and mean and widens it by about + step²/6 in variance. A finer grid resolves the galaxy overdensities + along the single EGS sightline, which belong to the calibration field + and not to the sources. Against a 0.01 grid, 0.05 moves the ξ± theory + (12–83′) by Δχ² < 0.01 without intrinsic alignments and 0.06 with + A_IA = 1. + Values: v2.yaml#grid.step = 0.05. + options: + step_0_05: + label: Δz = 0.05 + step_0_01: + label: Δz = 0.01 + description: Carries the EGS sightline's spikes into the n(z). + + ensemble_terms: + label: Statistical and systematic terms of the realisations + rationale: >- + 2,000 draws perturb the calibration's inputs and recalibrate every bin + together. Statistical terms: a bootstrap of the spectra, and a + lognormal line-of-sight density through the 2° × 0.25° DEEP2/3 strip + with bias 1.3. Systematic terms: EGS zero points against the wide field + (colour scatter and correlations from stellar-locus regression on + 3.4 deg² patches, and 0.01 mag grey), the z2 → z constant (0.02 mag), + spec-z failures (1%), and the gold factor drawn in [4, 6]. The zero + points dominate σ⟨z⟩ and correlate ⟨z⟩ between bins. Spectroscopic + selection and method bias calibrated on simulations are not modelled, + so the spread is a lower bound. + Values: v2.yaml#ensemble.draws = 2000; v2.yaml#ensemble.bootstrap = True; + v2.yaml#ensemble.density.field = [2.0, 0.25]; + v2.yaml#ensemble.density.bias = 1.3; + v2.yaml#ensemble.zero_points.colour_sigma = [0.0215, 0.0194, 0.0119, 0.0208]; + v2.yaml#ensemble.zero_points.colour_corr = [[1.0, -0.59, 0.13, -0.13], [-0.59, 1.0, -0.05, 0.16], [0.13, -0.05, 1.0, -0.49], [-0.13, 0.16, -0.49, 1.0]]; + v2.yaml#ensemble.zero_points.grey = 0.01; + v2.yaml#ensemble.z2_offset = 0.02; + v2.yaml#ensemble.specz_failure = 0.01; + v2.yaml#ensemble.nmad_factor = [4, 6]. + options: + statistical_and_systematic: + label: Statistical and systematic terms + statistical_only: + label: Bootstrap and density only + description: Expected Δχ² 0.16 on v2 ξ±, against 1.06 with the systematic terms. + delta_z_shifts: + label: Independent per-bin Δz shifts + description: >- + σ = 0.018 per bin, the 2D analysis's prior: expected Δχ² 4.08 and no + correlation between bins. + + sample_calibration: + label: Where each bin's response is applied + rationale: >- + The response belongs to a sample: it is the derivative of that + sample's weighted mean shear. The v2.0.0 bins have responses 0.854, + 0.858, 0.831 and 0.775 (R₁₁) against 0.786 for the whole sample, so the + whole sample's R applied to bins 1–3 puts their shear high by 6–9%. + Every bin's record is kept with the sample's; the question is whether + the catalogue's e1, e2 carry it. + options: + per_sample_at_measurement: + label: Catalogue keeps R_all; each bin's R applied when it is measured + description: >- + The shear of bin k is R_k⁻¹ R_all e minus the bin's weighted mean, + applied by sp_validation as it measures a bin. A reader that takes + the columns as they are measures a bin with the whole sample's R. + calibrate_in_release: + label: Catalogue's e1, e2 calibrated with each row's bin's R and c + description: >- + Each galaxy carries the calibration of its own bin; a statistic of + the whole catalogue is then that of the union of separately + calibrated bins. + whole_sample: + label: The whole sample's R for every bin + excluded: Biases the shear of bins 1–3 by 6–9%. + +prior_insights: + som_gold_sample: + claim: >- + A SOM trained on the spectroscopic sample defines, per tomographic bin, + a gold sample fully represented by spectra. + evidence: + - doi: "10.48550/arXiv.1909.09632" + quote: + exact: "We use the SOM to define a 100% represented ‘gold’ cosmic shear sample, per tomographic bin." + +findings: + bin_means: + claim: >- + The v2.0.0 bins, with edges 0.10/0.38/0.55/0.75/1.20, have mean + redshifts 0.293, 0.456, 0.609 and 0.916, calibrated on 9,917 EGS + spectra; after the BPZ range and gold, 54% of the sample's shear + weight is in a bin. + evidence: + - artifact: nz_summary + quote: { exact: "\"mean\": 0.2926222953762953" } + - artifact: nz_summary + quote: { exact: "\"mean\": 0.4564429777233325" } + - artifact: nz_summary + quote: { exact: "\"mean\": 0.6089238172100198" } + - artifact: nz_summary + quote: { exact: "\"mean\": 0.9155490145464295" } + - artifact: nz_summary + quote: { exact: "\"n_calibrators\": 9917" } + - artifact: nz_summary + quote: { exact: "\"gold\": 0.5441574244037846" } + bin_response_differs: + claim: >- + Bin 1's response (R₁₁ = 0.854) is 8.7% above the whole sample's + (0.786), and bin 4's (0.775) 1.3% below, so v2.0.0 applies each bin's + own response when the bin is measured. + evidence: + - artifact: bin_responses + quote: { exact: "0.8540098723066556" } + - artifact: bin_responses + quote: { exact: "0.7752978226636899" } + - artifact: bin_responses + quote: { exact: "0.7857610750514785" } diff --git a/analyses/shear_calibration/astra.yaml b/analyses/shear_calibration/astra.yaml new file mode 100644 index 000000000..04a8557ae --- /dev/null +++ b/analyses/shear_calibration/astra.yaml @@ -0,0 +1,374 @@ +# The shear-calibration section: the multiplicative shear bias m of the +# calibrated sample, measured on image simulations that twin a real UNIONS +# campaign, processed by ShapePipe and selected and weighted as the data are. +# +# options.yaml gives the concrete settings of each option the simulation +# code reads (sp_validation.image_sims.options); the recipes select one +# option per decision, and fixed settings with no live alternative are +# written into the commands. Commands name a fetched product by the path its +# manifest records. + +spec_version: "0.1.0" +label: Multiplicative shear bias from image simulations +description: >- + Twin image simulations of a real campaign: every CCD of every real exposure + keeps its WCS, zero point, weight and flag maps and its noise level, and + carries SKiLLS galaxies sheared by a known g, convolved with a PSF matched + to that CCD's v2 stars. Five shear branches (g = 0, ±g₁, ±g₂, |g| = 0.025) + share their noise and are each processed by ShapePipe's own workflow at the + code that made the v2 data, then selected, weighted with the data's weight + table and metacalibrated as the data are. m and c follow from the + calibrated mean shear of the ±g branches. The galaxies sit on a 10″ + lattice, so m measures the shape measurement and the selection without + blending. + +analyses: + sp: + path: ../.. + catalogue: + path: ../catalogue + +inputs: + options: + path: options.yaml + description: What each option of each simulation decision sets. + +outputs: + twin_field: + label: Staged real campaign + type: data + format: json + description: >- + The real campaign the simulation twins, staged from CADC by + sp_validation.image_sims.stage: tiles/CFIS.XXX.YYY.r.fits (WCS, size, + and HISTORY cards naming each tile's exposures) and + exposures/NNNNNNNp{,.weight,.flag}.fits.fz (CCD headers, weights, + flags, and the pixels the noise level is measured on). + decisions: [field] + recipe: + command: >- + python -m sp_validation.fetch '${{unions_data}}/image-sims/fields/{decisions.field}' + --version {decisions.field} --out {output} + resources: { cpus: 1, memory: 2GB, time_limit: 2h } + + skills: + label: SKiLLS input galaxies + type: data + format: json + description: >- + The SKiLLS v07Ds input galaxy catalogue (six feather files): Sérsic + index, effective radius, axis ratio and magnitudes, drawn at random + onto the layout's positions. + recipe: + command: >- + python -m sp_validation.fetch '${{unions_data}}/image-sims/skills' + --version v07Ds --out {output} + resources: { cpus: 1, memory: 2GB, time_limit: 1h } + + swarp: + label: SWarp 2.41.5 + type: data + format: json + description: >- + SWarp from conda-forge (astromatic-swarp 2.41.5), which coadds the + simulated exposures onto the real tiles' pixel grids as the real tiles + were made; the image lacks it. + recipe: + command: >- + python -m sp_validation.fetch '${{unions_data}}/image-sims/tools/swarp' + --version 2.41.5 --out {output} + resources: { cpus: 1, memory: 2GB, time_limit: 1h } + + truth: + label: Input galaxies + type: data + format: fits + description: >- + Every simulated galaxy: ID, RA, Dec, magnitude, flux, Sérsic n, size, + axis ratio, angle and intrinsic shear. + inputs: [options, twin_field, catalogue.star_catalogue, skills, swarp] + decisions: [field, galaxy_layout, magnitude_range, psf_model] + recipe: + command: >- + python -m sp_validation.image_sims.simulate truth + --options {inputs.options} + --select field={decisions.field} galaxy_layout={decisions.galaxy_layout} + magnitude_range={decisions.magnitude_range} psf_model={decisions.psf_model} + noise_model=gaussian_ccd_rms shear_amplitude=g0p025 generator=twin_c90c5b3 + shapepipe=v2_here selection=v2 simulation_weights=v2_table + --field "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.twin_field})" + --stars "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.catalogue.star_catalogue})"/dataset + --skills "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.skills})" + --swarp "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.swarp})"/bin/swarp + --output {output} + resources: { cpus: 1, memory: 16GB } + + catalogue_1z2z: + label: ShapePipe catalogue, no shear + type: data + format: hdf5 + description: >- + ShapePipe's merged catalogue of branch 1z2z (no shear): the generator draws + the branch's exposures and coadds its tiles in a temporary directory, + and `sp run --here` processes them; the images go with the directory. + inputs: [options, twin_field, catalogue.star_catalogue, skills, swarp] + decisions: [field, galaxy_layout, magnitude_range, psf_model] + recipe: + command: >- + python -m sp_validation.image_sims.simulate catalogue --branch 1z2z + --options {inputs.options} + --select field={decisions.field} galaxy_layout={decisions.galaxy_layout} + magnitude_range={decisions.magnitude_range} psf_model={decisions.psf_model} + noise_model=gaussian_ccd_rms shear_amplitude=g0p025 generator=twin_c90c5b3 + shapepipe=v2_here selection=v2 simulation_weights=v2_table + --field "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.twin_field})" + --stars "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.catalogue.star_catalogue})"/dataset + --skills "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.skills})" + --swarp "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.swarp})"/bin/swarp + --cores 48 --memory-mb 150000 --output {output} + resources: { cpus: 48, memory: 160GB } + + catalogue_1p2z: + label: ShapePipe catalogue, g₁ = +g + type: data + format: hdf5 + description: >- + ShapePipe's merged catalogue of branch 1p2z (g₁ = +g): the generator draws + the branch's exposures and coadds its tiles in a temporary directory, + and `sp run --here` processes them; the images go with the directory. + inputs: [options, twin_field, catalogue.star_catalogue, skills, swarp] + decisions: [field, galaxy_layout, magnitude_range, psf_model] + recipe: + command: >- + python -m sp_validation.image_sims.simulate catalogue --branch 1p2z + --options {inputs.options} + --select field={decisions.field} galaxy_layout={decisions.galaxy_layout} + magnitude_range={decisions.magnitude_range} psf_model={decisions.psf_model} + noise_model=gaussian_ccd_rms shear_amplitude=g0p025 generator=twin_c90c5b3 + shapepipe=v2_here selection=v2 simulation_weights=v2_table + --field "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.twin_field})" + --stars "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.catalogue.star_catalogue})"/dataset + --skills "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.skills})" + --swarp "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.swarp})"/bin/swarp + --cores 48 --memory-mb 150000 --output {output} + resources: { cpus: 48, memory: 160GB } + + catalogue_1m2z: + label: ShapePipe catalogue, g₁ = −g + type: data + format: hdf5 + description: >- + ShapePipe's merged catalogue of branch 1m2z (g₁ = −g): the generator draws + the branch's exposures and coadds its tiles in a temporary directory, + and `sp run --here` processes them; the images go with the directory. + inputs: [options, twin_field, catalogue.star_catalogue, skills, swarp] + decisions: [field, galaxy_layout, magnitude_range, psf_model] + recipe: + command: >- + python -m sp_validation.image_sims.simulate catalogue --branch 1m2z + --options {inputs.options} + --select field={decisions.field} galaxy_layout={decisions.galaxy_layout} + magnitude_range={decisions.magnitude_range} psf_model={decisions.psf_model} + noise_model=gaussian_ccd_rms shear_amplitude=g0p025 generator=twin_c90c5b3 + shapepipe=v2_here selection=v2 simulation_weights=v2_table + --field "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.twin_field})" + --stars "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.catalogue.star_catalogue})"/dataset + --skills "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.skills})" + --swarp "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.swarp})"/bin/swarp + --cores 48 --memory-mb 150000 --output {output} + resources: { cpus: 48, memory: 160GB } + + catalogue_1z2p: + label: ShapePipe catalogue, g₂ = +g + type: data + format: hdf5 + description: >- + ShapePipe's merged catalogue of branch 1z2p (g₂ = +g): the generator draws + the branch's exposures and coadds its tiles in a temporary directory, + and `sp run --here` processes them; the images go with the directory. + inputs: [options, twin_field, catalogue.star_catalogue, skills, swarp] + decisions: [field, galaxy_layout, magnitude_range, psf_model] + recipe: + command: >- + python -m sp_validation.image_sims.simulate catalogue --branch 1z2p + --options {inputs.options} + --select field={decisions.field} galaxy_layout={decisions.galaxy_layout} + magnitude_range={decisions.magnitude_range} psf_model={decisions.psf_model} + noise_model=gaussian_ccd_rms shear_amplitude=g0p025 generator=twin_c90c5b3 + shapepipe=v2_here selection=v2 simulation_weights=v2_table + --field "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.twin_field})" + --stars "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.catalogue.star_catalogue})"/dataset + --skills "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.skills})" + --swarp "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.swarp})"/bin/swarp + --cores 48 --memory-mb 150000 --output {output} + resources: { cpus: 48, memory: 160GB } + + catalogue_1z2m: + label: ShapePipe catalogue, g₂ = −g + type: data + format: hdf5 + description: >- + ShapePipe's merged catalogue of branch 1z2m (g₂ = −g): the generator draws + the branch's exposures and coadds its tiles in a temporary directory, + and `sp run --here` processes them; the images go with the directory. + inputs: [options, twin_field, catalogue.star_catalogue, skills, swarp] + decisions: [field, galaxy_layout, magnitude_range, psf_model] + recipe: + command: >- + python -m sp_validation.image_sims.simulate catalogue --branch 1z2m + --options {inputs.options} + --select field={decisions.field} galaxy_layout={decisions.galaxy_layout} + magnitude_range={decisions.magnitude_range} psf_model={decisions.psf_model} + noise_model=gaussian_ccd_rms shear_amplitude=g0p025 generator=twin_c90c5b3 + shapepipe=v2_here selection=v2 simulation_weights=v2_table + --field "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.twin_field})" + --stars "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.catalogue.star_catalogue})"/dataset + --skills "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.skills})" + --swarp "$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["path"])' {inputs.swarp})"/bin/swarp + --cores 48 --memory-mb 150000 --output {output} + resources: { cpus: 48, memory: 160GB } + + shear_bias: + label: Multiplicative and additive shear bias + type: data + format: yaml + description: >- + m₁, c₁, m₂, c₂ with their delete-one-tile jackknife covariance: each + branch selected with the sample's cuts, weighted with the data's table + and calibrated with its own response, and m = (ĝ⁺ − ĝ⁻)/(2 g_in) − 1 + per component. + inputs: + [catalogue_1z2z, catalogue_1p2z, catalogue_1m2z, catalogue_1z2p, + catalogue_1z2m, catalogue.weight_table, sp.selection_v2] + decisions: + [simulation_weight_table, simulation_shear_bias, + catalogue.selection_cuts, catalogue.response_estimator, + catalogue.galaxy_weights, catalogue.calibration_uncertainties] + recipe: + command: >- + python ../../scripts/compute_m_bias_image_sims.py -c m_bias_config.yaml -v + && cp results/m_bias_results.yaml {output} + resources: { cpus: 8, memory: 64GB, time_limit: 2h } + +decisions: + field: + label: Real campaign twinned + rationale: >- + The simulation takes its geometry, depth, masks and PSF from a real + campaign, so the field sets how representative m is of the survey. A + small field is a cheap end-to-end test; the survey interior, at typical + depth and away from the footprint's edge, is what m is quoted on. Edge + tiles of a small field are single-epoch and fail the N_EPOCH ≥ 2 cut. + options: + fir_b0269: + label: fir-b0269, 25 tiles + description: >- + The 25 tiles of the v2 Fir campaign fir-b0269 around 204.240 and + their 16 exposures, ten of them single-epoch edge tiles. + interior_253_246: + label: Survey interior around 253.246, 150 tiles + description: >- + The 150 v2 tiles nearest tile 253.246 and their 175 exposures, at + typical depth. + + galaxy_layout: + label: Galaxy positions + rationale: >- + A lattice of isolated galaxies measures the bias of the shape + measurement and the selection without blending; realistic positions + add blending and the detection of neighbours. + options: + lattice_10arcsec: + label: Square lattice, 10″ + description: On the tangent plane at the field centre, over the tiles' footprint. + skills_positions: + label: SKiLLS positions with stars + description: Blending and neighbour detection; not implemented. + + magnitude_range: + label: Input galaxy magnitudes + rationale: >- + The faint limit sets which undetected or barely detected galaxies are + drawn. r < 26.0 is about a magnitude below the sample's faint end, so + the selection's faint edge is populated; it leaves out the background + of fainter undetected galaxies. + options: + r18p5_26p0: + label: 18.5 < r < 26.0 + r18p5_27p5: + label: 18.5 < r < 27.5 + description: Adds the undetected faint background; not implemented. + + psf_model: + label: Simulated PSF + rationale: >- + ShapePipe is given the true PSF, so m measures the shape measurement + and the selection, not PSF modelling. The simulated PSF is matched per + CCD to the v2 stars' size and ellipticity and is constant over the CCD. + options: + moffat_ccd_stars: + label: Moffat matched to each CCD's stars + description: >- + Elliptical Moffat whose HSM T, g₁, g₂ equal the median of the CCD's + v2 stars; one β for the field from their median ρ₄. + psfex_stamps: + label: PSFEx model of the real exposures + description: Varies over the CCD; not implemented. + + simulation_weight_table: + label: Simulations weighted with the data's table + rationale: >- + The simulations take the data's selection and the data's weight table, + held fixed, so they are weighted as the data are. A table fitted on the + simulations' own shapes correlates the weights with the measured shapes + and suppresses the shear: for N galaxies per cell it gives m = −1/N + where an independent table gives 0. On the four SKiLLS v2 grids + (October 2026), a self-fitted table gives m = (−19.3 ± 4.0, + −14.3 ± 4.7) × 10⁻³, the data's table (−9.2 ± 3.2, −8.9 ± 3.6) × 10⁻³, + and a table fitted on the other three grids (−11.2 ± 3.3, + −8.1 ± 3.9) × 10⁻³. + options: + data_table: + label: The data's table, fixed + self_fitted: + label: Each simulation's own table + description: Biased by −1/N per cell. + other_grids_table: + label: A table fitted on independent simulations + description: Independent of the simulation it weights. + + simulation_shear_bias: + label: m from full populations, each with its own response + rationale: >- + For each component, the +g and −g simulations are each calibrated on + their full selected population with their own response and weights, + giving ĝ⁺ and ĝ⁻; this is the weighted mean applied to data, so m tests + the calibration the catalogue receives. Matching objects between the + ±g simulations with a symmetric pair weight cancels the change of the + weight that the response keeps and drops objects selected in only one: + on the SKiLLS grids it gives m = (−4, 0) × 10⁻³ where the full + populations give (−19.3 ± 4.0, −14.3 ± 4.7) × 10⁻³ with the same table. + options: + full_populations: + label: Each simulation on its full selection, own response + matched_pairs: + label: Matched ±g objects weighted ½(w₊ + w₋) + description: Cancels the weight response the data calibration keeps. + pair_mean_response: + label: Both simulations calibrated with the mean of their responses + description: Gives the same m to ≤ 1.4 × 10⁻³, within 1.2σ. + + multiplicative_bias_correction: + label: m measured, not applied + rationale: >- + Metacalibration calibrates the sample's shear from the data; the image + simulations test it. They leave a residual m of about −9 × 10⁻³ on the + SKiLLS grids, concentrated at low S/N, whose cause is not identified, + so no m is applied to the catalogue; how m enters the likelihood is the + inference section's prior. + options: + not_applied: + label: Not applied to the catalogue + divide_by_one_plus_m: + label: Shear divided by 1 + m + description: Applies the simulations' m to every galaxy. diff --git a/analyses/shear_calibration/options.yaml b/analyses/shear_calibration/options.yaml new file mode 100644 index 000000000..36f555da1 --- /dev/null +++ b/analyses/shear_calibration/options.yaml @@ -0,0 +1,40 @@ +# The concrete settings of each option of the decisions in astra.yaml, keyed +# decision -> option. sp_validation.image_sims.options merges the selected +# options' settings; an option astra.yaml lists and this file does not is not +# implemented. + +field: + fir_b0269: {seed: 1} + interior_253_246: {seed: 2} + +galaxy_layout: + lattice_10arcsec: {layout: grid, grid_spacing_arcsec: 10.0} + +magnitude_range: + r18p5_26p0: {mag_column: r_SDSS_apparent_corr, mag_range: [18.5, 26.0]} + +psf_model: + moffat_ccd_stars: {psf_stamp: 51} + +noise_model: + gaussian_ccd_rms: {} + +shear_amplitude: + g0p025: {shear: 0.025} + +generator: + twin_c90c5b3: + generator_repository: https://github.com/UNIONS-WL/MultiBand_ImSim.git + generator_commit: c90c5b3 + +shapepipe: + v2_here: + shapepipe_repository: https://github.com/CosmoStat/shapepipe.git + shapepipe_commit: 7f68451e6198089793ba2fc867e45d3c5c39bf18 + ngmix_chunks: 16 + +selection: + v2: {} + +simulation_weights: + v2_table: {} diff --git a/analyses/validation/astra.yaml b/analyses/validation/astra.yaml new file mode 100644 index 000000000..8a71e776a --- /dev/null +++ b/analyses/validation/astra.yaml @@ -0,0 +1,158 @@ +# The null tests and checks the data vector has to pass before inference: +# B-modes, the analytic covariance against the jackknife and the mocks, the +# additive bias, and the recovery of known inputs on the mocks. + +spec_version: "0.1.0" +label: Validation +description: >- + B-mode null tests of every bin pair and of all pairs jointly, in COSEBIs, + pure-mode ξ±^B, pseudo-Cℓ^BB and Cℓ^EB, by χ² against the analytic + covariance and against the mock ensemble; the check of the OneCovariance ξ± + covariance against the data's jackknife; the spatial variation of the + additive bias; and the recovery of the input signal, a zero B-mode and the + designed blind shift on the mocks. Nothing here reads an E-mode value. +tags: [null-tests, b-modes, validation] + +analyses: + sp: + path: ../.. + catalogue: + path: ../catalogue + redshifts: + path: ../redshifts + mocks: + path: ../mocks + covariance: + path: ../covariance + data_vectors: + path: ../data_vectors + +outputs: + bmode_ptes: + label: B-mode null tests + type: metric + format: json + description: >- + The PTE of χ² = bᵀC⁻¹b with the data vector's covariance, per bin pair + and jointly over all ten pairs with the full cross-pair covariance, + for COSEBIs B_n, pure-mode ξ+^B, ξ−^B and both combined at the + configuration-space scale cut, ξ±^B at 2–20 arcmin, and Cℓ^BB and + Cℓ^EB over the harmonic scale cut; and the number of per-pair PTEs + below the threshold against the number expected. v2.0.0's table is + report/summary.json of analyses/cosmo-val-v2-tomo-perbin, made by its + report script; cv_summarize_bmodes reads only the whole sample. + inputs: [data_vectors.data_vector] + decisions: [data_vectors.config_scale_cut, harmonic_scale_cut, pte_threshold, look_elsewhere] + recipe: + command: >- + python ../../workflow/scripts/cv_summarize_bmodes.py + --sacc {inputs.data_vectors.data_vector} --scale-cut 12 83 + --ell-range {decisions.harmonic_scale_cut} --tomo --out {output} + resources: { cpus: 1, memory: 8GB, time_limit: 20m } + + mock_calibrated_ptes: + label: Null tests against the mock ensemble + type: metric + format: json + description: >- + Each B-mode statistic of the data placed in the distribution of the + same statistic over the mock ensemble, which has no B-modes: the + fraction of mocks with a larger χ², and the analytic PTEs of the mocks + themselves, which should be uniform if the analytic covariance is + right. + inputs: [data_vectors.data_vector, mocks.mock_statistics, covariance.mock_covariance] + decisions: [data_vectors.config_scale_cut, harmonic_scale_cut] + recipe: + command: >- + python ../../workflow/scripts/mock_placement.py + --data {inputs.data_vectors.data_vector} + --mocks {inputs.mocks.mock_statistics} + --mock-cov {inputs.covariance.mock_covariance} --out {output} + resources: { cpus: 4, memory: 32GB, time_limit: 2h } + + jackknife_comparison: + label: OneCovariance against the jackknife + type: metric + format: json + description: >- + Per bin pair, the median ratio of the OneCovariance ξ± variance to the + 100-patch jackknife variance of the measured ξ±, below 10 arcmin and + inside the scale cut, and whether the small-scale median lies within + 15 % of one. On small scales the covariance is noise-dominated and + the jackknife is reliable, so this tests the shape-noise term. + inputs: [data_vectors.xi_reporting, covariance.xi_covariance] + recipe: + command: >- + python ../../workflow/scripts/covariance_check.py + --xi {inputs.data_vectors.xi_reporting} + --cov {inputs.covariance.xi_covariance} --out {output} + + additive_bias: + label: Additive bias and its variation + type: metric + format: json + description: >- + The weighted mean ellipticity c1, c2 of each bin after calibration, + which should vanish, and its scatter across patches of the footprint, + which the catalogue's single global c leaves in the shear. + inputs: [sp.cat_config, catalogue.calibrated_catalogue, redshifts.bin_responses] + recipe: + command: >- + python ../../workflow/scripts/cv_additive_bias.py --ver SP_v2.0.0 + --cat-config {inputs.sp.cat_config} --tomo --out {output} + resources: { cpus: 1, memory: 16GB, time_limit: 30m } + + mock_recovery: + label: Known answers on the mocks + type: metric + format: json + description: >- + On the mock ensemble: the mean EE pseudo-Cℓ and ξ± of each pair + against the input sky's spectra once the mock blind's designed shift + is removed, χ² per pair; the mean B-modes of every statistic against + zero at σ/√N; the blinded-minus-clean difference against the designed + shift, and the B response of the finite-grid E/B transforms to it. + inputs: [mocks.mock_statistics, mocks.skies, mocks.mock_blind, covariance.mock_covariance] + recipe: + command: >- + python ../../workflow/scripts/mock_cosebis_bias_test.py + --mocks {inputs.mocks.mock_statistics} --skies {inputs.mocks.skies} + --blind {inputs.mocks.mock_blind} --out {output} + resources: { cpus: 4, memory: 32GB, time_limit: 2h } + +decisions: + harmonic_scale_cut: + label: Multipole range of the Cℓ null tests + rationale: >- + Paper II's fiducial 300 < ℓ < 1600 excluded v1.4's low-ℓ outliers and + the excess power above ℓ ≈ 1600. v2.0.0's Cℓ^BB and Cℓ^EB PTEs use all + 32 bandpowers, 8 ≤ ℓ ≤ 2048 (320 points over ten pairs). + options: + ell_8_2048: + label: 8 ≤ ℓ ≤ 2048, every bandpower + ell_300_1600: + label: 300 < ℓ < 1600 + + pte_threshold: + label: PTE threshold + rationale: >- + A statistic fails when its PTE is below 0.05, the same threshold for + every statistic, with χ² = bᵀC⁻¹b and as many degrees of freedom as + data points. + options: + p0p05: + label: PTE < 0.05 fails + + look_elsewhere: + label: Many tests at once + rationale: >- + Seventy per-pair tests and seven joint ones are strongly correlated. + Paper II applied no correction and asked that the adopted cuts lie in + a broad region where every statistic passes. With ten pairs, v2.0.0 + reads the joint all-pair PTEs and compares the number of per-pair + failures with the number expected at the threshold. + options: + joint_and_count: + label: Joint all-pair PTEs, and per-pair failures against the expected count + stable_region: + label: No correction; the adopted cuts lie in a stable passing region diff --git a/astra.yaml b/astra.yaml new file mode 100644 index 000000000..b845d0598 --- /dev/null +++ b/astra.yaml @@ -0,0 +1,333 @@ +# sp_validation as an ASTRA 0.1 analysis: everything UNIONS weak lensing makes +# from ShapePipe's shear catalogue, from the calibrated sample to the blinded +# data vectors, their covariances, their validation and the inference. +# +# Sections are sub-analyses in analyses/
/, in the order the data +# flow. What is given to us is an output whose recipe fetches it and records +# what arrived (sp_validation.fetch); what we compute is an output; what we +# choose is a decision. Products used by several sections are fetched here, +# the rest in the section that reads them. +# +# Recipes run in their own analysis's folder and call the package +# (python -m sp_validation...) or the scripts the Snakemake workflow calls, +# so the two runners share code. The Snakemake workflow is unchanged. +# +# Validate with `uvx --prerelease allow astra-tools@0.3.0rc4 validate`. + +spec_version: "0.1.0" +label: UNIONS weak lensing from ShapePipe's catalogue +description: >- + The UNIONS cosmic-shear analysis downstream of shape measurement. ShapePipe + (CosmoStat/shapepipe, its own ASTRA analysis) makes the shear catalogue; + this analysis calibrates and selects the sample, bins it in redshift and + calibrates the n(z), builds the footprint and the GLASS digital twins of + the data, measures the PSF systematics, measures every two-point statistic + blinded, builds and validates their covariances, runs the null tests + calibrated on the mocks, and feeds the inference. Universe v2_0_0 holds the + choices that made the v2.0.0 release + (vos:cfis/weak_lensing/ShapePipe/v2.x/v2.0.0/) from ShapePipe's run 1. +tags: [unions, weak-lensing, cosmic-shear, sp_validation] + +inputs: + # Committed configs read by the sections (paths from the repository root). + # -- catalogue, shear_calibration, redshifts, footprint + assembly_v2: + path: config/assembly/v2.yaml + description: >- + The v2 HATS collection's recipe: the run-1 shape catalogue, PhotoPipe's + DR6 extract and spec-z match, and where the collection goes. + selection_v2: + path: config/calibration/mask_v2.0.yaml + description: >- + The v2 galaxy selection (column cuts, mask bits, N_EPOCH, magnitude, + ngmix flags) and the metacal block (S/N and size range, weight + scheme), read by the sample build. + nz_v2: + path: config/calibration/nz/v2.yaml + description: >- + The v2 n(z) recipe: sources, calibrators, SOM, bins, gold, grid and + ensemble, read by sp_validation.nz.pipeline. + # -- mocks, psf_systematics, data_vectors, covariance, validation, inference + cat_config: + path: cosmo_val/cat_config.yaml + description: >- + The catalogue config every cosmo_val measurement reads. Its SP_v2.0.0 + entry names the release's calibrated, star and PSF catalogues, the + footprints, the tomographic n(z), the blind, the columns and the + OneCovariance survey parameters (cov_th: area, n_eff, σ_e per bin). + cosmosis_pipeline: + path: cosmo_inference/cosmosis_config/templates/cosmosis_pipeline_A_psf.ini + description: >- + The CosmoSIS pipeline: CAMB with HMCode2020, NLA, Δz shifts, m bias, + the ξ_sys PSF term and the 2pt likelihood with its angular cuts. + cosmosis_values: + path: cosmo_inference/cosmosis_config/templates/values_psf.ini + description: The sampled parameters' ranges and starting values. + cosmosis_priors: + path: cosmo_inference/cosmosis_config/templates/priors_psf.ini + description: The Gaussian priors on the nuisance parameters and ω_b. + +analyses: + shapepipe: + url: https://github.com/CosmoStat/shapepipe.git + commit: fa6a53dc9444d3b8d8d16c796ec8e327df19523f + catalogue: + path: analyses/catalogue + shear_calibration: + path: analyses/shear_calibration + redshifts: + path: analyses/redshifts + footprint: + path: analyses/footprint + mocks: + path: analyses/mocks + psf_systematics: + path: analyses/psf_systematics + data_vectors: + path: analyses/data_vectors + covariance: + path: analyses/covariance + validation: + path: analyses/validation + inference: + path: analyses/inference + +outputs: + shapepipe_run1: + label: ShapePipe run 1, snapshot 3 + type: data + format: json + description: >- + ShapePipe's run-1 products on all 22,901 DR6 tiles, merged across its + 969 campaigns: the shear catalogue final_cat_latest.hdf5 (772,677,301 + objects), the star catalogue full_starcat_latest.hdf5, the coverage + maps (nexp, nflagged, npoint, ntaken) and MANIFEST.json. It is + ShapePipe's universe baseline_run1 as it ran (declared above as + shapepipe, imported into universes as baseline_run1), made by Snakemake + on Nibi and Fir in October 2026, so the release data are fetched rather + than read through an lc record. The result is the manifest of what + arrived: where it is, and every file's size and SHA-256. + recipe: + command: >- + python -m sp_validation.fetch '${{unions_data}}/v2.x/run1-snap3' + --version run1-snap3 --out {output} + resources: { cpus: 1, memory: 4GB, time_limit: 4h } + + photopipe_dr6: + label: PhotoPipe DR6 photometry and photo-z + type: data + format: json + description: >- + PhotoPipe's DR6 catalogue (Hendrik Hildebrandt's group, + hendrik1008/PhotoPipeUNIONS, CANFAR branch): GAaP u g r i z z2 + photometry and BPZ photo-z of every DR6 tile, joined to ShapePipe's + objects on (TILE_ID, NUMBER), with its match table and build record. + The catalogue section joins it to the shapes and the redshifts + section bins and calibrates from its colours. + recipe: + command: >- + python -m sp_validation.fetch '${{unions_data}}/photopipe-dr6-extract' + --version dr6 --out {output} + resources: { cpus: 1, memory: 4GB, time_limit: 2h } + + photopipe_specz: + label: PhotoPipe DR6 spec-z matches + type: data + format: json + description: >- + PhotoPipe's match of DR6 objects to spectroscopic redshifts over every + tile, UNIONS_DR6_ugriz_specz.cat, and the per-tile redshift compilation + of 19 Oct 2026 it used (asc/). The calibration sample of the SOM n(z) + and the spec-z extension of the HATS collection. + recipe: + command: >- + python -m sp_validation.fetch '${{unions_data}}/photopipe-dr6-specz-all' + --version 2026-10-19 --out {output} + resources: { cpus: 1, memory: 2GB, time_limit: 1h } + + blind: + label: The UNIONS blind + type: data + format: json + description: >- + The blind every cosmological statistic is shifted by as it is + measured, t(hidden) − t(fiducial) (sp_validation.blinding). Nobody + opens it: the manifest holds its path and hash, and the recipes that + measure signal pass the path to sp_validation, which conceals what it + writes. + recipe: + command: >- + python -m sp_validation.fetch '${{unions_v2}}/v2.0.0/blind/unions.blind.json' + --version v2.0.0 --md5sums '${{unions_v2}}/v2.0.0/MD5SUMS' --out {output} + +decisions: + fiducial_cosmology: + label: Fiducial cosmology + rationale: >- + The cosmology at which the blind is centred, the GLASS mocks are drawn, + the analytic covariances are evaluated and the PSF-leakage and B-mode + tests are interpreted. results/cosmology/planck18.json, made from + cs_util.cosmo.PLANCK18, is what the workflow reads. + options: + planck18: + label: Planck 2018 ΛCDM + description: astropy's Planck18 parameters (TT,TE,EE+lowE+lensing+BAO). + insights: [planck18_cosmology] + + blinding: + label: Blinding + rationale: >- + v2 cosmic shear is blind. Every cosmological statistic is shifted by + t(hidden) − t(fiducial) before it is written, so no unblinded E-mode + statistic exists on disk; B-modes, covariances and n(z) are not + shifted. Unblinding is a collaboration decision, not an analysis + choice, so it is not an option here. + options: + theory_shift: + label: Shift by a hidden cosmology at measurement + description: >- + sp_validation.blinding.conceal adds t(hidden) − t(fiducial) to + every ξ±, Cℓ_EE and statistic derived from them as it is saved. + unblinded: + label: Unblinded + excluded: The analysis is blind until the collaboration unblinds it. + +prior_insights: + planck18_cosmology: + claim: >- + The Planck 2018 results give the ΛCDM parameters used as the fiducial + cosmology. + evidence: + - doi: "10.48550/arXiv.1807.06209" + quote: + exact: "We present cosmological parameter results from the final full-mission Planck measurements of the cosmic microwave background" + +findings: + # Claims about v2.0.0, pinned to the root universe that made it. + # -- catalogue, shear_calibration, redshifts, footprint + # -- mocks, psf_systematics, data_vectors, covariance, validation, inference + bmode_joint_ptes: + claim: >- + Every joint B-mode null test of v2.0.0, over all ten bin pairs with the + full cross-pair covariance, passes: PTE 0.84 for COSEBIs, 0.26 for + pseudo-Cℓ^BB, 0.14 for Cℓ^EB, 0.45 for pure-mode ξ+^B, 0.15 for ξ−^B, + 0.20 for both, and 0.71 for ξ±^B at 2–20 arcmin. + evidence: + - artifact: validation.bmode_ptes#v2_0_0 + quote: { exact: "0.8401519895938314" } + - artifact: validation.bmode_ptes#v2_0_0 + quote: { exact: "0.25724936314554675" } + - artifact: validation.bmode_ptes#v2_0_0 + quote: { exact: "0.1376981103184307" } + - artifact: validation.bmode_ptes#v2_0_0 + quote: { exact: "0.4508334598492315" } + - artifact: validation.bmode_ptes#v2_0_0 + quote: { exact: "0.15155861935448933" } + - artifact: validation.bmode_ptes#v2_0_0 + quote: { exact: "0.19880867196194899" } + - artifact: validation.bmode_ptes#v2_0_0 + quote: { exact: "0.7096449253453415" } + + bmode_pair_failures: + claim: >- + Three of the 70 per-pair B-mode PTEs of v2.0.0 fall below 0.05, against + 3.5 expected by chance: ξ−^B (0.045) and both ξ±^B combined (0.021) of + bins 1×3, and ξ+^B of bins 1×4 (0.031). + evidence: + - artifact: validation.bmode_ptes#v2_0_0 + quote: { exact: "\"xim_B\": 0.04457311145664132" } + - artifact: validation.bmode_ptes#v2_0_0 + quote: { exact: "\"combined\": 0.02081724210714618" } + - artifact: validation.bmode_ptes#v2_0_0 + quote: { exact: "\"xip_B\": 0.030772179374044716" } + + leakage_alpha: + claim: >- + The PSF leakage α of the four v2.0.0 bins is 0.044, 0.025, 0.012 and + 0.051, each with an error of 0.011–0.013, and the α, β, η model fits + τ poorly in bin 3 (PTE 0.0025) and in bin 1 (PTE 0.021). + evidence: + - artifact: psf_systematics.leakage_fit#v2_0_0 + quote: { exact: "\"alpha\": 0.04434460490244715" } + - artifact: psf_systematics.leakage_fit#v2_0_0 + quote: { exact: "\"alpha\": 0.025199337526039454" } + - artifact: psf_systematics.leakage_fit#v2_0_0 + quote: { exact: "\"alpha\": 0.012235017786358961" } + - artifact: psf_systematics.leakage_fit#v2_0_0 + quote: { exact: "\"alpha\": 0.051489340289596716" } + - artifact: psf_systematics.leakage_fit#v2_0_0 + quote: { exact: "\"pte\": 0.0025183236218070336" } + - artifact: psf_systematics.leakage_fit#v2_0_0 + quote: { exact: "\"pte\": 0.021297311557925382" } + + onecov_matches_jackknife: + claim: >- + The OneCovariance ξ± variances of v2.0.0 agree with the data's + 100-patch jackknife: the median ratio over every bin pair, ξ+ and ξ−, + and θ is 0.994 below 10 arcmin and 1.011 within 12–83 arcmin. + evidence: + - artifact: validation.jackknife_comparison#v2_0_0 + quote: { exact: "\"median_small\": 0.9942354258799797" } + - artifact: validation.jackknife_comparison#v2_0_0 + quote: { exact: "\"median_cut\": 1.0111948400140864" } + +universes: + baseline_run1: + analysis: shapepipe + universe: baseline_run1 + v2_0_0: + label: v2.0.0 as made + description: >- + The choices that made the v2.0.0 release from ShapePipe's run 1 + (run1-snap3, ShapePipe universe baseline_run1): the calibrated sample, + its four tomographic bins and n(z), the footprints and the blinded + tomographic data vector SP_v2.0_tomo.sacc with its covariance. + decisions: + fiducial_cosmology: planck18 + blinding: theory_shift + # The image-sim m, the mock ensemble and the inference did not make + # v2.0.0, so this universe sets none of their decisions. + # -- catalogue, shear_calibration, redshifts, footprint + catalogue.overlap_cut: snapshot_tiles + catalogue.selection_cuts: bound_9_bit_16_ignored + catalogue.catalogue_match_tile_selection: no_cut + catalogue.sample_wide_calibration: one_for_the_sample + catalogue.galaxy_weights: des_table_on_every_branch + catalogue.weight_table: pooled_min_3 + catalogue.response_estimator: separate_normalisation + catalogue.additive_bias: global_mean + catalogue.calibration_uncertainties: tile_jackknife + catalogue.leakage_correction: uncorrected + redshifts.source_photometry_join: object_id + redshifts.tomographic_bins: equal_weight_quartiles + redshifts.calibrator_set: deep2_deep3_egs + redshifts.photometry_as_delivered: as_delivered + redshifts.z2_offset: offset_z2 + redshifts.som_map: calibrator_trained_101 + redshifts.gold_selection: floor_0_4_nmad_5 + redshifts.grid_step: step_0_05 + redshifts.ensemble_terms: statistical_and_systematic + redshifts.sample_calibration: per_sample_at_measurement + footprint.footprint_definition: occupied_nside_4096 + footprint.tomographic_footprint: binned_tiles + # -- mocks, psf_systematics, data_vectors, covariance, validation, inference + psf_systematics.tau_covariance: th + psf_systematics.leakage_fit_method: lsq + data_vectors.xi_reporting_grid: log20_1_250 + data_vectors.xi_jackknife_patches: npatch_100 + data_vectors.integration_grid: log1000_0p08_300 + data_vectors.config_scale_cut: arcmin_12_83 + data_vectors.cosebis_modes: n20 + data_vectors.pure_eb_method: schneider22 + data_vectors.cl_estimator: catalog + data_vectors.cl_binning: powspace + data_vectors.noise_bias: analytic + covariance.reporting_terms: full + covariance.integration_terms: gaussian + covariance.shape_noise: pair_counts + covariance.survey_mask: masked + covariance.covariance_power_spectrum: hmcode2020_feedback + covariance.cl_covariance_method: inka + validation.harmonic_scale_cut: ell_8_2048 + validation.pte_threshold: p0p05 + validation.look_elsewhere: joint_and_count diff --git a/config/calibration/mask_v2.0.yaml b/config/calibration/mask_v2.0.yaml index 89789be53..777340cba 100644 --- a/config/calibration/mask_v2.0.yaml +++ b/config/calibration/mask_v2.0.yaml @@ -97,7 +97,7 @@ dat: # catalogue. # Number of epochs - # @sc [decision:dr6_catalogue.catalogue_match_tile_selection] + # @sc [decision:catalogue.catalogue_match_tile_selection] - col_name: N_EPOCH label: r"$n_{\rm epoch}$" kind: greater_equal diff --git a/config/calibration/nz/v2.yaml b/config/calibration/nz/v2.yaml index cb90483f6..4c175f76e 100644 --- a/config/calibration/nz/v2.yaml +++ b/config/calibration/nz/v2.yaml @@ -1,7 +1,7 @@ name: v2_DR6_BPZ_SOM_EGS_tomo limitation: EGS-only calibration (DEEP2/3) for validation and null tests; no independent-field variance or spectroscopic-selection model. inputs: - # @sc [decision:nz.calibrator_set] + # @sc [decision:redshifts.calibrator_set] calibrators: # The spectra the collection's spec-z extension matches to PhotoPipe's # objects (by its own sky match), selected by survey and by the @@ -12,35 +12,35 @@ inputs: surveys: [deep2_final, deep3_final] field: {ra: [213.0, 217.0], dec: [51.5, 54.0]} # EGS z_min: 0.002 # stars - # @sc [decision:nz.source_photometry_join] + # @sc [decision:redshifts.source_photometry_join] sources: # The released calibrated shear catalogue; each row's photometry comes # from the v2 collection (shapes with their PhotoPipe extension) by its # DR6 object ID. catalogue: ${unions_v2}/v2.0.0/catalogs/calibrated photometry: ${unions_v2}/run1-snap3-collection -# @sc [decision:nz.som_map] +# @sc [decision:redshifts.som_map] som: side: 101 epochs: 60 seed: 42 groups: 2000 -# @sc [decision:nz.tomographic_bins] +# @sc [decision:redshifts.tomographic_bins] # Tomographic bins: equal shear weight in DR6 BPZ, computed by each run from # its sources with complete photometry and BPZ in range, before gold # (summary.json records the edges). The README says why. bins: {count: 4, range: [0.10, 1.20]} -# @sc [decision:nz.gold_selection] +# @sc [decision:redshifts.gold_selection] gold_qc: floor: 0.4 nmad_factor: 5 -# @sc [decision:nz.z2_offset] +# @sc [decision:redshifts.z2_offset] # Canonical z takes precedence over z2. z2_offset: -0.1104888916015625 -# @sc [decision:nz.grid_step] +# @sc [decision:redshifts.grid_step] # The step is the delivered n(z) resolution; the README says why 0.05. grid: {min: 0, max: 5, step: 0.05} -# @sc [decision:nz.ensemble_terms] +# @sc [decision:redshifts.ensemble_terms] # n(z) realisations (sp_validation.nz.ensemble). Each key switches a term on; # the README says why each size. ensemble: @@ -50,7 +50,7 @@ ensemble: density: # line-of-sight density through the DEEP2/3 strip field: [2.0, 0.25] # degrees bias: 1.3 - # @sc [decision:nz.photometry_as_delivered] + # @sc [decision:redshifts.photometry_as_delivered] zero_points: # EGS against the wide field, mag # u-g g-r r-i i-z: stellar-locus offsets of 3.4 deg² patches, noise removed colour_sigma: [0.0215, 0.0194, 0.0119, 0.0208] diff --git a/docs/catalogue-match-selection.md b/docs/catalogue-match-selection.md index ffe21719d..a5a1ea6e9 100644 --- a/docs/catalogue-match-selection.md +++ b/docs/catalogue-match-selection.md @@ -1,7 +1,7 @@ # Catalogue-match tile selection -Decision `dr6_catalogue.catalogue_match_tile_selection` keeps the external paired fraction diagnostic-only and applies no tile cut. -Its rationale, alternatives with their measured costs, and `Values` pins live in the [ASTRA record](../scratch/cdaley/unions_astra/analyses/dr6_catalogue/astra.yaml); this page holds the audit coverage and tile-level evidence behind it. +Decision `catalogue.catalogue_match_tile_selection` keeps the external paired fraction diagnostic-only and applies no tile cut. +Its rationale, alternatives with their measured costs, and `Values` pins live in the [ASTRA record](../analyses/catalogue/astra.yaml); this page holds the audit coverage and tile-level evidence behind it. The optional audit records published match counts, warnings and catalogue row counts without removing objects. Missing metadata remains distinct from a measured empty external catalogue. diff --git a/scratch/cdaley/unions_astra/analyses/bmodes/astra.yaml b/scratch/cdaley/unions_astra/analyses/bmodes/astra.yaml deleted file mode 100644 index 46d56493f..000000000 --- a/scratch/cdaley/unions_astra/analyses/bmodes/astra.yaml +++ /dev/null @@ -1,514 +0,0 @@ -version: "0.0.10" -name: "Paper II — B-mode validation (Daley et al.)" -tags: [unions, b-modes, null-tests] - -authors: - - "Cail Daley" - -narrative: - summary: | - B-mode validation for UNIONS-3500 cosmic shear using three E/B-separable - statistics — pure-mode correlation functions ξ±^B(θ), COSEBI B-mode - amplitudes B_n, and harmonic-space C_ℓ^BB. The goal is a null test: after - [fiducial scale cuts](#decisions.scale_cuts_config), all three statistics - pass with [minimum PTE = 0.18](#findings.min_pte_combined), and only the - [size-cut fiducial catalogue](#../decisions.catalog_version) passes - everything. This is a validation paper — its inference data products are - the B-mode data vectors and their covariances feeding the PTE table. - findings: | - All three statistics pass at fiducial cuts ([min PTE 0.18](#findings.min_pte_combined)); - fiducial PTEs are [COSEBI n≤6 = 0.78](#findings.pte_fid_cosebi6), - [n≤20 = 0.94](#findings.pte_fid_cosebi20), [ξ+^B = 0.31](#findings.pte_fid_xip), - [ξ−^B = 0.26](#findings.pte_fid_xim), [ξ_tot^B = 0.18](#findings.pte_fid_xitot), - [C_ℓ^BB = 0.30](#findings.pte_fid_cl). Over the full angular range COSEBI - n=1 shows a [>4σ excess](#findings.cosebi_n1_excess) (full-range PTE - [1.37e-05](#findings.pte_full_cosebi6)) traced to the [MegaCam CCD scale](#findings.ccd_scale). - Robustness: a [look-elsewhere sensitivity test](#findings.look_elsewhere_sensitivity) - still passes (0.09), the [leakage correction shifts PTEs by ≲0.05](#findings.leak_corr_shift), - the [Hartlap correction is ≤2%](#findings.hartlap_correction), and the - [COSEBI GLASS bias is <0.3σ](#findings.cosebi_glass_bias). - methods: | - Three statistics ([statistics](#decisions.statistics)) on a single source - bin: [pure-mode ξ±^B](#decisions.pure_eb_method) on a [1000-bin grid](#decisions.pure_eb_grid), - [COSEBIs](#decisions.cosebi_nmodes) (config-space and a [96-bin harmonic - transform](#decisions.cosebi_harmonic_bins)), and [catalogue-based C_ℓ](#decisions.cl_estimator) - in [32 bandpowers](#decisions.cl_binning). Covariances are propagated from - the CosmoCov ξ± covariance ([Monte-Carlo for pure-mode](#decisions.cov_method_pureeb), - [analytic transform for COSEBIs](#decisions.cov_cosebi)), kept - [Gaussian-only](#decisions.gaussian_only_cov). [Config-space](#decisions.scale_cuts_config) - and [harmonic-space scale cuts](#decisions.scale_cuts_harmonic) plus a - [uniform PTE threshold 0.05](#decisions.pte_threshold) define pass/fail; a - [look-elsewhere treatment](#decisions.look_elsewhere) requires stable - regions, and the pipeline is validated on [GLASS mocks](#decisions.mock_validation). - inputs: | - Consumes the shared [shear_catalog](#inputs.shear_catalog), [nz](#inputs.nz), - and [glass_mocks](#inputs.glass_mocks), and the parent CosmoCov config-space - [xi_covariance](#inputs.xi_covariance). - outputs: | - B-mode [data vectors](#outputs.bmode_data_vectors), their - [covariances](#outputs.bmode_covariances), and the [PTE table](#outputs.pte_table). - -inputs: - - id: shear_catalog - from: ../shear_catalog - - id: nz - from: ../nz - - id: glass_mocks - from: ../glass_mocks - - id: xi_covariance - type: data - label: "Finely-binned CosmoCov ξ±(θ) covariance" - source: "/n17data/UNIONS/WL/cosmocov/" - description: >- - CosmoCov covariance of ξ±(θ) on a 1000-bin logarithmic grid spanning - θ = 0.5–300 arcmin, Gaussian-only, under the Planck 2018 fiducial - cosmology and the UNIONS survey properties. Shared with Paper III's - config-space covariance; here it is the seed for all B-mode covariances - (MC propagation for pure-mode; linear transform for COSEBIs). - -decisions: - catalog_version: - from: ../catalog_version - shear_calibration: - from: ../shear_calibration - leakage_correction: - from: ../leakage_correction - fiducial_cosmology: - from: ../fiducial_cosmology - blinding: - from: ../blinding - - statistics: - label: "E/B-separable statistic" - tags: [stats] - rationale: >- - Three independent E/B-separable statistics cross-check the B-mode null: - pure-mode correlation functions, COSEBIs, and harmonic-space power - spectra. A signal seen in all three is robust. - default: all_three - options: - pure_eb: - label: "Pure-mode ξ±^B(θ)" - cosebis: - label: "COSEBI B-mode amplitudes B_n" - cl_bb: - label: "Harmonic C_ℓ^BB" - all_three: - label: "All three (fiducial)" - insights: [pure_eb_method_ref] - - pure_eb_method: - label: "Pure-mode decomposition method" - tags: [stats] - rationale: >- - Decompose ξ±(θ) into pure E, pure B, and ambiguous components following - Schneider et al. 2022, computing pure-mode CFs directly from the finely - binned ξ± rather than reconstructing from COSEBI coefficients. - default: schneider22_direct - options: - schneider22_direct: - label: "Schneider+22, direct from binned ξ±" - insights: [pure_eb_method_ref] - schneider22_from_cosebi: - label: "Schneider+22, reconstructed from COSEBIs" - description: "Alternative path via COSEBI coefficients; not used." - - pure_eb_grid: - label: "Integral-transform grid for pure modes" - tags: [numerics] - rationale: >- - The S± / V± boundary functions are evaluated on a separate 1000-bin - logarithmic grid over θ = 0.5–300 arcmin; the extended range reduces - edge effects. A 10000-bin grid confirms convergence. - default: log_1000_0p5_300 - options: - log_1000_0p5_300: - label: "1000 log bins, 0.5–300 arcmin (fiducial)" - log_10000_0p5_300: - label: "10000 log bins (convergence check)" - - cosebi_nmodes: - label: "COSEBI mode set" - tags: [stats] - rationale: >- - The E-mode signal saturates by n ≈ 5–6, so n ≤ 6 carries most - cosmological information; B-mode PTEs are also reported for n ≤ 20 over - the θ = 1–250 arcmin angular range. - default: n_le_6 - options: - n_le_6: - label: "n ≤ 6 (fiducial information content)" - n_le_20: - label: "n ≤ 20 (full mode set)" - - cosebi_harmonic_bins: - label: "COSEBI harmonic-transform bandpower binning" - tags: [numerics] - rationale: >- - The harmonic-space COSEBI path uses 96 sqrt-spaced bandpower bins, - balancing resolution against deconvolution. Validated on GLASS mocks so - that n ≤ 6 agree between the config-space and harmonic paths (paper - states agreement; no quantitative tolerance is quoted). - default: sqrt_96 - options: - sqrt_96: - label: "96 sqrt-spaced bandpowers (fiducial)" - - cl_estimator: - label: "C_ℓ estimator" - tags: [stats] - rationale: >- - Catalogue-based pseudo-Cℓ estimator (Wolz et al. 2025): the mask is - represented as delta functions at source positions and spin-2 transforms - computed on the irregular grid via ducc, avoiding pixelisation artifacts. - Analytic shot-noise subtraction; MASTER deconvolution via NaMaster. - default: catalog_based_wolz25 - options: - catalog_based_wolz25: - label: "Catalogue-based (Wolz+25)" - insights: [catalog_cl_ref] - - cl_binning: - label: "C_ℓ bandpower binning" - tags: [numerics] - rationale: "32 bandpowers, square-root (ℓ^0.5) spacing over 8 ≤ ℓ ≤ 2048." - default: sqrt_32_8_2048 - options: - sqrt_32_8_2048: - label: "32 sqrt-spaced bandpowers, 8–2048 (fiducial)" - - cov_method_pureeb: - label: "Pure-mode covariance method" - tags: [stats] - rationale: >- - No closed form for the pure-mode covariance, so draw N_samples = 2000 - realisations of ξ±(θ) from the finely binned CosmoCov covariance, - propagate each through the integral transforms, and apply the Hartlap - correction to the inverse — at most a 2% correction for N_obs ≤ 40. - default: mc_2000_hartlap - options: - mc_2000_hartlap: - label: "Monte-Carlo (N=2000) + Hartlap" - - cov_cosebi: - label: "COSEBI covariance method" - tags: [stats] - rationale: >- - For COSEBIs the covariance follows analytically from the linear - transform C_{B_n B_m} = Tᵀ C_ξ T, where T encodes the COSEBI filters. - default: analytic_transform - options: - analytic_transform: - label: "Analytic linear transform of C_ξ" - - gaussian_only_cov: - label: "Gaussian-only covariance for null tests" - tags: [stats] - rationale: >- - For all B-mode null tests, retain only the Gaussian part of the - covariance; omitting connected trispectrum and super-sample terms - underestimates the variance, so the reported PTEs are conservative. - default: gaussian_only - options: - gaussian_only: - label: "Gaussian-only (conservative)" - full: - label: "Full (Gaussian + cNG + SSC)" - description: "Not used for null tests." - - scale_cuts_config: - label: "Configuration-space scale cuts" - tags: [scale-cuts] - rationale: >- - Fiducial 12–83 arcmin (full range 1–250 arcmin). The lower cut excludes - most intra-CCD pair separations (MegaCam's 40 CCDs span 6–14 arcmin), - where B-mode contamination concentrates. COSEBIs use the same unified - range. - default: arcmin_12_83 - options: - arcmin_12_83: - label: "12–83 arcmin (fiducial)" - arcmin_1_250: - label: "1–250 arcmin (full range)" - - scale_cuts_harmonic: - label: "Harmonic-space scale cuts" - tags: [scale-cuts] - rationale: >- - Fiducial 300 < ℓ < 1600 (full range 8 ≤ ℓ ≤ 2048). Excludes low-ℓ - outliers (~125, 250) and elevated power above ℓ ≈ 1600. - default: ell_300_1600 - options: - ell_300_1600: - label: "300 < ℓ < 1600 (fiducial)" - ell_8_2048: - label: "8 ≤ ℓ ≤ 2048 (full range)" - - pte_threshold: - label: "PTE pass/fail threshold" - tags: [stats] - rationale: >- - Uniform threshold PTE = 0.05 for all tests, with χ²_B = d_Bᵀ C_BB⁻¹ d_B - and ν = number of data points. - default: uniform_0p05 - options: - uniform_0p05: - label: "Uniform PTE = 0.05" - - look_elsewhere: - label: "Look-elsewhere treatment" - tags: [stats] - rationale: >- - No explicit look-elsewhere correction across scale-cut combinations - (tests strongly correlated within and across statistics); instead require - adopted cuts to lie in broad stable regions passing all three frameworks. - A sensitivity test lowers the minimum PTE from 0.18 to 0.09, still above - threshold. - default: no_correction_stable_region - options: - no_correction_stable_region: - label: "No correction; require stable region" - - mock_validation: - label: "Pipeline validation on GLASS mocks" - tags: [validation] - rationale: >- - Validate on 350 GLASS lognormal mocks matching footprint, positions, - weights, and Planck 2018 cosmology (no PSF systematics). All three - statistics recover B-modes consistent with zero; COSEBI mean B_n biased - by < 0.3σ per mode over 100 realisations. - default: glass_350 - options: - glass_350: - label: "350 GLASS mocks" - insights: [glass_mocks_ref] - -prior_insights: - pure_eb_method_ref: - id: pure_eb_method_ref - label: "Pure-mode CFs (Schneider+22)" - claim: >- - Pure E/B-mode correlation functions cleanly separate E and B modes for - cosmic shear, demonstrated on KiDS-1000. - created_at: "2026-06-13T00:00:00" - derived: false - evidence: - - id: e1 - doi: "10.1051/0004-6361/202142479" - quote: - exact: "Pure-mode correlation functions for cosmic shear and application to KiDS-1000" - - catalog_cl_ref: - id: catalog_cl_ref - label: "Catalogue-based pseudo-Cℓ (Wolz+25)" - claim: >- - A catalogue-based pseudo-Cℓ estimator represents the mask as delta - functions at source positions, avoiding pixelisation bias. - created_at: "2026-06-13T00:00:00" - derived: false - evidence: - - id: e1 - doi: "10.1088/1475-7516/2025/01/028" - quote: - exact: "Catalog-based pseudo-Cls" - - glass_mocks_ref: - id: glass_mocks_ref - label: "GLASS mocks (Tessore+23)" - claim: >- - GLASS generates lognormal large-scale-structure realisations suitable for - weak-lensing pipeline and covariance validation. - created_at: "2026-06-13T00:00:00" - derived: false - evidence: - - id: e1 - doi: "10.21105/astro.2302.01942" - quote: - exact: "GLASS: Generator for Large Scale Structure" - -outputs: - - id: bmode_data_vectors - type: data - label: "B-mode data vectors (ξ±^B, B_n, C_ℓ^BB)" - inputs: [shear_catalog, nz] - decisions: [catalog_version, leakage_correction, statistics, pure_eb_method, - pure_eb_grid, cosebi_nmodes, cosebi_harmonic_bins, cl_estimator, - cl_binning, blinding] - recipe: - command: >- - python -m sp_validation.bmodes.measure - --catalog {inputs.shear_catalog} --nz {inputs.nz} - --catalog-version {decisions.catalog_version} - --leakage {decisions.leakage_correction} - --statistic {decisions.statistics} - --pure-eb-method {decisions.pure_eb_method} - --pure-eb-grid {decisions.pure_eb_grid} - --cosebi-nmodes {decisions.cosebi_nmodes} - --cosebi-harmonic-bins {decisions.cosebi_harmonic_bins} - --cl-estimator {decisions.cl_estimator} - --cl-binning {decisions.cl_binning} - --blind {decisions.blinding} - --out {output} - - - id: bmode_covariances - type: data - label: "B-mode covariances (Gaussian-only)" - inputs: [xi_covariance, glass_mocks] - decisions: [cov_method_pureeb, cov_cosebi, gaussian_only_cov, cosebi_nmodes, - cl_binning, fiducial_cosmology] - recipe: - command: >- - python -m sp_validation.bmodes.covariance - --xi-cov {inputs.xi_covariance} --mocks {inputs.glass_mocks} - --pure-eb-cov {decisions.cov_method_pureeb} - --cosebi-cov {decisions.cov_cosebi} - --cov-scope {decisions.gaussian_only_cov} - --cosebi-nmodes {decisions.cosebi_nmodes} - --cl-binning {decisions.cl_binning} - --cosmology {decisions.fiducial_cosmology} - --out {output} - - - id: pte_table - type: table - label: "B-mode PTE table (per statistic × catalogue × scale cut)" - inputs: [bmode_data_vectors, bmode_covariances] - decisions: [scale_cuts_config, scale_cuts_harmonic, pte_threshold, - look_elsewhere, mock_validation] - recipe: - command: >- - python -m sp_validation.bmodes.pte - --data {inputs.bmode_data_vectors} --cov {inputs.bmode_covariances} - --config-cuts {decisions.scale_cuts_config} - --harmonic-cuts {decisions.scale_cuts_harmonic} - --threshold {decisions.pte_threshold} - --look-elsewhere {decisions.look_elsewhere} - --validation {decisions.mock_validation} - --out {output} - -findings: - min_pte_combined: - id: min_pte_combined - claim: "After fiducial cuts, all three statistics pass; minimum PTE = 0.18 (ξ_tot^B joint)." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: pte_table - quote: { exact: "minimum PTE $= \\configPteSixThreeCombined$" } - - pte_fid_cosebi6: - id: pte_fid_cosebi6 - claim: "Fiducial COSEBI n≤6 PTE = 0.78." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: pte_table - - pte_fid_cosebi20: - id: pte_fid_cosebi20 - claim: "Fiducial COSEBI n≤20 PTE = 0.94." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: pte_table - - pte_fid_xip: - id: pte_fid_xip - claim: "Fiducial ξ+^B PTE = 0.31." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: pte_table - - pte_fid_xim: - id: pte_fid_xim - claim: "Fiducial ξ−^B PTE = 0.26." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: pte_table - - pte_fid_xitot: - id: pte_fid_xitot - claim: "Fiducial ξ_tot^B (joint) PTE = 0.18." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: pte_table - - pte_fid_cl: - id: pte_fid_cl - claim: "Fiducial C_ℓ^BB PTE = 0.30 (300 < ℓ < 1600)." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: pte_table - - pte_full_cosebi6: - id: pte_full_cosebi6 - claim: "Full-range COSEBI n≤6 PTE = 1.37e-05 (fails)." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: pte_table - - cosebi_n1_excess: - id: cosebi_n1_excess - claim: "On the full range, COSEBI n=1 shows a >4σ excess with oscillatory structure through 20 modes; scale cuts suppress it below 1σ." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: bmode_data_vectors - - look_elsewhere_sensitivity: - id: look_elsewhere_sensitivity - claim: "A look-elsewhere sensitivity test lowers the minimum PTE across all statistics from 0.18 to 0.09, still above 0.05." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: pte_table - - leak_corr_shift: - id: leak_corr_shift - claim: "The object-wise PSF-leakage correction shifts individual PTEs by ≲ 0.05 across all catalogue versions and statistics; no pass/fail conclusion changes." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: pte_table - - hartlap_correction: - id: hartlap_correction - claim: "For N_samples = 2000 and N_obs ≤ 40, the Hartlap correction to the inverse covariance is at most 2%." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: bmode_covariances - - cosebi_glass_bias: - id: cosebi_glass_bias - claim: "On GLASS mocks the mean COSEBI B_n is biased by less than 0.3σ per mode (100 realisations)." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: bmode_data_vectors - - ccd_scale: - id: ccd_scale - claim: "MegaCam's 40 CCDs span 6–14 arcmin; UNIONS dithers by ~1/3 of the FoV (~19 arcmin); observed B-mode contamination concentrates at θ ≲ 12 arcmin." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: bmode_data_vectors diff --git a/scratch/cdaley/unions_astra/analyses/cosmic_shear_2d/astra.yaml b/scratch/cdaley/unions_astra/analyses/cosmic_shear_2d/astra.yaml deleted file mode 100644 index 5c40621d4..000000000 --- a/scratch/cdaley/unions_astra/analyses/cosmic_shear_2d/astra.yaml +++ /dev/null @@ -1,468 +0,0 @@ -version: "0.0.10" -name: "Paper III — configuration-space cosmic shear (Goh et al.)" -tags: [unions, cosmic-shear, config-space, inference] - -authors: - - "Cail Daley" - -narrative: - summary: | - 2D (single-bin) configuration-space cosmic shear for UNIONS-3500: the - two-point correlation functions ξ±(θ) measured with [TreeCorr](#decisions.statistic), - fit jointly with the τ-statistics PSF systematics, to infer S₈. The - headline result is [S₈ = 0.831⁺⁰·⁰⁶⁷₋₀.₀₇₈](#findings.s8_fid). The project - stops at the inference data products: the ξ± data vector, the - [CosmoCov covariance](#decisions.covariance_method), and the cosmological - constraints (no chain modelling beyond the constraint outputs). - findings: | - Fiducial [S₈ = 0.831⁺⁰·⁰⁶⁷₋₀.₀₇₈](#findings.s8_fid), - [Ω_m = 0.265⁺⁰·¹³⁰₋₀.₀₇₅](#findings.om_fid), - [σ₈ = 0.782⁺⁰·²⁰⁶₋₀.₁₄₄](#findings.sigma8_fid). The fit has - [χ² = 75.33 / 54](#findings.chi2_total) (PTE driven low by the τ statistics). - Adding [Planck](#findings.s8_planck) gives 0.855, and [Planck+BAO](#findings.s8_planck_bao) - 0.849. The result is [0.6σ below the harmonic-space](#findings.s8_harmonic_consistency) - Paper IV value. Per-statistic, [ξ± alone fits well (PTE 0.39)](#findings.pte_xipm) - while the [τ statistics drive the low total (PTE 5.9e-3)](#findings.pte_tau). - The [fiducial B-mode PTEs are internally inconsistent in the source](#findings.bmode_pte_fiducial) - (prose vs table). The fiducial cuts drive the [n_eff change](#findings.neff_change), - and the [direct IA measurement](#findings.ia_amplitude) sets the A_IA prior. - methods: | - A single-bin ξ±(θ) 2PCF ([statistic](#decisions.statistic)) on a 20-bin - log θ grid, [scale cut 12–83 arcmin](#decisions.scale_cuts), jointly fit - with τ₀,₂ over the full range — 54 data points. Covariance from - [CosmoCov, masked](#decisions.covariance_method). Modelling: - [HMCode2020 non-linear power](#decisions.nl_model), [NLA intrinsic - alignment](#decisions.ia_model) with a doubled-width A_IA prior, - [PSF α/β leakage at inference](#decisions.psf_leakage), - [Δz](#decisions.dz_prior) and [m-bias](#decisions.mbias) nuisances, - [KiDS-Legacy priors on the sampled parameters](#decisions.sampled_params_prior), - [Polychord sampling](#decisions.sampler), and a [2D-marginalised-mode point - estimate](#decisions.bestfit_stat). Pipeline validated on - [341 GLASS mocks](#decisions.pipeline_validation); analysis [blinded](#decisions.blinding). - inputs: | - Consumes the shared [shear_catalog](#inputs.shear_catalog), [nz](#inputs.nz), - [glass_mocks](#inputs.glass_mocks), plus [tau_stats](#inputs.tau_stats), - external [Planck plik_lite](#inputs.external_cmb) and [DESI DR2 BAO](#inputs.external_bao). - outputs: | - The [xi_data_vector](#outputs.xi_data_vector), the - [covariance](#outputs.covariance), and the - [cosmo_constraints](#outputs.cosmo_constraints). - -inputs: - - id: shear_catalog - from: ../shear_catalog - - id: nz - from: ../nz - - id: glass_mocks - from: ../glass_mocks - - id: tau_stats - type: data - label: "τ₀,₂(θ) PSF systematics statistics + covariance" - source: "/n17data/UNIONS/WL/tau/" - description: >- - τ₀,+(θ) and τ₂,+(θ) PSF systematics statistics (only the '+' term), - with semi-analytical covariance C_τ (Guerrini et al. 2025). Jointly fit - with ξ± to marginalise PSF leakage; ξ-τ cross-covariance neglected. - - id: external_cmb - type: data - label: "Planck 2018 plik_lite CMB likelihood" - source: "external/planck_plik_lite/" - description: >- - Planck 2018 TT (2 ≤ ℓ ≤ 2508), TE/EE (2 ≤ ℓ ≤ 1996) via plik_lite, - marginalised over A_lens; no lensing power spectrum. Used only for the - external-combination constraints. - - id: external_bao - type: data - label: "DESI DR2 BAO" - source: "external/desi_dr2_bao/" - description: >- - DESI DR2 transverse/comoving BAO distances (D_M, D_H) over 0.1 < z < 3 - across BGS, LRG, ELG, QSO, Lyα. ΛCDM only. - -decisions: - catalog_version: - from: ../catalog_version - shear_calibration: - from: ../shear_calibration - leakage_correction: - from: ../leakage_correction - fiducial_cosmology: - from: ../fiducial_cosmology - blinding: - from: ../blinding - - statistic: - label: "Two-point statistic" - tags: [stats] - rationale: >- - 2D cosmic shear with a single tomographic bin using the ξ±(θ) 2PCF; the - r-band-only sample lacks the colour information needed for tomography. - default: xi_pm_2pcf - options: - xi_pm_2pcf: - label: "ξ±(θ) two-point correlation function (single bin)" - - scale_cuts: - label: "ξ± scale cuts" - tags: [scale-cuts] - rationale: >- - Fiducial θ ∈ [12,83] arcmin for both ξ±; τ statistics fit over the full - range. 54 data points total (7 each ξ±, 20 each τ₀,₂). [5,83] and [12,83] - pass the COSEBI B-mode null test; [9,83] does not. - default: arcmin_12_83 - options: - arcmin_12_83: - label: "12–83 arcmin (fiducial)" - arcmin_5_83: - label: "5–83 arcmin (small-scale extension)" - description: "Passes B-mode null; gives higher S₈ = 0.886 and worse fit (χ²_red 1.34)." - arcmin_9_83: - label: "9–83 arcmin" - description: "Fails COSEBI B-mode null test." - - covariance_method: - label: "Covariance matrix (CosmoCov, masked vs unmasked)" - tags: [stats] - rationale: >- - CosmoCov covariance of ξ± with the OneCovariance Table 1 input cosmology. - Masked is fiducial; unmasked presented to quantify the impact. ξ-τ - cross-correlation neglected. - default: cosmocov_masked - options: - cosmocov_masked: - label: "CosmoCov masked (fiducial)" - insights: [cosmocov_ref] - cosmocov_unmasked: - label: "CosmoCov unmasked" - description: "S₈ = 0.822⁺⁰·⁰⁷²₋₀.₀₇₀." - - nl_model: - label: "Non-linear power-spectrum model" - tags: [physics] - rationale: >- - HMCode2020 (halo model + baryonic feedback), ~2.5% accurate for - k ≤ 10 h/Mpc. Halofit and HMCode-no-baryons run as robustness checks. - default: hmcode2020 - options: - hmcode2020: - label: "HMCode2020 (baryons, fiducial)" - halofit: - label: "Halofit" - description: "S₈ = 0.800⁺⁰·⁰⁶⁸₋₀.₀₇₄." - hmcode_no_baryons: - label: "HMCode2020, no baryons" - description: "S₈ = 0.813⁺⁰·⁰⁷²₋₀.₀₆₈." - - ia_model: - label: "Intrinsic-alignment model and A_IA prior" - tags: [physics] - rationale: >- - NLA model. A direct red+blue IA measurement gives A_IA = 0.83 ± 0.39; - the prior width is doubled to ±0.78 for conservatism. TATT higher-order - terms ignored. - default: nla_gauss_0p78 - options: - nla_gauss_0p78: - label: "NLA, A_IA ~ N(0.83, 0.78) (fiducial)" - nla_flat: - label: "NLA, flat A_IA prior" - description: "S₈ = 0.895⁺⁰·¹⁷²₋₀.₁₃₃, A_IA = 2.61." - no_ia: - label: "No IA (A_IA = 0)" - description: "S₈ = 0.770⁺⁰·⁰²⁹₋₀.₀₅₉; largest shift (−0.71σ)." - - psf_leakage: - label: "PSF-leakage modelling at inference" - tags: [calibration] - rationale: >- - Sample PSF systematics parameters α, β at inference (η = 0 fixed), with - Gaussian priors fiducially (flat as a check). - default: gauss_alpha_beta - options: - gauss_alpha_beta: - label: "Gaussian α/β priors (fiducial)" - flat_alpha_beta: - label: "Flat α/β priors" - description: "S₈ = 0.825⁺⁰·⁰⁷¹₋₀.₀₇₅." - no_xi_sys: - label: "No ξ^sys term" - description: "S₈ = 0.824⁺⁰·⁰⁶³₋₀.₀₆₈." - - dz_prior: - label: "Redshift-shift Δz prior" - tags: [calibration] - rationale: >- - Δz = −0.003 with total uncertainty ±0.018. A bug in the Δz estimation - was found post-unblinding and the analysis rerun. - default: gauss_dz - options: - gauss_dz: - label: "Δz ~ N(−0.003, 0.018) (fiducial)" - flat_dz: - label: "Flat Δz prior" - description: "Δz = −0.045⁺⁰·⁰⁷⁷₋₀.₀₃₆; ~3× larger error bars." - - mbias: - label: "Multiplicative shear bias m" - tags: [calibration] - rationale: >- - Cumulative m = −0.057 ± 0.0047 from image sims; uncertainty conservatively - tripled to m = −0.057 ± 0.014. - default: gauss_m - options: - gauss_m: - label: "m ~ N(−0.057, 0.014) (fiducial)" - no_m: - label: "No m bias" - description: "S₈ = 0.809⁺⁰·⁰⁵⁰₋₀.₀₇₉." - - sampled_params_prior: - label: "Sampled cosmological parameters and priors" - tags: [stats] - rationale: >- - Sample {ω_c, ω_b, H0, n_s, S8} with KiDS-Legacy (Table 2) prior ranges. - BBN prior on ω_b for the WL-only run; with CMB, drop BBN and sample - τ_reio. τ_reio fixed at 0.0544 otherwise; Σm_ν = 0.06 eV. - default: kids_legacy_priors - options: - kids_legacy_priors: - label: "KiDS-Legacy Table-2 priors (fiducial)" - - sampler: - label: "Nested sampler" - tags: [stats] - rationale: "Polychord baseline; Nautilus as a consistency check." - default: polychord - options: - polychord: - label: "Polychord (baseline)" - nautilus: - label: "Nautilus" - description: "S₈ = 0.826⁺⁰·⁰⁶⁸₋₀.₀₆₉." - - bestfit_stat: - label: "Point-estimate statistic" - tags: [stats] - rationale: >- - Report the 2D marginalised mode for S₈ and Ω_m (most sensitive to - projection effects); 1D marginalised mode (MAP) for others; also quote a - getdist-KDE-smoothed weighted mean of S₈. - default: marg_mode_2d - options: - marg_mode_2d: - label: "2D marginalised mode (S₈, Ω_m); 1D MAP others" - - pipeline_validation: - label: "Pipeline validation on GLASS mocks" - tags: [validation] - rationale: >- - Validate on 341 GLASS mocks with the data mask, n_eff, σ_e, and a Planck - 2018 fiducial cosmology, drawing one blinded n(z) at random. Mean S₈ - differs by < 0.5σ between mock and data analyses; effective dof = 51.9. - default: glass_341 - options: - glass_341: - label: "341 GLASS mocks" - insights: [glass_mocks_ref] - -prior_insights: - cosmocov_ref: - id: cosmocov_ref - label: "CosmoCov (OneCovariance fiducial)" - claim: >- - OneCovariance / CosmoCov provides the semi-analytical covariance for - cosmic-shear two-point functions; Table 1 specifies the fiducial input - cosmology. - created_at: "2026-06-13T00:00:00" - derived: false - evidence: - - id: e1 - doi: "10.1051/0004-6361/202452592" - quote: - exact: "OneCovariance" - - glass_mocks_ref: - id: glass_mocks_ref - label: "GLASS mocks (Tessore+23)" - claim: >- - GLASS generates lognormal large-scale-structure realisations used to - validate the inference pipeline. - created_at: "2026-06-13T00:00:00" - derived: false - evidence: - - id: e1 - doi: "10.21105/astro.2302.01942" - quote: - exact: "GLASS: Generator for Large Scale Structure" - -outputs: - - id: xi_data_vector - type: data - label: "ξ±(θ) + τ₀,₂ data vector (54 points)" - inputs: [shear_catalog, nz, tau_stats] - decisions: [catalog_version, leakage_correction, statistic, scale_cuts, blinding] - recipe: - command: >- - python -m sp_validation.cosmo_inference.measure_xi - --catalog {inputs.shear_catalog} --nz {inputs.nz} --tau {inputs.tau_stats} - --catalog-version {decisions.catalog_version} - --leakage {decisions.leakage_correction} - --statistic {decisions.statistic} - --scale-cuts {decisions.scale_cuts} - --blind {decisions.blinding} - --out {output} - - - id: covariance - type: data - label: "ξ± covariance (CosmoCov)" - inputs: [nz] - decisions: [covariance_method, fiducial_cosmology] - recipe: - command: >- - python -m sp_validation.cosmo_inference.covariance - --nz {inputs.nz} - --covariance {decisions.covariance_method} - --cosmology {decisions.fiducial_cosmology} - --out {output} - - - id: cosmo_constraints - type: table - label: "Cosmological constraints (S₈, Ω_m, σ₈; ± external data)" - inputs: [xi_data_vector, covariance, nz, glass_mocks, external_cmb, external_bao] - decisions: [nl_model, ia_model, psf_leakage, dz_prior, mbias, - sampled_params_prior, sampler, bestfit_stat, pipeline_validation] - recipe: - command: >- - python -m sp_validation.cosmo_inference.infer - --data {inputs.xi_data_vector} --cov {inputs.covariance} --nz {inputs.nz} - --mocks {inputs.glass_mocks} - --cmb {inputs.external_cmb} --bao {inputs.external_bao} - --nl-model {decisions.nl_model} - --ia-model {decisions.ia_model} - --psf-leakage {decisions.psf_leakage} - --dz-prior {decisions.dz_prior} - --m-bias {decisions.mbias} - --params {decisions.sampled_params_prior} - --sampler {decisions.sampler} - --point-estimate {decisions.bestfit_stat} - --validation {decisions.pipeline_validation} - --out {output} - -findings: - s8_fid: - id: s8_fid - claim: "Fiducial S₈ = 0.831⁺⁰·⁰⁶⁷₋₀.₀₇₈ (2D marginalised mode 0.829)." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - quote: { exact: "0.831^{+0.067}_{-0.078}" } - - om_fid: - id: om_fid - claim: "Fiducial Ω_m = 0.265⁺⁰·¹³⁰₋₀.₀₇₅." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - sigma8_fid: - id: sigma8_fid - claim: "Fiducial σ₈ = 0.782⁺⁰·²⁰⁶₋₀.₁₄₄." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - chi2_total: - id: chi2_total - claim: >- - Fiducial fit χ² = 75.33 (effective dof 51.9); PTE driven low by the τ₀,₂ - fit. Prose quotes PTE 0.0147; results table quotes total PTE 0.0291 for - 75.33/54 — an internal prose-vs-table discrepancy. - created_at: "2026-06-13T00:00:00" - derived: true - notes: "Source carries two inconsistent total-PTE values; quote with caveat." - evidence: - - id: e1 - artifact: cosmo_constraints - - pte_xipm: - id: pte_xipm - claim: "ξ± alone fits well: PTE = 0.39 (χ² 9.50/14; ξ+ 0.745, ξ− 0.627)." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - pte_tau: - id: pte_tau - claim: "τ₀,₂ fit PTE = 5.9e-3 (χ² 65.77/40); drives the low total PTE." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - s8_harmonic_consistency: - id: s8_harmonic_consistency - claim: "Config-space S₈ is ~0.6σ lower than the harmonic-space (Paper IV) value, assuming independent errors." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - s8_planck: - id: s8_planck - claim: "UNIONS-3500 + Planck CMB gives S₈ = 0.855⁺⁰·⁰²⁰₋₀.₀₁₇ (+0.33σ vs WL-only)." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - s8_planck_bao: - id: s8_planck_bao - claim: "UNIONS-3500 + Planck CMB + DESI DR2 BAO gives S₈ = 0.849⁺⁰·⁰¹⁵₋₀.₀₁₇." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - bmode_pte_fiducial: - id: bmode_pte_fiducial - claim: >- - Fiducial (v1.4.6) B-mode PTEs are internally inconsistent in the source: - prose macros give COSEBIs n≤6 = 0.78 / ξ_tot = 0.18; the results table - gives COSEBIs n≤6 = 0.80 / ξ_tot = 0.57. Directional conclusion (fiducial - cut passes) holds under both. - created_at: "2026-06-13T00:00:00" - derived: true - notes: "Prose-vs-table discrepancy; quote with caveat." - evidence: - - id: e1 - artifact: cosmo_constraints - - neff_change: - id: neff_change - claim: "The fiducial cuts remove ~25% of galaxies, reducing n_eff from 6.48 to 4.96 arcmin⁻² and σ_e from 0.28 to 0.27." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: xi_data_vector - - ia_amplitude: - id: ia_amplitude - claim: "Direct IA measurement gives A_IA,r = 2.75 ± 0.49 (red), A_IA,b = 0.21 ± 0.37 (blue); combined with f_r=0.245, f_b=0.745 gives the A_IA = 0.83 ± 0.39 prior." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints diff --git a/scratch/cdaley/unions_astra/analyses/dr6_catalogue/astra.yaml b/scratch/cdaley/unions_astra/analyses/dr6_catalogue/astra.yaml deleted file mode 100644 index 2cef6e13c..000000000 --- a/scratch/cdaley/unions_astra/analyses/dr6_catalogue/astra.yaml +++ /dev/null @@ -1,120 +0,0 @@ -version: "0.0.10" -name: "DR6 shear-catalogue selection (ShapePipe v2)" -tags: [unions, weak-lensing, shear-catalogue, data-selection] - -authors: - - "Cail Daley" - -narrative: - summary: | - Selection of the DR6 ShapePipe v2 shear catalogue by - `config/calibration/mask_v2.0.yaml` and the calibration scripts. Papers - II–IV consume the v1.4.6.3 catalogue, so nothing here reaches their data - vectors; this sub-analysis holds the choices that select the DR6 - catalogue itself. - methods: | - The optional [catalogue-match audit](#outputs.catalogue_match_audit) - tabulates ShapePipe's published external-catalogue join counts per tile. - The [paired-fraction tile selection](#decisions.catalogue_match_tile_selection) - keeps that fraction diagnostic-only. - inputs: | - The [v2_catalogue](#inputs.v2_catalogue) and its published - [tile_manifests](#inputs.tile_manifests). - outputs: | - The [catalogue_match_audit](#outputs.catalogue_match_audit) table and the - [selected_catalogue](#outputs.selected_catalogue). - -inputs: - - id: v2_catalogue - type: data - label: "ShapePipe v2 comprehensive catalogue (DR6)" - source: "unions_shapepipe_comprehensive_2025_v2.0.hdf5" - description: >- - The comprehensive ShapePipe v2 catalogue named by mask_v2.0.yaml's - input_path, before galaxy selection and metacalibration. - - id: tile_manifests - type: data - label: "Published ShapePipe tile manifests" - source: "tile_make_cat.json (one per published tile)" - description: >- - Per-tile manifests; those written by ShapePipe with external-catalogue - matching carry a catalogue_match block of join counts, the external - paired fraction and the warning budget. - -decisions: - catalogue_match_tile_selection: - label: "External paired-fraction tile selection" - tags: [data-selection] - rationale: >- - No tile is removed on its external_paired_fraction; the audit reports - the fraction and ShapePipe's warnings without rejecting objects. - [HARDCODED] MIN_EXTERNAL_PAIRED_FRACTION is a module constant with no - config key. On 22,683 of the 22,901 run-1 tiles of the v2.0.0 release, - measured against its mask_v2.0.yaml selection (191,016,178 galaxies), - all 18 tiles below 0.98 pairing, including one empty tile, yield zero - selected galaxies, so a 0.98 cut would remove nothing; the lowest-pairing - tile that selects galaxies is at 0.981. The other 218 tiles (0.72% of - the selected galaxies) have no external count on Fir and are - unmeasured. The zero yield depends on the N_EPOCH >= 2 cut: of the - tiles below 0.98 only 207.238 retains objects past it (three - detections, lost at the fit cut), and a one-epoch selection would admit - a different population needing a new assessment. Stricter thresholds - remove galaxies with no measured improvement, and with no selected - galaxies below 0.98 there is no shear to test there, so the audit does - not establish that future low-pairing tiles are safe. Reassess if - N_EPOCH is relaxed, if any tile below 0.98 contributes a selected - galaxy (audit the selected catalogue's TILE_ID against nonzero - catalogue_rows), or on a coherent quality anomaly. Coverage and the - tile-level evidence are in docs/catalogue-match-selection.md. - Values: MIN_EXTERNAL_PAIRED_FRACTION = None; mask_v2.0.yaml#N_EPOCH = 2. - default: no_cut - options: - no_cut: - label: "No paired-fraction cut" - description: "The paired fraction is a diagnostic; no tile is removed on it." - cut_below_0_98: - label: "Reject tiles below 0.98" - description: >- - Removes the 18 measured tiles below 0.98, which contribute zero - selected galaxies under N_EPOCH >= 2: no change to the sample. - cut_below_0_99: - label: "Reject tiles below 0.99" - description: >- - Removes 198 tiles and 675,307 selected galaxies (0.354% of the - sample, 0.367% of its shear weight). - cut_below_0_995: - label: "Reject tiles below 0.995" - description: >- - Removes 3,072 tiles and 20,855,054 selected galaxies (10.92% of the - sample, 11.16% of its shear weight). - reject_warning_tiles: - label: "Reject tiles with a ShapePipe match warning" - description: >- - Warnings budget join discrepancies, not catalogue quality; the two - published warning tiles (058.220, 207.238) are sparse coverage edges - contributing zero selected galaxies. - mask_unmatched_positions: - label: "Mask positions of unmatched external objects" - description: >- - Unmatched external objects carry no shapes; their absence alone does - not justify masking retained neighbours. - -outputs: - - id: catalogue_match_audit - type: table - label: "Per-tile catalogue-match audit" - inputs: [v2_catalogue, tile_manifests] - decisions: [catalogue_match_tile_selection] - description: >- - catalogue_match_audit.csv from scripts/calibration/extract_info.py when - catalogue_match_manifests is set: per-tile catalogue rows, join counts - and warnings, distinguishing a missing manifest, missing match metadata - and a measured empty external catalogue. - - id: selected_catalogue - type: data - label: "Selected, metacalibrated DR6 shear catalogue" - inputs: [v2_catalogue] - decisions: [catalogue_match_tile_selection] - description: >- - Output of scripts/calibration/calibrate_comprehensive_cat.py under - mask_v2.0.yaml, including its N_EPOCH >= 2 cut. diff --git a/scratch/cdaley/unions_astra/analyses/harmonic/astra.yaml b/scratch/cdaley/unions_astra/analyses/harmonic/astra.yaml deleted file mode 100644 index 22cc481bf..000000000 --- a/scratch/cdaley/unions_astra/analyses/harmonic/astra.yaml +++ /dev/null @@ -1,518 +0,0 @@ -version: "0.0.10" -name: "Paper IV — harmonic-space cosmic shear (Guerrini et al.)" -tags: [unions, cosmic-shear, harmonic, inference] - -authors: - - "Cail Daley" - -narrative: - summary: | - Harmonic-space (pseudo-Cℓ) 2D cosmic shear for UNIONS-3500: the shear power - spectrum measured with a [catalogue-based pseudo-Cℓ estimator](#decisions.estimator) - and used to infer S₈. The headline is [S₈ = 0.891⁺⁰·⁰⁵⁷₋₀.₀₈₄](#findings.s8) — - higher than, but consistent with, the [config-space Paper III value](#findings.config_consistency_indep). - The project stops at the inference data products: the Cℓ data vector, the - iNKA+OneCovariance covariance, and the cosmological constraints. - findings: | - Fiducial [S₈ = 0.891⁺⁰·⁰⁵⁷₋₀.₀₈₄](#findings.s8), - [Ω_m = 0.225⁺⁰·¹⁵³₋₀.₀₇₇](#findings.omega_m), - [σ₈ = 0.960⁺⁰·²²³₋₀.₂₅₇](#findings.sigma8); good fit - ([χ² = 8.1, PTE 0.76](#findings.gof_chi2) vs GLASS). Consistent with - [Planck at 0.79σ](#findings.planck_consistency) and with the - [config-space value at 0.60σ](#findings.config_consistency_indep) (independent - errors) — but [2.18σ](#findings.config_consistency_corr) once the shared - sample correlation is included, and with [other WL surveys at 0.87–1.51σ](#findings.wl_consistency). - B-mode nulls: [EB PTE 0.95](#findings.eb_pte) and [BB PTE 0.132](#findings.bb_pte) - (iNKA, all scales), rising under [scale cuts](#findings.bb_pte_cuts) and - tightening under a [10000-Gaussian-sim covariance](#findings.bb_pte_gauss_sims). - The [iNKA-vs-OneCovariance covariance differs by ~20–25%](#findings.covariance_diff). - methods: | - Pseudo-Cℓ ([estimator](#decisions.estimator), [catalogue-based](#decisions.cell_method)) - in [32 sqrt-spaced bandpowers](#decisions.binning), [scale cut 300 < ℓ < 1600](#decisions.scalecut) - via a [k-contribution criterion](#decisions.scalecut_method). Covariance is - [iNKA Gaussian + OneCovariance non-Gaussian](#decisions.covariance_method) - with an [analytic noise-bias term](#decisions.noise_bias). Modelling: - [HMCode2020](#decisions.nl_model) with a [marginalised T_AGN baryon - parameter](#decisions.baryon), [NLA IA](#decisions.ia_model) with a - [Gaussian A_IA prior](#decisions.ia_prior), [Δz](#decisions.dz_prior) and - [m-bias](#decisions.m_prior) nuisances, [leakage-corrected ellipticities](#decisions.leakage), - [Polychord sampling](#decisions.sampler), and a [MAP-via-KDE point - estimate](#decisions.point_estimate). Analysis [blinded](#decisions.blinding). - inputs: | - Consumes the shared [shear_catalog](#inputs.shear_catalog), [nz](#inputs.nz), - [glass_mocks](#inputs.glass_mocks), and external [Planck 2018](#inputs.external_planck). - outputs: | - The [cl_data_vector](#outputs.cl_data_vector), the - [covariance](#outputs.covariance), and the - [cosmo_constraints](#outputs.cosmo_constraints). - -inputs: - - id: shear_catalog - from: ../shear_catalog - - id: nz - from: ../nz - - id: glass_mocks - from: ../glass_mocks - - id: external_planck - type: data - label: "Planck 2018 (external comparison)" - source: "external/planck2018/" - description: >- - Planck 2018 cosmology — both the fiducial cosmology used to generate the - covariance and the external S₈ comparison (0.79σ consistency). - -decisions: - catalog_version: - from: ../catalog_version - shear_calibration: - from: ../shear_calibration - leakage_correction: - from: ../leakage_correction - fiducial_cosmology: - from: ../fiducial_cosmology - blinding: - from: ../blinding - - estimator: - label: "Power-spectrum estimator" - tags: [stats] - rationale: >- - Pseudo-Cℓ formalism (MASTER) via NaMaster for the shear power spectrum; - the configuration-space companion is Paper III's ξ±. - default: pseudo_cl_namaster - options: - pseudo_cl_namaster: - label: "Pseudo-Cℓ (NaMaster)" - - cell_method: - label: "Field/map construction" - tags: [numerics] - rationale: >- - Catalogue-based estimator (Wolz et al. 2025) rather than pixelised maps: - avoids pixel-window / aliasing bias at small scales and Poisson-noise - instabilities in low-density mask regions. - default: catalog_based_wolz25 - options: - catalog_based_wolz25: - label: "Catalogue-based (Wolz+25, fiducial)" - insights: [catalog_cl_ref] - pixelised_map: - label: "Pixelised HealPix map (DES/HSC-style)" - description: "Alternative; susceptible to pixel-window and Poisson bias." - - binning: - label: "Bandpower binning" - tags: [numerics] - rationale: >- - Equal-weight binning with 32 square-root-spaced bins over ℓ ∈ [8, 2048], - following the DES Doux et al. 2022 strategy. - default: sqrt_32_8_2048 - options: - sqrt_32_8_2048: - label: "32 sqrt-spaced bins, 8–2048 (fiducial)" - - scalecut: - label: "Multipole scale cut" - tags: [scale-cuts] - rationale: >- - Conservative ℓ ∈ [300, 1600] (k_max ≈ 2.6 h/Mpc), removing the largest - and smallest scales where a B-mode signal is present. - default: ell_300_1600 - options: - ell_300_1600: - label: "300 < ℓ < 1600 (fiducial)" - ell_full: - label: "Full range (8 ≤ ℓ ≤ 2048)" - - scalecut_method: - label: "Scale-cut derivation (k-contribution)" - tags: [scale-cuts] - rationale: >- - α = 0.95 (k above k_{>α}(ℓ) contributes at most 5% of the signal), - following Doux et al. 2021; tested k_max ∈ {1,3,5} h/Mpc (k_max = 3 maps - to ℓ_max = 1800). - default: alpha_0p95 - options: - alpha_0p95: - label: "α = 0.95 k-contribution (fiducial)" - - covariance_method: - label: "Covariance method (iNKA + OneCovariance)" - tags: [stats] - rationale: >- - Gaussian term from NaMaster iNKA; non-Gaussian (connected four-point + - super-sample) from OneCovariance. The iNKA and OneCovariance estimates - differ by ~25% (largely from number-density variation); OneCovariance - shifts S₈ by +0.02σ. Validated against 350 GLASS mocks. - default: inka_plus_onecov - options: - inka_plus_onecov: - label: "iNKA Gaussian + OneCovariance non-Gaussian (fiducial)" - insights: [cosmocov_ref] - onecov_only: - label: "OneCovariance only" - description: "S₈ shifts by +0.02σ." - glass_cov: - label: "GLASS-derived covariance" - description: "Validation variant." - - noise_bias: - label: "Noise-bias subtraction" - tags: [numerics] - rationale: >- - Analytic binned noise pseudo-power spectrum (Nicola et al. 2021), - Ñ_L = Ω_pix ⟨Σ w² (e₁²+e₂²)/2⟩, equivalent to projecting random-rotated - shapes onto the HealPix map (Nside=1024); accounts for number-density - variation on the sky. - default: nicola21_analytic - options: - nicola21_analytic: - label: "Nicola+21 analytic (fiducial)" - random_rotation: - label: "Random-rotation map projection" - description: "Equivalent numerical estimate." - - nl_model: - label: "Non-linear power-spectrum model" - tags: [physics] - rationale: >- - HMCode2020 with a single feedback parameter T_AGN. Halofit and - HMCode-no-baryons run as robustness checks (S₈ shifts −0.41σ and −0.20σ). - default: hmcode2020 - options: - hmcode2020: - label: "HMCode2020 (T_AGN feedback, fiducial)" - halofit: - label: "Halofit (Takahashi 2012)" - description: "S₈ shifts −0.41σ." - hmcode_no_baryons: - label: "HMCode2020, no baryons" - description: "S₈ shifts −0.20σ." - - baryon: - label: "Baryonic-feedback marginalisation" - tags: [physics] - rationale: >- - Marginalise log T_AGN with a uniform hydro-informed prior - (T_AGN ~ 10^7.6–10^8 K; range U(7.3, 8.0) is config-derived). Weakly - constrained (posterior 7.627⁺⁰·²⁶³₋₀.₁₈₇). - default: marginalise_tagn - options: - marginalise_tagn: - label: "Marginalise log T_AGN, uniform prior (fiducial)" - - ia_model: - label: "Intrinsic-alignment model" - tags: [physics] - rationale: >- - NLA with η_IA = 0 (redshift-independent, non-tomographic); a strong - conservative A_IA prior is required to break the IA–shear degeneracy. - default: nla_eta0 - options: - nla_eta0: - label: "NLA, η_IA = 0 (fiducial)" - - ia_prior: - label: "A_IA prior" - tags: [physics] - rationale: >- - Gaussian A_IA prior from a direct red+blue IA measurement: A_IA = 0.83 ± - 0.39 in the live text. (Config and a commented-out table use width 0.7 — - a known text-vs-config discrepancy.) Posterior follows the prior - (1.011⁺⁰·⁶⁵⁵₋₀.₆₉₄; unconstrained). - default: gauss_0p39 - options: - gauss_0p39: - label: "A_IA ~ N(0.83, 0.39) (live text, fiducial)" - gauss_0p7: - label: "A_IA ~ N(0.83, 0.7) (config / commented table)" - description: "Config-derived width; not the live-text value." - - dz_prior: - label: "Redshift-shift Δz prior" - tags: [calibration] - rationale: >- - Additive shift n(z) → n(z + Δz). Corrected mean Δz = −0.003 (from MICE2 - mocks), width ±0.018. A pre-unblinding bug used −0.030; the fix shifted - S₈ lower by ~0.03. - default: gauss_dz - options: - gauss_dz: - label: "Δz ~ N(−0.003, 0.018) (fiducial)" - preunblinding_dz: - label: "Pre-unblinding Δz = −0.030 (bug)" - description: "Superseded; still present in config." - - m_prior: - label: "Multiplicative shear bias m" - tags: [calibration] - rationale: >- - Residual multiplicative bias m added as a nuisance, rescaling Cℓ → - (1+m)² Cℓ. Calibrated from image simulations (Paper V); the numeric - N(−0.057, 0.014) is config-derived. - default: gauss_m - options: - gauss_m: - label: "m ~ N(−0.057, 0.014) (config, fiducial)" - - leakage: - label: "PSF-leakage treatment" - tags: [calibration] - rationale: >- - PSF-leakage-corrected ellipticities (Li/KiDS-Legacy method). With/without - leakage agree at +0.02σ; the residual C_ℓ^sys stays below 5% on almost - all scales and is neglected. - default: corrected - options: - corrected: - label: "Leakage-corrected (fiducial)" - uncorrected: - label: "No leakage correction" - description: "+0.02σ shift." - - sampler: - label: "Sampler / likelihood" - tags: [stats] - rationale: >- - Gaussian likelihood with fixed covariance; theory from CosmoSIS; - parameter estimation with the Polychord nested sampler. Sampled set - {ω_c, ω_b, H0, n_s, S8} with KiDS-Legacy Y3 Hybrid priors. (Live-point - count is config-derived.) - default: polychord - options: - polychord: - label: "Polychord, CosmoSIS theory (fiducial)" - - point_estimate: - label: "Point-estimate statistic" - tags: [stats] - rationale: >- - MAP via KDE on the marginalised posterior — 2D for S₈ and Ω_m, 1D for - the rest. Chosen because the 2D-marginalised KDE best recovers the input - cosmology in the GLASS validation test. - default: map_kde - options: - map_kde: - label: "MAP via KDE (2D for S₈/Ω_m, 1D others)" - -prior_insights: - catalog_cl_ref: - id: catalog_cl_ref - label: "Catalogue-based pseudo-Cℓ (Wolz+25)" - claim: >- - A catalogue-based pseudo-Cℓ estimator represents the mask via source - positions, avoiding pixel-window, aliasing, and Poisson-noise bias. - created_at: "2026-06-13T00:00:00" - derived: false - evidence: - - id: e1 - doi: "10.1088/1475-7516/2025/01/028" - quote: - exact: "Catalog-based pseudo-Cls" - - cosmocov_ref: - id: cosmocov_ref - label: "Non-Gaussian covariance (OneCovariance)" - claim: >- - OneCovariance provides the connected four-point and super-sample - non-Gaussian covariance terms for cosmic-shear power spectra. - created_at: "2026-06-13T00:00:00" - derived: false - evidence: - - id: e1 - doi: "10.1051/0004-6361/202452592" - quote: - exact: "OneCovariance" - - glass_mocks_ref: - id: glass_mocks_ref - label: "GLASS mocks (Tessore+23)" - claim: >- - 350 GLASS lognormal mocks reproduce the survey footprint, number density, - shape noise, and n(z) for covariance validation and the goodness-of-fit. - created_at: "2026-06-13T00:00:00" - derived: false - evidence: - - id: e1 - doi: "10.21105/astro.2302.01942" - quote: - exact: "GLASS: Generator for Large Scale Structure" - -outputs: - - id: cl_data_vector - type: data - label: "Shear Cℓ data vector (EE/EB/BB bandpowers)" - inputs: [shear_catalog, nz] - decisions: [catalog_version, leakage, estimator, cell_method, binning, - noise_bias, blinding] - recipe: - command: >- - python -m sp_validation.harmonic.measure_cl - --catalog {inputs.shear_catalog} --nz {inputs.nz} - --catalog-version {decisions.catalog_version} - --leakage {decisions.leakage} - --estimator {decisions.estimator} - --field {decisions.cell_method} - --binning {decisions.binning} - --noise-bias {decisions.noise_bias} - --blind {decisions.blinding} - --out {output} - - - id: covariance - type: data - label: "Cℓ covariance (iNKA + OneCovariance)" - inputs: [nz, glass_mocks] - decisions: [covariance_method, fiducial_cosmology] - recipe: - command: >- - python -m sp_validation.harmonic.covariance - --nz {inputs.nz} --mocks {inputs.glass_mocks} - --covariance {decisions.covariance_method} - --cosmology {decisions.fiducial_cosmology} - --out {output} - - - id: cosmo_constraints - type: table - label: "Cosmological constraints (S₈, Ω_m, σ₈)" - inputs: [cl_data_vector, covariance, nz, external_planck] - decisions: [scalecut, scalecut_method, nl_model, baryon, ia_model, ia_prior, - dz_prior, m_prior, sampler, point_estimate] - recipe: - command: >- - python -m sp_validation.harmonic.infer - --data {inputs.cl_data_vector} --cov {inputs.covariance} --nz {inputs.nz} - --planck {inputs.external_planck} - --scalecut {decisions.scalecut} - --scalecut-method {decisions.scalecut_method} - --nl-model {decisions.nl_model} - --baryon {decisions.baryon} - --ia-model {decisions.ia_model} - --ia-prior {decisions.ia_prior} - --dz-prior {decisions.dz_prior} - --m-bias {decisions.m_prior} - --sampler {decisions.sampler} - --point-estimate {decisions.point_estimate} - --out {output} - -findings: - s8: - id: s8 - claim: "Fiducial S₈ = 0.891⁺⁰·⁰⁵⁷₋₀.₀₈₄ (MAP via getdist 2D-marginalised KDE)." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - quote: { exact: "0.891^{+0.057}_{-0.084}" } - - omega_m: - id: omega_m - claim: "Fiducial Ω_m = 0.225⁺⁰·¹⁵³₋₀.₀₇₇." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - sigma8: - id: sigma8 - claim: "Fiducial σ₈ = 0.960⁺⁰·²²³₋₀.₂₅₇." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - gof_chi2: - id: gof_chi2 - claim: "Good fit: χ² = 8.1 (table 8.06, N_data 17), PTE 0.76 vs GLASS mocks." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - planck_consistency: - id: planck_consistency - claim: "Consistent with Planck 2018 at the 0.79σ level." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - wl_consistency: - id: wl_consistency - claim: "Consistent at 0.87–1.51σ with DES Y3, HSC Y3, and KiDS-Legacy." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - config_consistency_indep: - id: config_consistency_indep - claim: "S₈ consistent with the config-space (Paper III) value at 0.60σ assuming independent errors." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - config_consistency_corr: - id: config_consistency_corr - claim: >- - Accounting for the shared sample, the ΔS₈ = 0.06 difference has p = 1.5e-2 - (2.18σ); uncertain given the low simulation budget. - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cosmo_constraints - - eb_pte: - id: eb_pte - claim: "EB power spectrum: χ² = 20 for 32 dof, PTE = 0.95 (iNKA cov, all scales)." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cl_data_vector - - bb_pte: - id: bb_pte - claim: "BB power spectrum: χ² = 41 for 32 dof, PTE = 0.132 (iNKA, all scales); marginally passes 0.05." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cl_data_vector - - bb_pte_cuts: - id: bb_pte_cuts - claim: "Removing the 3 smallest-scale points raises BB PTE to 0.271; also removing ℓ<300 gives 0.336." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cl_data_vector - - bb_pte_gauss_sims: - id: bb_pte_gauss_sims - claim: "With 10000-Gaussian-sim covariance: all-scales BB PTE 0.013, EB 0.82; after cuts BB 0.17, EB 0.40." - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: cl_data_vector - - covariance_diff: - id: covariance_diff - claim: >- - Non-Gaussian terms add ~10% off-diagonal correlation for 100 ≲ ℓ ≲ 900 - (~5% diagonal at ℓ=300); iNKA vs OneCovariance differ by ~20–25%. - created_at: "2026-06-13T00:00:00" - derived: true - evidence: - - id: e1 - artifact: covariance diff --git a/scratch/cdaley/unions_astra/analyses/nz/astra.yaml b/scratch/cdaley/unions_astra/analyses/nz/astra.yaml deleted file mode 100644 index 1625a1403..000000000 --- a/scratch/cdaley/unions_astra/analyses/nz/astra.yaml +++ /dev/null @@ -1,376 +0,0 @@ -version: "0.0.10" -name: "v2 tomographic n(z) (SOM direct calibration)" -tags: [unions, weak-lensing, redshift-calibration, n-of-z] - -authors: - - "Cail Daley" - -narrative: - summary: | - The source redshift distributions of the v2 tomographic analysis, from - the recipe `config/calibration/nz/v2.yaml` run by - `scripts/calibration/calibrate_nz.py` (`sp_validation.nz`). Sources and - calibrators share one photometry, PhotoPipe's run on the DR6 detections; - a self-organising map trained on EGS spectra transfers the spectra's - redshifts to the sources of each BPZ bin. The calibration rests on one - spectroscopic field, so it serves validation, null tests and mocks, not - parameter constraints. - methods: | - Sources take their photometry by [object ID](#decisions.source_photometry_join), - with an undetected z filled from [z2](#decisions.z2_offset), and every - magnitude [as delivered](#decisions.photometry_as_delivered). They fall - into [four equal-weight BPZ bins](#decisions.tomographic_bins). The - [calibrators](#decisions.calibrator_set) train the [SOM](#decisions.som_map); - within each bin, [gold](#decisions.gold_selection) groups keep sources - whose spectra agree with their BPZ, and the weighted spectra are - deposited on the [Δz = 0.05 grid](#decisions.grid_step). The - [ensemble](#decisions.ensemble_terms) perturbs that calibration to give - its uncertainty. - inputs: | - The [shear_catalogue](#inputs.shear_catalogue), its - [photometry_collection](#inputs.photometry_collection), and the - [egs_spectra](#inputs.egs_spectra). - outputs: | - The binned n(z) [nz_tomo](#outputs.nz_tomo) and its sum - [nz_nontomo](#outputs.nz_nontomo), each row's bin in - [tom_bin](#outputs.tom_bin), and the n(z) - [realisations](#outputs.realisations). - -inputs: - - id: shear_catalogue - type: data - label: "Released calibrated v2 shear catalogue" - source: "${unions_v2}/v2.0.0/catalogs/calibrated" - description: >- - The catalogue cosmo_val measures (SP_v2.0): TILE_ID, NUMBER and the - shear weight w_des of every row. Its rows are the sources. - - id: photometry_collection - type: data - label: "v2 collection: shapes with the PhotoPipe extension" - source: "${unions_v2}/run1-snap3-collection" - description: >- - The HATS collection of ShapePipe shapes and PhotoPipe's dereddened GAaP - ugriz, z2 and BPZ Z_B on Stephen Gwyn's DR6 detections, indexed by - OBJECT_ID. - - id: egs_spectra - type: data - label: "The collection's spec-z extension" - source: "${unions_v2}/run1-snap3-collection/specz" - description: >- - PhotoPipe's spec-z matches to its own objects (UNIONS_DR6_ugriz_specz.cat, - compilation of 2026-10-19), joined to the collection on OBJECT_ID by - sp_validation.assembly.specz_merge: Z_SPEC, Z_SPEC_SURVEY and the spectrum's own - position, 4.7 million rows over 36 surveys. - -decisions: - source_photometry_join: - label: "Source photometry join" - tags: [data-selection] - rationale: >- - Each catalogue row takes PhotoPipe photometry and BPZ from the - collection by its DR6 object ID, OBJECT_ID = 10⁶ × tile + NUMBER, an - exact integer key. A row with no DR6 number, or an ID the collection - lacks, keeps NaN photometry, so it gets no bin, and summary.json's - `match` reports its share of the shear weight. The previous run matched - by exact float RA/Dec, which depends on two catalogues writing the same - bits for a position (Cail, 14 Nov: "Why are we not doing this on object - IDs? … concerning to me"). - Values: nz.inputs.OBJECT_ID = "OBJECT_ID". - default: object_id - options: - object_id: - label: "Join on OBJECT_ID" - description: "Exact integer key; unmatched rows are counted, never guessed." - exact_position: - label: "Exact RA/Dec position match" - description: >- - The previous run's join. A rounding difference between catalogues - silently drops or mismatches rows. - - tomographic_bins: - label: "Tomographic bin edges" - tags: [binning] - rationale: >- - Four bins cut on the DR6 BPZ point estimate Z_B within [0.10, 1.20). - Each run places the interior edges at equal shear weight (quartiles) - over sources with complete photometry and BPZ in range, before gold; - summary.json records them. The calibrators are split by the same edges. - Cail, 14 Nov: "equal weight quartiles is fine. I don't see why we care - if they move a little bit. The n(z) are gonna move either way." The - population the quartiles are taken over (complete photometry, in range, - before gold, in one pass, since gold depends on the bins) is the hub's - choice and not yet confirmed by Cail; gold then removes a different - share of each bin, so the delivered bins are only roughly equal. - The previous hand-set edges 0.10/0.37/0.55/0.76/1.20 were the - shear-weight quartiles of the first calibration, kept through later - runs. - Values: v2.yaml#bins.count = 4; v2.yaml#bins.range = [0.1, 1.2]. - default: equal_weight_quartiles - options: - equal_weight_quartiles: - label: "Equal shear weight, recomputed per run" - description: "Interior edges at the shear-weight quartiles of the run's own sources." - fixed_edges: - label: "Fixed edges kept across releases" - description: >- - The previous 0.10/0.37/0.55/0.76/1.20. Bins stay comparable between - runs, but drift from equal weight as the catalogue changes. - equal_number: - label: "Equal galaxy number" - description: >- - Quantiles of galaxy count rather than shear weight. KiDS-Legacy - (Wright et al. 2025, arXiv:2503.19440) chose six approximately - equipopulated Z_B bins a priori on the SKiLLS simulations - (0.10/0.42/0.58/0.71/0.90/1.14/2.00). - som_cell_assignment: - label: "Bins assigned by SOM cell" - description: >- - DES Y3 (Myles et al. 2021, arXiv:2012.08566) assigns each wide SOM - cell to the bin where most of its redshift-sample galaxies fall, with - edges adjusted to roughly equal galaxy numbers in four bins. Needs a - wide-field SOM and a deep-field transfer this calibration lacks. - fixed_width: - label: "Fixed-width bins" - description: >- - KiDS-1000 (Hildebrandt et al. 2021, arXiv:2007.15635) cut on the BPZ - point estimate Z_B in five bins, Δz_B = 0.2 over 0.1–0.9 and a fifth - over 0.9–1.2, calibrated by SOM direct calibration with a gold - selection (Wright et al. 2020, arXiv:1909.09632). HSC Y3 (Dalal et - al. 2023, arXiv:2304.00701) used four bins of width 0.3 over - 0.3–1.5 in the DNNz point estimate. - - calibrator_set: - label: "Spectroscopic calibration sample" - tags: [calibration, data-selection] - rationale: >- - Calibrators are a selection on the collection's spec-z extension, so - they share the sources' photometry by construction: the DEEP2 and DEEP3 - spectra whose position lies in the EGS, each kept once (a spectrum - matched in two overlapping tiles keeps its lowest OBJECT_ID), with z > - 0.002 (removing stars) and complete ugriz after the z2 fill: about - 9,900. The field bound matters because DEEP2 also covers Field 2 (RA - 252°, Dec 35°, 3,900 matched spectra), which DEEP2 preselected by BRI - colour to z > 0.7; a SOM trained on both fields would calibrate the low - bins on a sample missing low-z galaxies, and the ensemble's density term - describes one 2° × 0.25° strip. Our code applies no redshift-quality - cut; the compilation gives every DEEP2/3 entry confidence 0.99, read - as a secure-redshift selection made upstream (not confirmed). One field - means no field-to-field variance beyond the ensemble's line-of-sight - term and no model of DEEP2/3 targeting or redshift success. - Values: v2.yaml#inputs.calibrators.surveys = ["deep2_final", "deep3_final"]; - v2.yaml#inputs.calibrators.field = {"ra": [213.0, 217.0], "dec": [51.5, 54.0]}; - v2.yaml#inputs.calibrators.z_min = 0.002. - default: deep2_deep3_egs - options: - deep2_deep3_egs: - label: "DEEP2 + DEEP3 in EGS" - description: "PhotoPipe's own matches; one field, bounded by position." - deep2_both_fields: - label: "DEEP2 in EGS and Field 2 + DEEP3" - description: >- - 13,800 spectra, but Field 2's BRI preselection removes z < 0.7 - galaxies there, and the ugriz SOM does not absorb it: in groups shared - with EGS, Field 2's spec-z sit higher by +0.44, +0.31, +0.14 and - +0.017 in bins 1-4, and adding Field 2 moves bin 3's mean z by +0.039 - (3.7 sigma) with sigma barely changed (tested 15 Nov on this - calibration's SOM). Not taken. - add_desi_dr1: - label: "Add DESI DR1 on the same tiles" - description: >- - About 36,000 DESI DR1 spectra on the same photometry, with their own - targeting; a separate decision, not taken. - other_fields: - label: "Add other spectroscopic fields" - description: "Field-to-field variance, once PhotoPipe matches spectra elsewhere." - - photometry_as_delivered: - label: "PhotoPipe photometry used as delivered" - tags: [calibration] - rationale: >- - [HARDCODED] Sources and calibrators use PhotoPipe's magnitudes with no - stellar-locus or zero-point correction; the code has no correction step. - EGS sits off the DR6 stellar locus (+0.035 in g−r, +0.055 in i−z) and - DR6 tiles carry 9–28 mmag zero-point errors in colours - (pando unions/v2-tomographic-nz/egs-off-the-stellar-locus, - unions/v2-tomographic-nz/romain-dr6-zero-point-note). These enter as - the ensemble's zero_points term and a stated limitation. Correcting EGS - by the full stellar offset would raise ⟨z⟩ by up to +0.018, +0.005, - +0.007, +0.013 per bin. Cail, 14 Nov: "We don't correct the photometry - … this is up to Hendrik to fix. We can do any checks we want, but - Hendrik's the photo-z guy." - Values: none. - default: as_delivered - options: - as_delivered: - label: "As delivered" - description: "Zero-point errors enter as an uncertainty term." - correct_egs: - label: "Correct EGS only" - description: >- - Shift the calibrators by the EGS stellar-locus offset. Galaxies follow - only 0.6–0.9 of a stellar offset, so this over-corrects. - per_tile_stellar_locus: - label: "Per-tile stellar-locus correction" - description: "Romain Paviot's smoothed per-tile solution, applied to sources and calibrators." - - z2_offset: - label: "z2 fills an undetected z" - tags: [calibration] - rationale: >- - Where z is undetected, the second z exposure (z2) fills it after a - constant offset, for sources and calibrators alike; canonical z takes - precedence. Without it, sources measured only in z2 (a third of the - gold weight) would lack complete photometry and leave every bin. The - constant's error enters the ensemble as its z2_offset term. - Values: v2.yaml#z2_offset = -0.1104888916015625. - default: offset_z2 - options: - offset_z2: - label: "z2 + constant offset" - description: "Canonical z first." - canonical_only: - label: "Canonical z only" - description: "Drops the z2-only sources." - - som_map: - label: "Self-organising map" - tags: [calibration] - rationale: >- - A planar 101 × 101 batch SOM, 60 epochs with PCA initialisation, seed - 42, trained on the calibrators alone. [HARDCODED] Its features are the - ten pairwise ugriz colours and r, standardised per feature. Ward - clustering merges the 10,201 cells into 2,000 groups, about five spectra - each, the unit of the calibration weights and the gold test; each - source goes to its nearest cell with no distance cut. - Values: v2.yaml#som.side = 101; v2.yaml#som.epochs = 60; - v2.yaml#som.seed = 42; v2.yaml#groups = 2000. - default: calibrator_trained_101 - options: - calibrator_trained_101: - label: "101 × 101 on calibrators, 2,000 groups" - description: "Ten colours + r." - train_on_sources: - label: "Train on the sources" - description: "Cells follow the source population; most cells then hold no spectrum." - no_grouping: - label: "Calibrate per cell" - description: "About one spectrum per cell: more cells without support, noisier weights." - - gold_selection: - label: "Gold selection threshold" - tags: [data-selection, calibration] - rationale: >- - Within a bin, a group is gold when it holds an in-bin spectrum and its - spectra's mean spec-z agrees with its sources' weighted mean BPZ within - max(0.4, 5 × NMAD(spec-z − BPZ)) over every calibrator; sources outside - gold get TOM_BIN_ID 0. Most of gold's loss is groups with no in-bin - spectrum, not the agreement test. The - factor's range enters the ensemble as its nmad_factor term. - Values: v2.yaml#gold_qc.floor = 0.4; v2.yaml#gold_qc.nmad_factor = 5. - default: floor_0_4_nmad_5 - options: - floor_0_4_nmad_5: - label: "max(0.4, 5 × NMAD)" - description: "Fiducial." - support_only: - label: "Support only" - description: "Keep every group with an in-bin spectrum, no agreement test." - - grid_step: - label: "Delivered n(z) resolution" - tags: [binning] - rationale: >- - The weighted spectra are deposited linearly on a grid of step 0.05 over - [0, 5], which keeps each bin's mass and mean and widens it by about - step²/6 in variance. A finer grid resolves the galaxy overdensities - along the single EGS sightline, which belong to the calibration field - and not to the sources. Against a 0.01 grid, 0.05 moves the ξ± theory - (12–83′) by Δχ² < 0.01 without intrinsic alignments and 0.06 with - A_IA = 1. - Values: v2.yaml#grid.step = 0.05. - default: step_0_05 - options: - step_0_05: - label: "Δz = 0.05" - description: "Smooths the calibration field's line-of-sight structure." - step_0_01: - label: "Δz = 0.01" - description: "Resolves the EGS sightline's spikes into the delivered n(z)." - - ensemble_terms: - label: "n(z) realisation terms and sizes" - tags: [stats, systematics] - rationale: >- - 2,000 draws perturb the calibration's inputs and recalibrate every bin - together. Statistical terms: a bootstrap of the spectra, and a lognormal - line-of-sight density through the 2° × 0.25° DEEP2/3 strip with bias - 1.3. Systematic terms: EGS zero points against the wide field (colour - sigmas and correlations from stellar-locus regression on 3.4 deg² - patches, plus 0.01 mag grey from Pan-STARRS 3π uniformity), the z2 → z - constant (0.02 mag), spec-z failures (1%, from the compilation's 0.99 - confidence), and the gold factor drawn in [4, 6]. The zero points - dominate σ⟨z⟩ and correlate ⟨z⟩ between bins. - Unmodelled: spectroscopic selection and incompleteness, and method bias - calibrated on simulations, so this is a lower bound. Sizes are argued - in scripts/calibration/README.md. - Values: v2.yaml#ensemble.draws = 2000; v2.yaml#ensemble.bootstrap = True; - v2.yaml#ensemble.density.field = [2.0, 0.25]; - v2.yaml#ensemble.density.bias = 1.3; - v2.yaml#ensemble.zero_points.colour_sigma = [0.0215, 0.0194, 0.0119, 0.0208]; - v2.yaml#ensemble.zero_points.colour_corr = [[1.0, -0.59, 0.13, -0.13], [-0.59, 1.0, -0.05, 0.16], [0.13, -0.05, 1.0, -0.49], [-0.13, 0.16, -0.49, 1.0]]; - v2.yaml#ensemble.zero_points.grey = 0.01; - v2.yaml#ensemble.z2_offset = 0.02; - v2.yaml#ensemble.specz_failure = 0.01; - v2.yaml#ensemble.nmad_factor = [4, 6]. - default: statistical_and_systematic - options: - statistical_and_systematic: - label: "Statistical and systematic terms" - description: "Every term above." - statistical_only: - label: "Bootstrap and density only" - description: "Expected Δχ² 0.16 on v2 ξ±, against 1.06 with the systematic terms." - delta_z_shifts: - label: "Independent per-bin Δz shifts" - description: "σ = 0.018 per bin, the 2D analysis's prior: expected Δχ² 4.08, no inter-bin correlation." - -outputs: - - id: nz_tomo - type: data - label: "Tomographic n(z)" - inputs: [shear_catalogue, photometry_collection, egs_spectra] - decisions: - [source_photometry_join, tomographic_bins, calibrator_set, - photometry_as_delivered, z2_offset, som_map, gold_selection, grid_step] - description: >- - nz_tomo.txt: z and one density per bin, each integrating to the bin's - share of the retained shear weight (cosmo_val's shear.redshift_path). - - id: nz_nontomo - type: data - label: "Non-tomographic n(z)" - inputs: [shear_catalogue, photometry_collection, egs_spectra] - decisions: - [source_photometry_join, tomographic_bins, calibrator_set, - photometry_as_delivered, z2_offset, som_map, gold_selection, grid_step] - description: "nz_nontomo.txt: the sum of the bins, the n(z) of every TOM_BIN_ID > 0 row." - - id: tom_bin - type: data - label: "Per-row tomographic bin" - inputs: [shear_catalogue, photometry_collection, egs_spectra] - decisions: - [source_photometry_join, tomographic_bins, calibrator_set, - photometry_as_delivered, z2_offset, som_map, gold_selection] - description: >- - tom_bin.parquet: OBJECT_ID, TOM_BIN_ID and ZBAND, row-aligned with the - shear catalogue. - - id: realisations - type: data - label: "n(z) realisations" - inputs: [shear_catalogue, photometry_collection, egs_spectra] - decisions: - [source_photometry_join, tomographic_bins, calibrator_set, - photometry_as_delivered, z2_offset, som_map, gold_selection, grid_step, - ensemble_terms] - description: >- - realisations.npz: (draws, bins, z) unit-integral n(z), every bin drawn - together and recentred on the delivered n(z). diff --git a/scratch/cdaley/unions_astra/astra.yaml b/scratch/cdaley/unions_astra/astra.yaml deleted file mode 100644 index 9abfb95b5..000000000 --- a/scratch/cdaley/unions_astra/astra.yaml +++ /dev/null @@ -1,238 +0,0 @@ -version: "0.0.10" -name: "UNIONS-3500 weak-lensing release (Papers II–IV)" -tags: [unions, weak-lensing, cosmic-shear] - -authors: - - "Cail Daley" - -narrative: - summary: | - The UNIONS-3500 cosmic-shear release as a single ASTRA project, spanning - three papers that share one shear catalogue and one fiducial setup but - diverge in statistic and estimator: **Paper II** ([bmodes](#analyses.bmodes), - Daley et al.) validates B-modes with three E/B-separable statistics; - **Paper III** ([cosmic_shear_2d](#analyses.cosmic_shear_2d), Goh et al.) - measures the configuration-space two-point functions ξ±(θ) and infers - S₈; **Paper IV** ([harmonic](#analyses.harmonic), Guerrini et al.) does the - same in harmonic space with pseudo-Cℓ. This project stops at **inference - data products** — data vectors, covariances, and the cosmological-constraint - findings — and does not model the MCMC chains themselves. - - What is genuinely shared hoists here: the [catalogue version](#decisions.catalog_version) - (ShapePipe v1.4.6.3, the adopted size-cut fiducial), [metacalibration](#decisions.shear_calibration), - the [PSF-leakage correction](#decisions.leakage_correction), the [SOM n(z)](#inputs.nz), - the [Planck 2018 fiducial cosmology](#decisions.fiducial_cosmology), the - [GLASS validation mocks](#inputs.glass_mocks), and the [external blinding](#decisions.blinding) - coordinated by Koen Kuijken. Where the papers truly diverge — covariance - method most of all (CosmoCov in config space; NaMaster iNKA + OneCovariance - in harmonic space) — the decision stays local to the paper. - methods: | - Three external sub-analyses: [bmodes](#analyses.bmodes), - [cosmic_shear_2d](#analyses.cosmic_shear_2d), [harmonic](#analyses.harmonic). - Shared methodological choices live here and are pulled down with `from:`: - [catalog_version](#decisions.catalog_version), [shear_calibration](#decisions.shear_calibration), - [leakage_correction](#decisions.leakage_correction), [fiducial_cosmology](#decisions.fiducial_cosmology), - and [blinding](#decisions.blinding). Each paper owns its statistic, - scale cuts, estimator, binning, covariance method, and (for III/IV) the - full modelling stack (non-linear power, baryons, intrinsic alignment). - A fourth sub-analysis, [dr6_catalogue](#analyses.dr6_catalogue), records - the selection of the DR6 ShapePipe v2 catalogue, which no paper here - consumes; a fifth, [nz](#analyses.nz), records the SOM direct - calibration of the v2 tomographic n(z), which none consumes either. - inputs: | - The common [shear_catalog](#inputs.shear_catalog) (ShapePipe v1.4.6.3, - 61,378,891 galaxies over 2894 deg² effective, n_eff ≈ 4.96 arcmin⁻², - σ_e = 0.27), the SOM [nz](#inputs.nz), and the 350 [glass_mocks](#inputs.glass_mocks) - are shared inputs aliased into each paper. - outputs: | - The release-level products are re-exported from the sub-analyses: the Paper II - [bmode_pte_table](#outputs.bmode_pte_table), the Paper III - [config_constraints](#outputs.config_constraints), and the Paper IV - [harmonic_constraints](#outputs.harmonic_constraints). - -inputs: - - id: shear_catalog - type: data - label: "UNIONS-3500 ShapePipe shear catalogue (v1.4.6.3, fiducial size-cut)" - source: "/n17data/UNIONS/WL/" - description: >- - The fiducial UNIONS weak-lensing sample: ShapePipe v1.4 catalogue, - size-cut variant (r_h,gal/r_h,psf > 0.707), leakage-corrected, - metacalibration-calibrated ellipticities. 61,378,891 galaxies covering - A_eff = 2894 deg² after masking; n_eff = 4.96 arcmin⁻²; per-component - shape noise σ_e = 0.27. CFIS r-band. Adopted as the fiducial for - Papers II, III, and IV. Config-string v1.4.6.3 is config-derived (Paper I, - Table H.1). - - id: nz - type: data - label: "SOM redshift distribution n(z)" - source: "/n17data/UNIONS/WL/nz/" - description: >- - Single-bin source n(z) from a self-organising map (101×101 cells, - hierarchically clustered to ~5000 resolution elements) trained on the - colour-redshift relation, calibrated with ~65,500 spec-z (DEEP2, VVDS, - VIPERS) and CFHTLenS ugriz in the W3 field (44.2 deg²). Mean of 1000 - realisations. Method derived in Paper III (Goh et al.) Sect. 3.3. - - id: glass_mocks - type: data - label: "GLASS lognormal validation mocks (~350)" - source: "/n17data/UNIONS/WL/glass/" - description: >- - ~350 GLASS (Tessore et al. 2023) lognormal simulated catalogues - reproducing the UNIONS footprint, galaxy positions/number density, - weights, shape noise, and n(z) under the Planck 2018 cosmology, with no - PSF systematics. Paper II uses 350; Paper III uses 341; Paper IV uses - 350. Used for pipeline/covariance validation and the harmonic config-vs- - Cℓ cross-correlation. - -decisions: - catalog_version: - label: "Shear catalogue version / variant" - tags: [data-selection] - rationale: >- - Paper II validates four ShapePipe v1.4 variants and adopts the size-cut - catalogue (tightened r_h,gal/r_h,psf > 0.707) as the release fiducial; - only that variant passes all B-mode statistics at the adopted cuts. - Papers III and IV consume the adopted fiducial. Version string v1.4.6.3 - is config-derived (TeX refers to Paper I Table H.1). - default: size_cut_v1_4_6_3 - options: - initial_v1_4_5: - label: "Initial (loose size cut > 0.5)" - description: "Loose size cut r_h,gal/r_h,psf > 0.5. Fails harmonic B-mode null test (Paper III)." - size_cut_v1_4_6_3: - label: "Size-cut (fiducial)" - description: "Tightened size cut > 0.707. Adopted fiducial for Papers II–IV; passes all statistics at adopted cuts." - masked_v1_4_8: - label: "Masked (bright/faint-star halo masking)" - description: >- - Size cut plus bright-star (r<12) and faint-star (12- - Ellipticities calibrated via metacalibration: galaxy images artificially - sheared to measure the 2×2 response matrix R, yielding γ = R⁻¹(e − c). - Shared across all three papers (set by the catalogue). A residual - multiplicative bias m is handled per-paper as a nuisance parameter. - default: metacalibration - options: - metacalibration: - label: "Metacalibration (Huff & Mandelbaum 2017; Sheldon & Huff 2017)" - insights: [metacal_selfcal] - - leakage_correction: - label: "Object-wise PSF-leakage correction" - tags: [calibration] - rationale: >- - Object-wise PSF-leakage correction (Paper I), modelling PSF contamination - via binned regression in S/N and galaxy-PSF size ratio. The - leakage-corrected catalogues are the fiducial used for cosmological - inference in Papers III and IV; Paper II reports both corrected and - uncorrected. The correction shifts B-mode PTEs by ≲ 0.05 and S₈ by - ≈ +0.02 σ (harmonic) — minimal impact. - default: corrected - options: - corrected: - label: "Leakage-corrected" - description: "Fiducial. Used for inference in Papers III and IV." - uncorrected: - label: "No object-wise leakage correction" - description: "Comparison variant (Paper II reports both; Paper III sensitivity row)." - - fiducial_cosmology: - label: "Fiducial cosmology for covariances / mocks" - tags: [physics] - rationale: >- - Planck 2018 is the fiducial cosmology used to generate the GLASS mocks - and (in config space) the CosmoCov covariance. Paper III's CosmoCov input - cosmology follows Table 1 of the OneCovariance paper (a Planck-class - ΛCDM). astropy Planck18 parameter values are config-derived, not in TeX. - default: planck18 - options: - planck18: - label: "Planck 2018 ΛCDM" - insights: [planck18_cosmology] - onecov_table1: - label: "OneCovariance Table 1 fiducial (Paper III CosmoCov input)" - description: "Planck-class ΛCDM adopted as the CosmoCov input cosmology in Paper III." - - blinding: - label: "Blinding strategy" - tags: [stats] - rationale: >- - Analysis choices and scale cuts were fixed within a blinded framework. - An external coordinator (Koen Kuijken) generated three blinded n(z) - distributions by applying random Δz shifts; PTEs/results were evaluated - across blinds and the most conservative reported. The internal A/B/C - labelling and "fiducial = blind B" mapping are config/script-derived, not - stated in the TeX. - default: external_three_nz - options: - external_three_nz: - label: "External coordinator, three blinded n(z)" - description: >- - Three blinded n(z) via random Δz shifts (Kuijken). Conservative - (min/max-across-blinds) reporting. Primary authors were inadvertently - unblinded in late stages (no setup changes induced). - -prior_insights: - metacal_selfcal: - id: metacal_selfcal - label: "Metacalibration" - claim: >- - Metacalibration self-calibrates shear measurement biases directly from - the imaging by artificially shearing galaxy images to measure the shear - response, without external calibration simulations. - created_at: "2026-06-13T00:00:00" - derived: false - evidence: - - id: e1 - doi: "10.48550/arXiv.1702.02600" - quote: - exact: "Metacalibration: Direct Self-Calibration of Biases in Shear Measurement" - - id: e2 - doi: "10.3847/1538-4357/aa704b" - quote: - exact: "Practical Weak-lensing Shear Measurement with Metacalibration" - - planck18_cosmology: - id: planck18_cosmology - label: "Planck 2018 cosmology" - claim: >- - The Planck 2018 results provide the fiducial ΛCDM cosmological parameters - used to generate the survey mocks and covariances and as the external - comparison for the cosmic-shear constraints. - created_at: "2026-06-13T00:00:00" - derived: false - evidence: - - id: e1 - doi: "10.1051/0004-6361/201833910" - quote: - exact: "Planck 2018 results" - -outputs: - - id: bmode_pte_table - from: bmodes.pte_table - - id: config_constraints - from: cosmic_shear_2d.cosmo_constraints - - id: harmonic_constraints - from: harmonic.cosmo_constraints - -analyses: - bmodes: - path: ./analyses/bmodes - cosmic_shear_2d: - path: ./analyses/cosmic_shear_2d - harmonic: - path: ./analyses/harmonic - dr6_catalogue: - path: ./analyses/dr6_catalogue - nz: - path: ./analyses/nz diff --git a/scripts/calibration/README.md b/scripts/calibration/README.md index 9f1487670..1f0ffe536 100644 --- a/scripts/calibration/README.md +++ b/scripts/calibration/README.md @@ -30,7 +30,7 @@ has unit integral. The recipe for v2 is `config/calibration/nz/v2.yaml`: the inputs, every choice of the calibration, and the output directory, written with data roots (`config/data_roots.yaml`). The choices and their alternatives are recorded as -decisions in `scratch/cdaley/unions_astra/analyses/nz/astra.yaml`. Run inside +decisions in `analyses/redshifts/astra.yaml`. Run inside the container on an allocation: ```bash diff --git a/scripts/calibration/extract_info.py b/scripts/calibration/extract_info.py index 983f0c74b..f062f62f0 100644 --- a/scripts/calibration/extract_info.py +++ b/scripts/calibration/extract_info.py @@ -70,7 +70,7 @@ verbose=verbose, ) -# @sc [decision:dr6_catalogue.catalogue_match_tile_selection] +# @sc [decision:catalogue.catalogue_match_tile_selection] if globals().get("catalogue_match_manifests") is not None: from sp_validation.catalogue_match import write_catalogue_match_audit diff --git a/src/sp_validation/catalogue_match.py b/src/sp_validation/catalogue_match.py index 96f7c3d68..df6a4d765 100644 --- a/src/sp_validation/catalogue_match.py +++ b/src/sp_validation/catalogue_match.py @@ -10,7 +10,7 @@ import numpy as np -# @sc [decision:dr6_catalogue.catalogue_match_tile_selection] +# @sc [decision:catalogue.catalogue_match_tile_selection] MIN_EXTERNAL_PAIRED_FRACTION = None _COUNT_FIELDS = ( diff --git a/src/sp_validation/fetch.py b/src/sp_validation/fetch.py new file mode 100644 index 000000000..f73e8ffb7 --- /dev/null +++ b/src/sp_validation/fetch.py @@ -0,0 +1,98 @@ +"""Bring in a product that is given to the analysis, and record what arrived. + +A delivered product (a ShapePipe snapshot, PhotoPipe's photometry, a mask +ladder) is too large, or has too many files, to commit with the analysis. Its +ASTRA output is therefore this manifest: the product's source and version, and +the size and SHA-256 of every file. It names no machine-local path, so the same +bytes give the same manifest everywhere; a recipe that reads the product +resolves ``source`` with :mod:`sp_validation.data_roots`. + +``source`` is written as in ``config/data_roots.yaml`` (``${unions_data}/...``) +and resolved by :mod:`sp_validation.data_roots`, which fetches a ``vos:`` path +into the local cache. That cache is not refreshed, so for a ``vos:`` product +pass ``--md5sums``: the checksum list is fetched afresh every time, and a file +the list names under the product that is missing or differs (a stale cached +copy included) is an error. + + python -m sp_validation.fetch '${unions_v2}/v2.0.0/nz' --version v2.0.0 \ + --md5sums '${unions_v2}/v2.0.0/MD5SUMS' --out nz.json +""" + +import argparse +import hashlib +import json +from pathlib import Path + +from sp_validation import data_roots + +CHUNK = 1 << 24 + + +def digest(path): + """SHA-256 and MD5 of a file, read once.""" + sha, md5 = hashlib.sha256(), hashlib.md5() + with open(path, "rb") as f: + while block := f.read(CHUNK): + sha.update(block) + md5.update(block) + return sha.hexdigest(), md5.hexdigest() + + +def read_md5sums(path): + """``relative path -> md5`` from an ``md5sum``-format list.""" + table = {} + for line in Path(path).read_text().splitlines(): + if line.strip(): + md5, name = line.split(maxsplit=1) + table[name.lstrip("*").removeprefix("./")] = md5 + return table + + +def manifest(source, version, md5sums=None): + """The manifest of ``source``: its local path and every file's size and hash.""" + root = Path(data_roots.local(data_roots.expand(source))) + files = ( + sorted(p for p in root.rglob("*") if p.is_file()) if root.is_dir() else [root] + ) + entries, md5_of = {}, {} + for path in files: + name = path.relative_to(root).as_posix() if root.is_dir() else path.name + sha, md5 = digest(path) + entries[name] = {"size": path.stat().st_size, "sha256": sha} + md5_of[name] = md5 + if md5sums: + md5sums = data_roots.expand(md5sums) + if md5sums.startswith(data_roots.VOS): + cached = data_roots.CACHE / md5sums.removeprefix(data_roots.VOS).strip("/") + cached.unlink(missing_ok=True) + listed = Path(data_roots.local(md5sums)) + prefix = root.relative_to(listed.parent).as_posix() + under = "" if prefix == "." else prefix + "/" + expected = { + Path(name).name if not root.is_dir() else name.removeprefix(under): md5 + for name, md5 in read_md5sums(listed).items() + if name == prefix or name.startswith(under) + } + missing = sorted(set(expected) - set(md5_of)) + wrong = sorted(n for n, m in expected.items() if n in md5_of and md5_of[n] != m) + if missing or wrong: + raise SystemExit( + f"{source} does not match {md5sums}: " + f"{len(missing)} missing {missing[:5]}, {len(wrong)} differ {wrong[:5]}" + ) + return {"source": source, "version": version, "files": entries} + + +def main(argv=None): + parser = argparse.ArgumentParser(description=__doc__.split("\n")[0]) + parser.add_argument("source", help="data-root path of the product") + parser.add_argument("--version", required=True, help="the product's version") + parser.add_argument("--md5sums", help="data-root path of an md5sum list to check") + parser.add_argument("--out", required=True, help="where to write the manifest") + args = parser.parse_args(argv) + record = manifest(args.source, args.version, args.md5sums) + Path(args.out).write_text(json.dumps(record, indent=1, sort_keys=True) + "\n") + + +if __name__ == "__main__": + main() diff --git a/src/sp_validation/nz/calibration.py b/src/sp_validation/nz/calibration.py index 27f8e41c2..5718482ba 100644 --- a/src/sp_validation/nz/calibration.py +++ b/src/sp_validation/nz/calibration.py @@ -21,7 +21,7 @@ def detected(mag): def features(mag): """Return the ten ugriz colours and r magnitude, in the training order. - @sc [decision:nz.som_map] + @sc [decision:redshifts.som_map] """ return np.column_stack( [mag[:, i] - mag[:, j] for i in range(5) for j in range(i + 1, 5)] + [mag[:, 2]] @@ -31,7 +31,7 @@ def features(mag): def train(mag, side=101, epochs=60, seed=42, workers=1): """Train a planar batch SOM with PCA initialization and Gaussian smoothing. - @sc [decision:nz.som_map] + @sc [decision:redshifts.som_map] """ x = features(mag) center, scale = x.mean(0), x.std(0) @@ -68,7 +68,7 @@ def assign(mag, model, workers=1): def group_cells(model, n_groups=2000): """Ward-cluster map code vectors into zero-based calibration groups. - @sc [decision:nz.som_map] + @sc [decision:redshifts.som_map] """ return ( fcluster(linkage(model["code"], method="ward"), n_groups, criterion="maxclust") @@ -82,7 +82,7 @@ def z_magnitudes(mag, offset, use_z2=True): Canonical z takes precedence; z2 + offset enters only when z is undetected. Five-column inputs contain canonical z only. - @sc [decision:nz.z2_offset] + @sc [decision:redshifts.z2_offset] """ out = mag[:, :5].astype("f8") channel = detected(out[:, 4]).astype(np.int8) @@ -102,7 +102,7 @@ def quantile_edges(mag, photoz, weight, *, range, count, offset): edge is the BPZ value at which the weight below it is nearest to k/count, so it is one of the values BPZ takes. - @sc [decision:nz.tomographic_bins] + @sc [decision:redshifts.tomographic_bins] """ lo, hi = range m, _ = z_magnitudes(mag, offset) @@ -160,7 +160,7 @@ def source_groups( def gold_threshold(cal_z, cal_photoz, floor=0.4, nmad_factor=5): """Compute max(floor, factor × NMAD) of unnormalized spec-z − BPZ. - @sc [decision:nz.gold_selection] + @sc [decision:redshifts.gold_selection] """ residual = cal_z - cal_photoz good = np.isfinite(residual) & (cal_photoz >= 0) & (cal_photoz < 5) @@ -172,7 +172,7 @@ def gold_threshold(cal_z, cal_photoz, floor=0.4, nmad_factor=5): def gold_mask(source_weight, source_photoz_sum, cal_count, cal_z_sum, threshold): """Keep supported groups whose mean spec-z and source BPZ agree within QC. - @sc [decision:nz.gold_selection] + @sc [decision:redshifts.gold_selection] """ spec = np.divide( cal_z_sum, cal_count, out=np.zeros_like(cal_z_sum), where=cal_count > 0 @@ -204,7 +204,7 @@ def tom_bin_ids(prelim, group, gold): def deposit(z, weight, grid): """Linearly deposit mass, conserving its zeroth and first trapezoid moments. - @sc [decision:nz.grid_step] + @sc [decision:redshifts.grid_step] @sc [label:invariant] deposit-conserves-moments The trapezoid integrals of the deposited density over the grid equal the total weight and the weighted mean redshift exactly, on any grid, so the diff --git a/src/sp_validation/nz/ensemble.py b/src/sp_validation/nz/ensemble.py index 8130d3d58..abb0f6ddc 100644 --- a/src/sp_validation/nz/ensemble.py +++ b/src/sp_validation/nz/ensemble.py @@ -337,7 +337,7 @@ def realisations(cal, settings, density=None): nonlinear in them, and the raw mean is returned so its offset can be reported. - @sc [decision:nz.ensemble_terms] + @sc [decision:redshifts.ensemble_terms] """ rng = np.random.default_rng(settings.get("seed", 0)) n_draw, n_cal = settings["draws"], len(cal.z) diff --git a/src/sp_validation/nz/inputs.py b/src/sp_validation/nz/inputs.py index 61ef875e9..3f5bc3a06 100644 --- a/src/sp_validation/nz/inputs.py +++ b/src/sp_validation/nz/inputs.py @@ -7,7 +7,7 @@ DR6 object ID. Calibrators are the objects of the same collection that its spec-z extension gives a spectrum from the recipe's surveys. -@sc [decision:nz.photometry_as_delivered] +@sc [decision:redshifts.photometry_as_delivered] """ from concurrent.futures import ThreadPoolExecutor @@ -40,7 +40,7 @@ def calibrators(photometry, surveys, field, z_min, offset, workers=1): from the compilation. Missing z is filled from z2 + ``offset``, as for sources. Rows come in ``OBJECT_ID`` order. - @sc [decision:nz.calibrator_set] + @sc [decision:redshifts.calibrator_set] """ spectrum = ["Z_SPEC", "Z_SPEC_SURVEY", "Z_SPEC_RA", "Z_SPEC_DEC"] columns = [OBJECT_ID, *spectrum, "Z_B", *MAGS] @@ -91,7 +91,7 @@ def sources(catalogue, photometry, workers=1): no PhotoPipe), ``NO_ID`` for a row with no DR6 number and ``UNMATCHED`` for an ID the collection lacks; both keep NaN photometry. - @sc [decision:nz.source_photometry_join] + @sc [decision:redshifts.source_photometry_join] @sc [label:convention] sources-row-aligned Every returned array is in the catalogue's row order, rows without photometry included: ``tom_bin.parquet`` is written in this order, and row diff --git a/src/sp_validation/tests/test_catalogue_match.py b/src/sp_validation/tests/test_catalogue_match.py index c60a2d5ca..448d79dc6 100644 --- a/src/sp_validation/tests/test_catalogue_match.py +++ b/src/sp_validation/tests/test_catalogue_match.py @@ -144,18 +144,18 @@ def test_missing_unit_and_missing_vs_present_metadata(tmp_path): cm.read_catalogue_match_manifests([missing]) -DECISION = "dr6_catalogue.catalogue_match_tile_selection" +DECISION = "catalogue.catalogue_match_tile_selection" def record_pins(root): """Return the decision's ``Values:`` pins from the composed ASTRA record.""" analysis_id, decision_id = DECISION.split(".") - project_root = root / "scratch/cdaley/unions_astra" - project = yaml.safe_load((project_root / "astra.yaml").read_text()) - analysis_root = project_root / project["analyses"][analysis_id]["path"] + project = yaml.safe_load((root / "astra.yaml").read_text()) + analysis_root = root / project["analyses"][analysis_id]["path"] spec = yaml.safe_load((analysis_root / "astra.yaml").read_text()) decision = spec["decisions"][decision_id] - assert decision["default"] in decision["options"] + chosen = project["universes"]["v2_0_0"]["decisions"][DECISION] + assert chosen in decision["options"] rationale = decision["rationale"] assert rationale.count("Values:") == 1 values = rationale.split("Values:", 1)[1].strip().removesuffix(".") diff --git a/src/sp_validation/tests/test_fetch.py b/src/sp_validation/tests/test_fetch.py new file mode 100644 index 000000000..6e0f47715 --- /dev/null +++ b/src/sp_validation/tests/test_fetch.py @@ -0,0 +1,75 @@ +"""The fetch manifest records every file's hash and checks a checksum list.""" + +import hashlib +import json + +import pytest + +from sp_validation import fetch + + +@pytest.fixture +def release(tmp_path): + product = tmp_path / "v9" / "nz" + product.mkdir(parents=True) + (product / "a.txt").write_text("alpha") + (product / "sub").mkdir() + (product / "sub" / "b.txt").write_text("beta") + (tmp_path / "v9" / "other.txt").write_text("gamma") + lines = [ + f"{hashlib.md5(text.encode()).hexdigest()} ./{name}" + for name, text in [ + ("nz/a.txt", "alpha"), + ("nz/sub/b.txt", "beta"), + ("other.txt", "gamma"), + ] + ] + (tmp_path / "v9" / "MD5SUMS").write_text("\n".join(lines) + "\n") + return tmp_path / "v9" + + +def test_manifest_hashes_every_file(release, tmp_path): + out = tmp_path / "m.json" + fetch.main( + [ + str(release / "nz"), + "--version", + "v9", + "--md5sums", + str(release / "MD5SUMS"), + "--out", + str(out), + ] + ) + record = json.loads(out.read_text()) + assert record["version"] == "v9" + assert record["files"]["sub/b.txt"] == { + "size": 4, + "sha256": hashlib.sha256(b"beta").hexdigest(), + } + assert set(record["files"]) == {"a.txt", "sub/b.txt"} + + +def test_single_file(release): + record = fetch.manifest(str(release / "other.txt"), "v9", str(release / "MD5SUMS")) + assert set(record["files"]) == {"other.txt"} + + +def test_changed_bytes_fail(release): + (release / "nz" / "a.txt").write_text("ALPHA") + with pytest.raises(SystemExit, match="1 differ"): + fetch.manifest(str(release / "nz"), "v9", str(release / "MD5SUMS")) + + +def test_missing_file_fails(release): + (release / "nz" / "sub" / "b.txt").unlink() + with pytest.raises(SystemExit, match="1 missing"): + fetch.manifest(str(release / "nz"), "v9", str(release / "MD5SUMS")) + + +def test_product_beside_its_checksum_list(release): + record = fetch.manifest(str(release), "v9", str(release / "MD5SUMS")) + assert set(record["files"]) >= {"nz/a.txt", "other.txt"} + (release / "other.txt").write_text("GAMMA") + with pytest.raises(SystemExit, match="1 differ"): + fetch.manifest(str(release), "v9", str(release / "MD5SUMS")) diff --git a/src/sp_validation/tests/test_nz_record.py b/src/sp_validation/tests/test_nz_record.py index ec3e0f99a..62dd0dfae 100644 --- a/src/sp_validation/tests/test_nz_record.py +++ b/src/sp_validation/tests/test_nz_record.py @@ -1,10 +1,11 @@ -"""Record integrity of the ``nz`` sub-analysis: its decisions, tags and pins agree. - -Every ``@sc`` decision citation of ``nz`` names a decision the ASTRA record -defines, every decision has a tagged site, every ``Values:`` pin sits in a file -that cites its decision and equals the committed value there, and contract ids -are unique. A pin is ``v2.yaml#dotted.key`` (the n(z) recipe) or -``module.CONSTANT`` (under ``sp_validation``). +"""Record integrity of the ``redshifts`` n(z) decisions: tags and pins agree. + +Every ``@sc`` decision citation of ``redshifts`` names a decision the ASTRA +record defines for ``nz_calibration``, every such decision has a tagged site, +every ``Values:`` pin sits in a file that cites its decision and equals the +committed value there, and contract ids are unique. A pin is +``v2.yaml#dotted.key`` (the n(z) recipe) or ``module.CONSTANT`` (under +``sp_validation``). """ import ast @@ -17,15 +18,23 @@ import yaml ROOT = Path(__file__).resolve().parents[3] -RECORD = ROOT / "scratch/cdaley/unions_astra" +ANALYSIS = "redshifts" RECIPE = "config/calibration/nz/v2.yaml" TAG = re.compile(r"@sc \[([^\]]*)\][ \t]*([\w.-]*)") def read_record(): - project = yaml.safe_load((RECORD / "astra.yaml").read_text()) - path = RECORD / project["analyses"]["nz"]["path"] / "astra.yaml" - return yaml.safe_load(path.read_text())["decisions"] + project = yaml.safe_load((ROOT / "astra.yaml").read_text()) + path = ROOT / project["analyses"][ANALYSIS]["path"] / "astra.yaml" + spec = yaml.safe_load(path.read_text()) + universe = project["universes"]["v2_0_0"]["decisions"] + nz_decisions = [ + d for d in spec["outputs"]["nz_calibration"]["decisions"] if "." not in d + ] + return { + name: {**spec["decisions"][name], "chosen": universe[f"{ANALYSIS}.{name}"]} + for name in nz_decisions + } def read_sites(): @@ -79,8 +88,10 @@ def check(record, sites, recipe): for meta, contract in TAG.findall(text): for item in meta.split(","): key, _, value = item.strip().partition(":") - if key == "decision" and value.startswith("nz."): - cited.setdefault(value.removeprefix("nz."), set()).add(path) + if key == "decision" and value.startswith(f"{ANALYSIS}."): + cited.setdefault(value.removeprefix(f"{ANALYSIS}."), set()).add( + path + ) if contract: contracts.append(contract) assert not set(cited) - set(record), f"undefined: {set(cited) - set(record)}" @@ -88,7 +99,7 @@ def check(record, sites, recipe): repeated = {c for c in contracts if contracts.count(c) > 1} assert not repeated, f"repeated contract ids: {repeated}" for name, decision in record.items(): - assert decision["default"] in decision["options"] + assert decision["chosen"] in decision["options"] for pin, value in pins(decision).items(): assert site(pin) in cited[name], f"{pin}: no {name} tag there" assert committed(pin, recipe) == value, f"{pin} drifted" @@ -123,14 +134,14 @@ def test_detects_record_drift(): def test_detects_a_removed_pinned_site(): sites = read_sites() - tag = "@sc [decision:nz." + "gold_selection]" + tag = f"@sc [decision:{ANALYSIS}." + "gold_selection]" sites[RECIPE] = sites[RECIPE].replace(tag, "") with pytest.raises(AssertionError, match="no gold_selection tag there"): check(read_record(), sites, read_recipe()) def test_detects_an_untagged_decision(): - tag = "@sc [decision:nz." + "grid_step]" + tag = f"@sc [decision:{ANALYSIS}." + "grid_step]" sites = {path: text.replace(tag, "") for path, text in read_sites().items()} with pytest.raises(AssertionError, match="untagged: {'grid_step'}"): check(read_record(), sites, read_recipe()) @@ -138,7 +149,7 @@ def test_detects_an_untagged_decision(): def test_detects_an_undefined_decision(): sites = read_sites() - sites["extra.py"] = "# @sc [decision:nz." + "unrecorded]\n" + sites["extra.py"] = f"# @sc [decision:{ANALYSIS}." + "unrecorded]\n" with pytest.raises(AssertionError, match="undefined: {'unrecorded'}"): check(read_record(), sites, read_recipe()) diff --git a/workflow/scripts/footprint_masks.py b/workflow/scripts/footprint_masks.py new file mode 100644 index 000000000..83d673a43 --- /dev/null +++ b/workflow/scripts/footprint_masks.py @@ -0,0 +1,52 @@ +"""Occupied-pixel footprints of the calibrated sample (HEALPix nside 4096, RING, uint8). + +usage: footprint_masks.py + +Writes full.fits, the pixels holding any galaxy of the sample, and tomo.fits, the +pixels holding any galaxy on a tile that has at least one galaxy in bins 1-4 +(TOM_BIN_ID > 0), so a tile without usable photometry leaves the tomographic +footprint whole. +""" + +import glob +import sys +from concurrent.futures import ThreadPoolExecutor + +import healpy as hp +import numpy as np +import pyarrow.parquet as pq + +NSIDE = 4096 + + +def read(path, ra, dec): + t = pq.read_table(path, columns=[ra, dec, "TOM_BIN_ID", "TILE_ID"]) + pix = hp.ang2pix(NSIDE, t[ra].to_numpy(), t[dec].to_numpy(), lonlat=True) + return pix, t["TOM_BIN_ID"].to_numpy(), t["TILE_ID"].to_numpy() + + +def write(path, pixels, sample): + m = np.zeros(hp.nside2npix(NSIDE), np.uint8) + m[pixels] = 1 + header = [("MASKTYPE", "OCCUPIED")] + ([("SAMPLE", sample)] if sample else []) + hp.write_map( + path, m, dtype=np.uint8, overwrite=True, nest=False, extra_header=header + ) + area = m.sum() * hp.nside2pixarea(NSIDE, degrees=True) + print(f"{path}: {int(m.sum())} pixels, {area:.1f} deg2") + + +def main(catalogue, out): + files = sorted(glob.glob(f"{catalogue}/dataset/**/*.parquet", recursive=True)) + schema = pq.read_schema(files[0]).names + dec = "Dec" if "Dec" in schema else "DEC" + with ThreadPoolExecutor(32) as pool: + parts = list(pool.map(lambda f: read(f, "RA", dec), files)) + pix, tom_bin, tile = (np.concatenate([p[i] for p in parts]) for i in range(3)) + write(f"{out}/full.fits", pix, None) + binned_tiles = np.isin(tile, np.unique(tile[tom_bin > 0])) + write(f"{out}/tomo.fits", pix[binned_tiles], "TOM_BIN_ID>0 tiles") + + +if __name__ == "__main__": + main(*sys.argv[1:3])