sp_validation.cosmo_val.real_space¶
Real-space two-point diagnostics for cosmology validation.
This mixin holds the real-space machinery: the TreeCorr two-point correlation function (2PCF) ξ± measurement, the aperture-mass dispersion ⟨M_ap²⟩ measurement, and the per-bin-pair plots of both. It depends on TreeCorr.
- class RealSpaceMixin[source]¶
Bases:
object- calculate_2pcf_version(ver, npatch=None, compute_tomography=False, *, grid='reporting', out=None, **treecorr_config)[source]¶
ξ± of one catalogue version on one binning, for each bin pair.
The non-tomographic
("all", "all")pair is born as its SACC part, sealed under the version’s blind (sp_validation.sacc_io.seal()) before it is kept inself.xi_parts[ver, grid], returned or written, so on a blinded catalogue its true values never leave this method. A part already held for(ver, grid)is reused when nonpatch, binning oroutis asked for, so the figure rules draw the parts they are handed. Tomographic pairs are measured only on a public catalogue (_refuse_blinded_tomography()). Usecalculate_2pcf()to run over every version inself.versions.- Parameters:
ver (str) – The catalogue version to measure.
npatch (int, optional) – Jackknife patches; the instance’s
npatchby default. With patches the part carries the jackknife covariance, without them the shot-noise diagonal. Seeded patch centres come from the full catalogue and are shared by every bin pair.compute_tomography (bool, optional) – Measure the tomographic bin pairs instead of
("all", "all").grid (str) – The grid tag the part’s points carry.
out (str, optional) – Where to write the part as well.
**treecorr_config – Overrides of the instance’s
treecorr_config, e.g.min_sep=1.
- Returns:
"tomo_bin_{b1}_tomo_bin_{b2}"→ ξ± shaped like a TreeCorrGGCorrelation: the part’sxi_correlation()view for("all", "all"), the TreeCorr object for a tomographic pair.- Return type:
- _shear_columns(ver, compute_tomography)[source]¶
Positions, calibrated shears, weights and bin labels of a version.
All arrays come from the same rows of the version’s shear catalogue, as read by
self.results[ver]. The bin labels areNoneunlesscompute_tomography.
- _bin_catalog(cols, tomo_bin_id, npatch, patch_centers=None)[source]¶
TreeCorr catalogue of one tomographic bin (
"all": every row).
- calculate_2pcf(npatch=None, compute_tomography=False, **treecorr_config)[source]¶
Calculate the 2PCF ξ± for every catalog version in
self.versions.Parent function that iterates over
self.versionsand delegates the per-version computation tocalculate_2pcf_version(). Results are stored inself.cat_ggskeyed by version.- Parameters:
npatch (int, optional) – Number of patches to use; defaults to the
attribute. (instance's npatch)
compute_tomography (bool, optional) – Whether to compute tomographic
False. (correlations. Defaults to)
**treecorr_config – Additional TreeCorr configuration parameters passed
call. (through to each per-version)
- Returns:
self.cat_ggs, mapping each version to its{"tomo_bin_{b1}_tomo_bin_{b2}": ξ±}dict.- Return type:
- calculate_aperture_mass_dispersion(theta_min=0.3, theta_max=200, nbins=500, nbins_map=15, npatch=None, compute_tomography=False)[source]¶
⟨M_ap²⟩ and ⟨M_ײ⟩ of every version and bin pair, from its ξ±.
Both are linear in ξ± (TreeCorr’s
calculateMapSqsum, Schneider et al. 2002 filter), so they and their covariance T·C·Tᵀ come from the ξ± ofcalculate_2pcf_version()on a fine grid: for("all", "all")its sealed part, concealed on a blinded catalogue, whose shift, the same in every patch, leaves C unchanged.
- property map2¶
- plot_2pcf(tomography=False, offset=0.02, alpha=1.0, show=True, close=True)[source]¶
Plot ξ± of every version, one panel per bin pair.
Measures, or reads back, the 2PCF with
calculate_2pcf()and draws it withplot_2pcf_tomography(), as ξ± (log-log) and as θ·ξ±. Writesxi_pm_tomography_{tomography}.pngandxi_pm_theta_tomography_{tomography}.pngunder the output directory.
- plot_ratio_xi_sys_xi(tomography=False, threshold=0.1, offset=0.02, show=True, close=True)[source]¶
Plot ξ^{PSF, sys}_± / ξ± of every version, one panel per bin pair.
The band marks
±threshold. ξ± comes fromcalculate_2pcf()and ξ^{PSF, sys} from thexi_psf_sysproperty, both on the instance’streecorr_configbinning. Writesratio_xi_sys_xi.png(non- tomographic) orratio_xi_sys_xi_tomography.pngunder the output directory.
- plot_2pcf_tomography(x_y_plot_function, x_label, y_label_plus, y_label_minus, tomo_bin_label_position, extract_text_offset, add_index_version_to_kwargs, x_scale=None, y_scale=None, tomography=False, versions=None, colors=None, savefig=None, show=True, close=True, **kwargs)[source]¶
Standard plot function for 2-point correlation functions with tomographic bins.
- Parameters:
x_y_plot_function (callable) – Function to plot the x and y data. Should accept axes for `+’ and `-’ components, version, tomo_bin_indices, and kwargs.
x_label (str) – Label for the x-axis.
y_label_plus (str) – Label for the y-axis of the `+’ component.
y_label_minus (str) – Label for the y-axis of the `-’ component.
tomo_bin_label_position (tuple) – Position to place the tomographic bin labels in axes coordinates (x, y).
extract_text_offset (bool) – If True, extract the y-axis offset text and include it in the y-label.
add_index_version_to_kwargs (bool) – If True, add the index of the version to the kwargs for plotting.
x_scale (str, optional) – Scale for the x-axis (‘linear’, ‘log’, etc.). If None, default scale is used.
y_scale (str, optional) – Scale for the y-axis (‘linear’, ‘log’, etc.). If None, default scale is used.
tomography (bool, optional) – If True, plot the tomographic bins. Default is False.
versions (list, optional) – List of versions to plot. If None, all versions are plotted.
colors (list, optional) – List of colors for each version. If None, default colors are used.
savefig (str, optional) – If provided, save the figure to this file.
show (bool, optional) – If True, show the figure.
close (bool, optional) – If True, close the figure after saving or showing.
kwargs (dict) – Additional keyword arguments to pass to the plotting function.
- _xiplus_ximinus_sample_x_y_plot_function(ax_plus, ax_minus, version, tomo_bin_a, tomo_bin_b, idx, versions, color, offset, times_theta, alpha)[source]¶
Plot the measured ξ± 2PCF for one version/tomographic-bin pair.
Uses the jackknife covariance from TreeCorr to plot the error bars. This function is fed into
plot_2pcf_tomography()as thex_y_plot_functionargument.- Parameters:
ax_plus (matplotlib.axes.Axes) – Axes for the ξ+ and ξ- components.
ax_minus (matplotlib.axes.Axes) – Axes for the ξ+ and ξ- components.
version (str) – Catalog version to plot.
tomo_bin_a (int or str) – Tomographic bin pair (
"all"for the non-tomographic case).tomo_bin_b (int or str) – Tomographic bin pair (
"all"for the non-tomographic case).idx (int) – Index of
versionwithinversions(used for the x-jitter).versions (list) – Full list of versions being plotted.
color (str) – Colour for this version.
offset (float) – Fractional jitter applied to θ for readability.
times_theta (bool) – If True, plot θ·ξ± rather than ξ±.
alpha (float) – Opacity of the plotted points/error bars.
- _mapsq_mxsq_sample_x_y_plot_function(ax_plus, ax_minus, version, tomo_bin_a, tomo_bin_b, idx, versions, color, offset, times_theta, alpha)[source]¶
Plot the aperture-mass dispersion ⟨M_ap²⟩ / ⟨M_ײ⟩ for one bin pair.
Uses the jackknife covariance from TreeCorr to plot the error bars. This function is fed into
plot_2pcf_tomography()as thex_y_plot_functionargument. The E-mode ⟨M_ap²⟩ is placed on theplusaxis and the B-mode ⟨M_ײ⟩ on theminusaxis.- Parameters:
ax_plus (matplotlib.axes.Axes) – Axes for the E-mode (⟨M_ap²⟩) and B-mode (⟨M_ײ⟩) components.
ax_minus (matplotlib.axes.Axes) – Axes for the E-mode (⟨M_ap²⟩) and B-mode (⟨M_ײ⟩) components.
version (str) – Catalog version to plot.
tomo_bin_a (int or str) – Tomographic bin pair (
"all"for the non-tomographic case).tomo_bin_b (int or str) – Tomographic bin pair (
"all"for the non-tomographic case).idx (int) – Index of
versionwithinversions(used for the x-jitter).versions (list) – Full list of versions being plotted.
color (str) – Colour for this version.
offset (float) – Fractional jitter applied to θ for readability.
times_theta (bool) – If True, plot θ·⟨M²⟩ rather than ⟨M²⟩.
alpha (float) – Opacity of the plotted points/error bars.
- _ratio_xi_sys_xi_x_y_plot_function(ax_plus, ax_minus, version, tomo_bin_a, tomo_bin_b, idx, versions, color, offset, threshold)[source]¶
Plot ξ^{PSF, sys}_± / ξ± for one version/tomographic-bin pair.
Fed into
plot_2pcf_tomography()as thex_y_plot_functionargument. The error bar propagates the variances of both ξ^{PSF, sys} and ξ±; the first version also draws the±thresholdband.