Skip to content

Implementation of reduced shear in source selection for clusters#398

Merged
eduardojsbarroso merged 14 commits into
masterfrom
clusters_source_selection
Jun 5, 2026
Merged

Implementation of reduced shear in source selection for clusters#398
eduardojsbarroso merged 14 commits into
masterfrom
clusters_source_selection

Conversation

@eduardojsbarroso

Copy link
Copy Markdown
Contributor

So far, the cluster code only measures Delta Sigma from the select source galaxies around a cluster. We need to implement the same for gamma and we are also interested in using N(z) to select the galaxies behind the cluster instead of redshift PDF or zmode or zmean.

@eduardojsbarroso

Copy link
Copy Markdown
Contributor Author

In this code. We set a maximum radius of search for galaxies around a cluster. Given the cluster redshift and a fiducial cosmology, we can transform this distance into an angle that changes for each cluster given their redshift.

If I do not want to assume any fiducial cosmology and search the galaxies by angle directly, should I use the same search angle for all clusters? Or is there some other approach to reescale this distance with redshift without using cosmology? @marina-ricci @joezuntz

@joezuntz

joezuntz commented Aug 1, 2025

Copy link
Copy Markdown
Collaborator

There's definitely no way to convert a distance to an angle without knowing the cosmology. So I guess you would have to use the same angle, and make sure it's large enough. Why don't you want to use a fiducial cosmology? It shouldn't have a significant impact on the results at this level.

@eduardojsbarroso

eduardojsbarroso commented Aug 4, 2025

Copy link
Copy Markdown
Contributor Author

There's definitely no way to convert a distance to an angle without knowing the cosmology. So I guess you would have to use the same angle, and make sure it's large enough. Why don't you want to use a fiducial cosmology? It shouldn't have a significant impact on the results at this level.

Thank you for the reply Joe. I just wanted to know if there was any other way around it since we do not need the cosmology for the tangential signal. But ok, then I think I will leave this untouched and maybe add an option to use a constant angle if wanted

@marina-ricci

marina-ricci commented Sep 22, 2025

Copy link
Copy Markdown
Contributor

