Skip to content

Photoz catalogue handling - #409

Open
martinkilbinger wants to merge 19 commits into
developfrom
photoz
Open

martinkilbinger wants to merge 19 commits into
developfrom
photoz

Conversation

@martinkilbinger

@martinkilbinger martinkilbinger commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

This PR handles the reading of GaaP photometry and photo-z catalogues, and their merging with ShapePipe catalogues. The code corresponds to v1.X formats, not yet v2.0 compatible. It is used to create the joint ShapePipe+ PhotoPipe v1.6.y catalogues for current tomographic studies.

It includes the special handling of the two z-band masks.

martinkilbinger and others added 19 commits February 25, 2026 16:23
Merge 6ec03ae committed scripts/fill_photoz_bands.py and
scripts/check_filled_fields.py with their conflict markers still in place,
so neither file could be imported or run.

Both were added independently on the two sides, which is why git conflicted
the whole file. Upstream's version is a superset: it adds the per-tile
row-order check (check_tile_row_order, n_check_rows, check_tol_arcsec,
FITS_RADEC_CANDIDATES) and the Z_ML key, and differs otherwise only in
formatting. Taken as-is, with the one local change upstream lacks
re-applied: reading TILE_ID with dset.fields() so the scan chunk holds one
column instead of all of them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013NzWDtdQbsK1VhvYbDnmTo
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

🤖 autofix pushed b2208d4, ruff is clean — formatting and safe lint fixes were applied for you; nothing else to do.

@martinkilbinger martinkilbinger self-assigned this Oct 8, 2026

@cailmdaley cailmdaley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice progress, Martin. The two-band z coverage logic (measured_z & covered_z) | (measured_z2 & covered_z2) looks right. A few integration snags turned up while tracing the v1.X path, flagged inline; none of them are a verdict on the approach:

  • the PSF-size export column (one-word fix)
  • binned_mask needs output_path for the calibration script
  • footprint_only mode in masking.py can't evaluate the new composite cut yet, and that needs a decision about what "footprint" means there

One pointer for later, not for this PR: v2 support probably lives mostly in the enrichment I/O. fill_photoz_bands.py currently pairs PhotoPipe and ShapePipe rows by their order within each tile, so a reliable row-matching rule is the main thing to settle.

— Claude on behalf of Cail

"MAGERR_AUTO",
"NGMIX_T_NOSHEAR",
"NGMIX_T_PSF_RECONV_NOSHEAR",
"NGMIX_Tpsf_NOSHEAR",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read_cat() already maps v1 catalogues onto the canonical names (through grammar), and it hides NGMIX_Tpsf_NOSHEAR in the process. So this lookup raises KeyError even on v1.6 inputs. The canonical column also carries the adapter's NGMIX_Tpsf_1P correction, so it's the one we want anyway:

Suggested change
"NGMIX_Tpsf_NOSHEAR",
"NGMIX_T_PSF_RECONV_NOSHEAR",

(The first_present() fallback in fill_cat_gal() then isn't needed for this.)

good: False

# Output file path base
output_base: "footprint_binned"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this section present, calibrate_comprehensive_cat.py reads cbm["output_path"] (line 170), so it'll KeyError before writing anything. output_base is what create_binned_mask_comprehensive.py reads, so keeping both is the smallest fix:

Suggested change
output_base: "footprint_binned"
output_base: "footprint_binned"
output_path: "footprint_binned_8192.fits"

mag_col: MAG_GAAP_0p7_z
mag_col2: MAG_GAAP_0p7_z2
label: "z-band imaging"
kind: covered_2bands

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MASK_256_z is in SPATIAL_CUTS in scripts/masking.py, so with footprint_only=True this cut gets sent to apply_condition(), which only handles single-column cuts. The result is ValueError: Unknown mask condition kind: 'covered_2bands'.

It's worth deciding what footprint-only should mean for this cut. One option reproduces the catalogue selection, magnitude checks included. The other is purely geometric: the union of the two imaging footprints, with bad = bad_z & bad_z2. demo_create_footprint_mask.py has the same gap, since it ignores col_name2.

@martinkilbinger

Copy link
Copy Markdown
Contributor Author

Nice progress, Martin.

image

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants