clevar.match_metrics.recovery.funcs module

@file clevar/match_metrics/recovery/funcs.py

Main recovery functions for mass and redshift plots, wrapper of catalog_funcs functions

clevar.match_metrics.recovery.funcs.plot(cat, matching_type, redshift_bins, mass_bins, transpose=False, log_mass=True, redshift_label=None, mass_label=None, recovery_label=None, p_m1_m2=None, min_mass2=1, max_mass2=None, min_mass2_norm=None, **kwargs)[source]

Plot recovery rate as lines, with each line binned by redshift inside a mass bin.

Parameters
  • cat (clevar.ClCatalog) – ClCatalog with matching information

  • matching_type (str) – Type of matching to be considered. Must be in: ‘cross’, ‘cat1’, ‘cat2’, ‘multi_cat1’, ‘multi_cat2’, ‘multi_join’

  • redshift_bins (array, int) – Bins for redshift

  • mass_bins (array, int) – Bins for mass

  • transpose (bool) – Transpose mass and redshift in plots

  • log_mass (bool) – Plot mass in log scale

  • mask (array) – Mask of unwanted clusters

  • mask_unmatched (array) – Mask of unwanted unmatched clusters (ex: out of footprint)

  • p_m1_m2 (function) – P(M1|M2) - Probability of having a catalog 1 cluster with mass M1 given a catalog 2 cluster with mass M2. If provided, computes the intrinsic completeness.

  • min_mass2 (float) – Threshold mass for intrinsic completeness computation.

  • max_mass2 (float) – Maximum mass2 for integration. If none, estimated from p_m1_m2.

  • min_mass2_norm (float) – Minimum mass2 to be used in normalization integral. If none, estimated from p_m1_m2.

  • shape (str) – Shape of the lines. Can be steps or line.

  • mass_label (str) – Label for mass.

  • redshift_label (str) – Label for redshift.

  • recovery_label (str) – Label for recovery rate.

  • ax (matplotlib.axes) – Ax to add plot

  • plt_kwargs (dict, None) – Additional arguments for pylab.plot. It also includes the possibility of smoothening the line with n_increase, scheme arguments. See clevar.utils.smooth_line for details.

  • lines_kwargs_list (list, None) – List of additional arguments for plotting each line (using pylab.plot). Must have same size as len(bins2)-1

  • add_legend (bool) – Add legend of bins

  • legend_format (function) – Function to format the values of the bins in legend

  • legend_fmt (str) – Format the values of binedges (ex: ‘.2f’)

  • legend_kwargs (dict, None) – Additional arguments for pylab.legend

Returns

info

Information of data in the plots, it contains the sections:

  • ax: ax used in the plot.

  • data: Binned data used in the plot. It has the sections:

    • recovery: Recovery rate binned with (bin1, bin2). bins where no cluster was found have nan value.

    • edges1: The bin edges along the first dimension.

    • edges2: The bin edges along the second dimension.

    • counts: Counts of all clusters in bins.

    • matched: Counts of matched clusters in bins.

Return type

dict

clevar.match_metrics.recovery.funcs.plot2D(cat, matching_type, redshift_bins, mass_bins, transpose=False, log_mass=True, redshift_label=None, mass_label=None, recovery_label=None, **kwargs)[source]

Plot recovery rate as in 2D (redshift, mass) bins.

Parameters
  • cat (clevar.ClCatalog) – ClCatalog with matching information

  • matching_type (str) – Type of matching to be considered. Must be in: ‘cross’, ‘cat1’, ‘cat2’, ‘multi_cat1’, ‘multi_cat2’, ‘multi_join’

  • redshift_bins (array, int) – Bins for redshift

  • mass_bins (array, int) – Bins for mass

  • transpose (bool) – Transpose mass and redshift in plots

  • log_mass (bool) – Plot mass in log scale

  • mask (array) – Mask of unwanted clusters

  • mask_unmatched (array) – Mask of unwanted unmatched clusters (ex: out of footprint)

  • mass_label (str) – Label for mass.

  • redshift_label (str) – Label for redshift.

  • recovery_label (str) – Label for recovery rate.

  • plt_kwargs (dict, None) – Additional arguments for pylab.pcolor.

  • add_cb (bool) – Plot colorbar

  • cb_kwargs (dict, None) – Colorbar arguments

  • add_num (int) – Add numbers in each bin

  • num_kwargs (dict, None) – Arguments for number plot (used in plt.text)

Returns

info

Information of data in the plots, it contains the sections:

  • ax: ax used in the plot.

  • cb (optional): colorbar.

  • data: Binned data used in the plot. It has the sections:

    • recovery: Recovery rate binned with (bin1, bin2). bins where no cluster was found have nan value.

    • edges1: The bin edges along the first dimension.

    • edges2: The bin edges along the second dimension.

    • counts: Counts of all clusters in bins.

    • matched: Counts of matched clusters in bins.

Return type

dict

clevar.match_metrics.recovery.funcs.plot_panel(cat, matching_type, redshift_bins, mass_bins, transpose=False, log_mass=True, redshift_label=None, mass_label=None, recovery_label=None, p_m1_m2=None, min_mass2=1, max_mass2=None, min_mass2_norm=None, **kwargs)[source]

Plot recovery rate as lines in panels, with each line binned by redshift and each panel is based on the data inside a mass bin.

Parameters
  • cat (clevar.ClCatalog) – ClCatalog with matching information

  • matching_type (str) – Type of matching to be considered. Must be in: ‘cross’, ‘cat1’, ‘cat2’, ‘multi_cat1’, ‘multi_cat2’, ‘multi_join’

  • redshift_bins (array, int) – Bins for redshift

  • mass_bins (array, int) – Bins for mass

  • transpose (bool) – Transpose mass and redshift in plots

  • log_mass (bool) – Plot mass in log scale

  • mask (array) – Mask of unwanted clusters

  • mask_unmatched (array) – Mask of unwanted unmatched clusters (ex: out of footprint)

  • shape (str) – Shape of the lines. Can be steps or line.

  • mass_label (str) – Label for mass.

  • redshift_label (str) – Label for redshift.

  • recovery_label (str) – Label for recovery rate.

  • ax (matplotlib.axes) – Ax to add plot

  • plt_kwargs (dict, None) – Additional arguments for pylab.plot. It also includes the possibility of smoothening the line with n_increase, scheme arguments. See clevar.utils.smooth_line for details.

  • panel_kwargs_list (list, None) – List of additional arguments for plotting each panel (using pylab.plot). Must have same size as len(bins2)-1

  • fig_kwargs (dict, None) – Additional arguments for plt.subplots

  • add_label (bool) – Add bin label to panel

  • label_format (function) – Function to format the values of the bins

  • label_fmt (str) – Format the values of binedges (ex: ‘.2f’)

  • p_m1_m2 (function) – P(M1|M2) - Probability of having a catalog 1 cluster with mass M1 given a catalog 2 cluster with mass M2. If provided, computes the intrinsic completeness.

  • min_mass2 (float) – Threshold mass for intrinsic completeness computation.

  • max_mass2 (float) – Maximum mass2 for integration. If none, estimated from p_m1_m2.

  • min_mass2_norm (float) – Minimum mass2 to be used in normalization integral. If none, estimated from p_m1_m2.

Returns

info

Information of data in the plots, it contains the sections:

  • fig: matplotlib.figure.Figure object.

  • axes: matplotlib.axes used in the plot.

  • data: Binned data used in the plot. It has the sections:

    • recovery: Recovery rate binned with (bin1, bin2). bins where no cluster was found have nan value.

    • edges1: The bin edges along the first dimension.

    • edges2: The bin edges along the second dimension.

    • counts: Counts of all clusters in bins.

    • matched: Counts of matched clusters in bins.

Return type

dict

clevar.match_metrics.recovery.funcs.skyplot(cat, matching_type, nside=256, nest=True, mask=None, mask_unmatched=None, auto_lim=False, ra_lim=None, dec_lim=None, recovery_label='Recovery Rate', fig=None, figsize=None, **kwargs)[source]

Plot recovery rate in healpix pixels.

Parameters
  • cat (clevar.ClCatalog) – ClCatalog with matching information

  • matching_type (str) – Type of matching to be considered. Must be in: ‘cross’, ‘cat1’, ‘cat2’, ‘multi_cat1’, ‘multi_cat2’, ‘multi_join’

  • nside (int) – Healpix nside

  • nest (bool) – If ordering is nested

  • mask (array) – Mask of unwanted clusters

  • mask_unmatched (array) – Mask of unwanted unmatched clusters (ex: out of footprint)

  • auto_lim (bool) – Set automatic limits for ra/dec.

  • ra_lim (None, list) – Min/max RA for plot.

  • dec_lim (None, list) – Min/max DEC for plot.

  • recovery_label (str) – Lable for colorbar. Default: ‘recovery rate’

  • fig (matplotlib.figure.Figure, None) – Matplotlib figure object. If not provided a new one is created.

  • figsize (tuple) – Width, height in inches (float, float). Default value from hp.cartview.

  • **kwargs

    Extra arguments for hp.cartview:

    • xsize (int) : The size of the image. Default: 800

    • title (str) : The title of the plot. Default: None

    • min (float) : The minimum range value

    • max (float) : The maximum range value

    • remove_dip (bool) : If True, remove the dipole+monopole

    • remove_mono (bool) : If True, remove the monopole

    • gal_cut (float, scalar) : Symmetric galactic cut for the dipole/monopole fit. Removes points in latitude range [-gal_cut, +gal_cut]

    • format (str) : The format of the scale label. Default: ‘%g’

    • cbar (bool) : Display the colorbar. Default: True

    • notext (bool) : If True, no text is printed around the map

    • norm ({‘hist’, ‘log’, None}) : Color normalization, hist= histogram equalized color mapping, log= logarithmic color mapping, default: None (linear color mapping)

    • cmap (a color map) : The colormap to use (see matplotlib.cm)

    • badcolor (str) : Color to use to plot bad values

    • bgcolor (str) : Color to use for background

    • margins (None or sequence) : Either None, or a sequence (left,bottom,right,top) giving the margins on left,bottom,right and top of the axes. Values are relative to figure (0-1). Default: None

Returns

info

Information of data in the plots, it contains the sections:

  • fig (matplotlib.pyplot.figure): Figure of the plot. The main can be accessed at info[‘fig’].axes[0], and the colorbar at info[‘fig’].axes[1].

  • nc_pix: Dictionary with the number of clusters in each pixel.

  • nc_mt_pix: Dictionary with the number of matched clusters in each pixel.

Return type

dict