Skip to content

Add stages to compute and plot Delta Sigma - #428

Open
joezuntz wants to merge 79 commits into
masterfrom
delta-sigma
Open

Add stages to compute and plot Delta Sigma#428
joezuntz wants to merge 79 commits into
masterfrom
delta-sigma

Conversation

@joezuntz

@joezuntz joezuntz commented Nov 7, 2025

Copy link
Copy Markdown
Collaborator

Someone who knows more about this area should check what I have done here!

@joezuntz
joezuntz marked this pull request as ready for review July 14, 2026 12:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces new pipeline stages and utilities to ingest DESI/Flagship inputs, build joint masks, compute Delta-Sigma (excess surface density) using dsigma, generate a corresponding theory curve (via dsf), and plot the results, integrating these stages into example pipelines.

Changes:

  • Added TXDeltaSigma, TXDeltaSigmaTheory, and TXDeltaSigmaPlots stages plus example pipeline/config wiring.
  • Added DESI ingestion/selection stages and new mask/catalog-cutting helpers to support DESI + shear joint analyses.
  • Centralized SACC metadata/provenance writing (SACCFile.add_metadata) and adjusted SACC loading behavior.

Reviewed changes

Copilot reviewed 20 out of 22 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
txpipe/utils/conversion.py Adds photometry conversion/SNR helper utilities used by new ingestion.
txpipe/twopoint.py Uses centralized SACC metadata writer; replaces sys.exit with exceptions.
txpipe/source_selection/simple.py Adjusts band-variant selection catalog type for “simple” shear catalogs.
txpipe/source_selection/base.py Removes an unused/required input tag from the source selector base stage.
txpipe/random_cats.py Updates depth-map pixelization handling; adds an nside consistency check.
txpipe/masks.py Adds joint-mask stage(s) and catalog footprint cutting stages.
txpipe/lens_selector.py Adds DESI selector stages (FITS + Parquet mocks + multi-mock globbing).
txpipe/ingest/flagship_mocks.py Adds Flagship mock shear catalog + mask ingestion stages for DESI mock workflows.
txpipe/ingest/dp1.py Adds a TXIngestDataPreview2 alias stage.
txpipe/ingest/desi.py Adds DESI ingest stages for selected DESI catalogs and DESI randoms.
txpipe/ingest/init.py Exposes new ingest stages via package imports.
txpipe/delta_sigma.py Implements Delta-Sigma measurement, theory generation, and plotting stages.
txpipe/data_types.py Adds SACCFile.add_metadata; switches SACC read path to sacc.Sacc.load.
txpipe/init.py Exposes new stages at top-level import.
examples/metadetect/pipeline.yml Wires Delta-Sigma stages into the metadetect example pipeline.
examples/metadetect/config.yml YAML boolean normalization for TXShearCalibration.
examples/desi_mocks/pipeline.yml New example pipeline for DESI mocks + Delta-Sigma flow.
examples/desi_mocks/config.yml New config for DESI mocks pipeline (selection, ingest, Delta-Sigma).
examples/desi_dr1_stage3/pipeline.yml New example pipeline wiring for DESI DR1 stage-3 + Delta-Sigma.
examples/desi_dr1_stage3/config.yml New config for DESI DR1 stage-3 example.
bin/environment-perlmutter.yml Bumps healsparse/sacc; adds dsigma and dsf dependency sources.
bin/environment-local.yml Bumps healsparse/sacc; adds dsigma and dsf dependency sources.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread txpipe/random_cats.py Outdated
Comment thread txpipe/masks.py
Comment thread txpipe/masks.py
Comment thread txpipe/lens_selector.py
Comment thread txpipe/lens_selector.py
Comment thread txpipe/delta_sigma.py Outdated
Comment thread txpipe/delta_sigma.py Outdated
Comment thread txpipe/delta_sigma.py
Comment thread txpipe/delta_sigma.py Outdated
Comment thread txpipe/delta_sigma.py
@myamamoto26

Copy link
Copy Markdown
Collaborator

I commented in some of the copilot reviews, but I think you've addressed most of them in later pushes. So I think it all looks ok now?

@myamamoto26 myamamoto26 self-assigned this Jul 22, 2026

@empEvil empEvil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great, but there are a lot of todo's that we might want to address first

Comment thread txpipe/ingest/desi.py
("lens_photoz_stack", QPNOfZFile),
]

# TODO: CHANGE CONFIG OPTIONS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this still a TODO?

Comment thread txpipe/ingest/desi.py
zbin = np.digitize(z, zbin_edges) - 1
zbin[zbin == nbin_lens] = -1

# # can select on any other criterion here, e.g.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this for the future?

Comment thread txpipe/delta_sigma.py

# Add columns to two tables in-place to do most of the pre-computation work.
# We should look at using the n_jobs multiprocessing option here
# but I don't know if it will play well with MPI on NERSC that we are

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Has this been tested yet?

Comment thread txpipe/delta_sigma.py

def load_source_table(self, bin_index):
"""
Load the lens table for a given bin index

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lens or source table?

Comment thread txpipe/delta_sigma.py

print("CCL Cosmology:", cosmo)

# TODO expose these as config options

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this be fixed?

Comment thread txpipe/delta_sigma.py
x = sacc_data.get_tag("rp", tracers=(f"source_{s}", f"lens_{l}"))
x = np.array(x)
y = sacc_data.get_mean(tracers=(f"source_{s}", f"lens_{l}"))
# raw_y = sacc_data.get_tag("raw_value", tracers=(f"source_{s}", f"lens_{l}"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if not used can we delete?

Comment thread txpipe/delta_sigma.py
axes[l, 0].errorbar(
x * shift[s], y * x, yerr=error * x, fmt="+", label=rf"$\Delta\Sigma$ s={s}"
)
# Also plot the raw value with boost/randoms

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also here, and below

Comment thread txpipe/lens_selector.py
Select lens galaxies from a DESI spectroscopic FITS catalog.

Reads a raw DESI FITS catalog and applies:
TODO: ADJUST NECESSARY CUTS FOR REAL DATA

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will this be part of this PR or a subsequent one?

Comment thread txpipe/lens_selector.py
with self.open_input("mask", wrapper=True) as f:
self.mask = f.read_mask("mask")
self.mask_nside = f.read_map_info("mask")["nside"]
# self.mask_fmt = f.read_map_info("mask")["nest"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we are not using lets remove this?

Comment thread txpipe/lens_selector.py
start = end


class TXDESIMultiMockSelector(TXDESIMockSelector):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does this class do?

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.

4 participants