@eduardojsbarroso for this special case I don't think it is a problem. Indeed we can use a fiducial cosmology just to define theta_max, it doesn't (should't) interfer with the "scientific" measurements. And even having radial binning in Mpc is not as much of a problem as having e.g. sigma_crit.

@marina-ricci

Copy link
Copy Markdown
Contributor

Also, note for ourselves : we should through an error message when our binning is larger than the search radius (in case it's not hapening already)

@marina-ricci

marina-ricci commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

We decided it makes no sense to implement the N(z) method in source_compute_select, as it will be done more cleanly with the NG correlation.

@eduardojsbarroso eduardojsbarroso changed the title Implementation of reduced shear and N(z) in source selection for clusters Implementation of reduced shear in source selection for clusters Sep 26, 2025
@eduardojsbarroso

Copy link
Copy Markdown
Contributor Author

@marina-ricci I have cleaned the option of Nz, as as discussed with @combet, we can implement this in another pull request, and a third one for the treecor option. Could you take a look at the code and check what you think?

@eduardojsbarroso

eduardojsbarroso commented Sep 26, 2025

Copy link
Copy Markdown
Contributor Author

Also, note for ourselves : we should through an error message when our binning is larger than the search radius (in case it's not hapening already)

I think this is already done in the make_ensemble_profile.py

            cat_max_distance = (clmm.utils.convert_units(np.max(bg_cat["distance_arcmin"]), "arcmin", "Mpc", z_cl, self.clmm_cosmo) if shear_units == "mpc" else np.max(bg_cat["distance_arcmin"]))
            if cat_max_distance < self.distance_bins[-1]:
                print ("!!! maximum distance of source smaller than distance_bins")

@eduardojsbarroso
eduardojsbarroso marked this pull request as ready for review September 26, 2025 14:35
@eduardojsbarroso
eduardojsbarroso marked this pull request as draft September 29, 2025 09:10
@eduardojsbarroso
eduardojsbarroso marked this pull request as ready for review October 2, 2025 15:07
@eduardojsbarroso

Copy link
Copy Markdown
Contributor Author

@marina-ricci I added a pipeline file to test this new functionalities and a notebook if you want to explore the results. Everything seems into place for me

@joezuntz joezuntz 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.

In general I don't know enough to comment on the clusters code, so I will just review to make sure that things look structurally correct and don't cause any issues with the wider code.

This looks fine from that perspective, though I've added a note about a change you'll need to make because of other changes in the rest of the imports. I'm happy for you to merge it whenever the CL people are happy!

name: mini
interval: 3.0
modules: >
txpipe

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.

You will need to add txpipe.extensions here because of changes in the structuring of the code.

nzbins: 301
columns_file: ./data/bpz_riz.columns
data_path: ./data/example/rail-bpz-inputs
columns_file: /sps/lsst/groups/clusters/cl_pipeline_project/TXPipe_data/bpz_riz.columns

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.

Maybe avoid hard-coded paths (this is for cc-in2p3 only) so users may more easily use the examples. Or at least add a comment to explain how they should change it to match their setup.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed


output_dir: ./data/cosmodc2/outputs-20deg2-CL
config: ./examples/cosmodc2/Cluster_pipelines/config-20deg2-CL.yml
output_dir: /sps/lsst/users/ebarroso/TXPipe/data/cosmodc2/outputs-20deg2-CL

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.

Same as above regarding path

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

"r_min" : 0.2, #in Mpc
"r_max" : 5.0, #in Mpc
#distance bin definition
"d_min" : 0.5, #in Mpc or acrmin

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.

To me, r_min and r_max is more intuitive than d_min, d_max. And 'radial bin' is more used I think, even when thinking of angular separation. Just a suggestion.

radius_edges = np.logspace(np.log10(rmin), np.log10(rmax), len(radius_centers) + 1)
for i in range(len(radius_edges) - 1):
bin_radius_dict[f'radius_{i}'] = (radius_edges[i], radius_edges[i+1], radius_centers[i])
distance_centers = np.array(data['bin_zbin_0_richbin_0']['clmm_cluster_ensemble'].stacked_data['radius'])

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.

Similar comment as above. distance_centers is a bit cryptic. Maybe radial_bin_centers instead, or something along those lines?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed to radial_bins_centers, Also changed in the file dmin to rmin, and so on.

def add_deltasigma_data(self, sacc_obj, data: dict, survey_name: str):
def add_shear_data(self, sacc_obj, data: dict, survey_name: str, profile_type: str):
"""
Adds cluster shear (delta sigma) data to the SACC object.

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.

Adds cluster reduced shear or delta sigma (depending on profile_type) profile to the SACC object.

self.radial_bins = clmm.dataops.make_bins(self.config["r_min"], self.config["r_max"], nbins=self.config["nbins"], method="evenlog10width")
print (self.radial_bins)
import clmm.cosmology.ccl
if self.config["units"].lower() == "arcmin":

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.

I find it a bit counter-intuitive to have a units keywords decide the type of radial binning (angular or in physical distance). Maybe there should be another keyword radial_bin_type (e.g. 'radius' or 'angle' ) or something like this to control it?

Good to keep the units information though, maybe to save it later as metadata in the sacc file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I checked this part of the code. I decided that r_min is for radial bin, thus I dont need to add radial_bin_type, because I use the units on the ClusterEnsemble only and this gives me the profile.

The profile type information is needed only in the individual computation. Now we just need:
radial bin max, radial bin min, and units. And clmm does everything automatic. It is just taking the min, max and divide in n bins. And then when stacking, giving these bins + units measure.

I think the radial bin info is not needed in the ensemble, but on the individual only.


if (clmm.utils.convert_units(np.max(bg_cat["distance_arcmin"]), 'arcmin', 'Mpc', z_cl, self.clmm_cosmo)< self.radial_bins[-1]):
print ("!!! maximum radial distance of source smaller than radial_bins")
cat_max_distance = (clmm.utils.convert_units(np.max(bg_cat["distance_arcmin"]), "arcmin", "Mpc", z_cl, self.clmm_cosmo) if shear_units == "mpc" else np.max(bg_cat["distance_arcmin"]))

@combet combet Feb 6, 2026

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.

Need to find another name for shear_units. "shear" in this code is either dimensionless or surface mass density if working with DeltaSigma.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will change this to bin_units, like done in clmm and do the same in the configs.

gc_object.make_radial_profile(
"Mpc",
bins=self.radial_bins,
shear_units,

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.

Same as above

@eduardojsbarroso
eduardojsbarroso force-pushed the clusters_source_selection branch from 72f8348 to 3d06d20 Compare June 4, 2026 14:04
@eduardojsbarroso
eduardojsbarroso merged commit e93ea91 into master Jun 5, 2026
26 checks passed
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