clevar.match_metrics.recovery.array_funcs module¶
@file clevar/match_metrics/recovery/array_funcs.py
Main recovery functions using arrays.
- clevar.match_metrics.recovery.array_funcs.get_recovery_rate(values1, values2, bins1, bins2, is_matched)[source]¶
Get recovery rate binned in 2 components
- Parameters
values1 (array) – Component 1 and 2.
values2 (array) – Component 1 and 2.
bins1 (array, int) – Bins for components 1 and 2.
bins2 (array, int) – Bins for components 1 and 2.
is_matched (array (boolean)) – Boolean array indicating matching status
- Returns
Binned recovery rate. Its sections are:
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.array_funcs.plot(values1, values2, bins1, bins2, is_matched, shape='steps', ax=None, plt_kwargs=None, lines_kwargs_list=None, add_legend=True, legend_format=<function <lambda>>, legend_kwargs=None)[source]¶
Plot recovery rate as lines, with each line binned by bins1 inside a bin of bins2.
- Parameters
values1 (array) – Component 1 and 2.
values2 (array) – Component 1 and 2.
bins1 (array, int) – Bins for components 1 and 2.
bins2 (array, int) – Bins for components 1 and 2.
is_matched (array (boolean)) – Boolean array indicating matching status
shape (str) – Shape of the lines. Can be steps or line.
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_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.array_funcs.plot2D(values1, values2, bins1, bins2, is_matched, ax=None, plt_kwargs=None, add_cb=True, cb_kwargs=None, add_num=False, num_kwargs=None)[source]¶
Plot recovery rate as in 2D bins.
- Parameters
values1 (array) – Component 1 and 2.
values2 (array) – Component 1 and 2.
bins1 (array, int) – Bins for components 1 and 2.
bins2 (array, int) – Bins for components 1 and 2.
is_matched (array (boolean)) – Boolean array indicating matching status
ax (matplotlib.axes) – Ax to add plot
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.array_funcs.plot_panel(values1, values2, bins1, bins2, is_matched, shape='steps', plt_kwargs=None, panel_kwargs_list=None, fig_kwargs=None, add_label=True, label_format=<function <lambda>>)[source]¶
Plot recovery rate as lines in panels, with each line binned by bins1 and each panel is based on the data inside a bins2 bin.
- Parameters
values1 (array) – Component 1 and 2.
values2 (array) – Component 1 and 2.
bins1 (array, int) – Bins for components 1 and 2.
bins2 (array, int) – Bins for components 1 and 2.
is_matched (array (boolean)) – Boolean array indicating matching status
shape (str) – Shape of the lines. Can be steps or line.
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
- 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.array_funcs.skyplot(ra, dec, is_matched, nside=256, nest=True, 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
ra (numpy array) – Ra array in degrees
dec (numpy array) – Dec array in degrees
is_matched (array (boolean)) – Boolean array indicating matching status
nside (int) – Healpix nside
nest (bool) – If ordering is nested
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+monopoleremove_mono (bool) : If
True
, remove the monopolegal_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