clevar.match_metrics.scaling.catalog_funcs module¶
@file clevar/match_metrics/scaling/catalog_funcs.py
Main scaling functions using catalogs, wrapper of array_funcs functions
- clevar.match_metrics.scaling.catalog_funcs.plot(cat1, cat2, matching_type, col, col_color=None, color1=True, color_log=False, **kwargs)[source]¶
Scatter plot with errorbars. Color can be based on input column.
- Parameters
cat1 (clevar.ClCatalog) – ClCatalogs with matching information.
cat2 (clevar.ClCatalog) – ClCatalogs with matching information.
matching_type (str) – Type of matching to be considered. Must be in: ‘cross’, ‘cat1’, ‘cat2’
col (str) – Name of column to be plotted
col_color (str, None) – Name of column for color
color1 (bool) – Use catalog 1 for color. If false uses catalog 2
color_log (bool) – Use log of col_color
add_err (bool) – Add errorbars
mask1 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
mask2 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
ax (matplotlib.axes, None) – Ax to add plot. If equals None, one is created.
plt_kwargs (dict, None) – Additional arguments for pylab.scatter
add_cb (bool) – Plot colorbar
cb_kwargs (dict, None) – Colorbar arguments
err_kwargs (dict, None) – Additional arguments for pylab.errorbar
xlabel (str) – Label of x/y axis (default=cat1.labels[col]/cat2.labels[col]).
ylabel (str) – Label of x/y axis (default=cat1.labels[col]/cat2.labels[col]).
xscale (str) – Scale for x/y axis.
yscale (str) – Scale for x/y axis.
add_bindata (bool) – Plot binned data used for fit (default=False).
add_fit (bool) – Fit and plot binned dat (default=False).
fit_err2 (array, None) – Error of catalog 2 component (set to err2 if not provided).
fit_log (bool) – Bin and fit in log values (default=False).
fit_statistics (str) –
Statistics to be used in fit (default=mean). Options are:
individual : Use each point
mode : Use mode of catalog 2 component distribution in each catalog 1 component bin, requires bins2.
mean : Use mean of catalog 2 component distribution in each catalog 1 component bin, requires bins2.
fit_bins1 (array, None) – Bins for catalog 1 component (default=10).
fit_bins2 (array, None) – Bins for catalog 2 component (default=30).
fit_legend_kwargs (dict, None) – Additional arguments for plt.legend.
fit_bindata_kwargs (dict, None) – Additional arguments for pylab.errorbar.
fit_plt_kwargs (dict, None) – Additional arguments for plot of fit pylab.scatter.
fit_label_components (tuple (of strings)) – Names of fitted components in fit line label, default=(xlabel, ylabel)
- Returns
info –
Information of data in the plots, it contains the sections:
ax: ax used in the plot.
binned_data (optional): input data for fitting, with values:
x: x values in fit (log of values if log=True).
y: y values in fit (log of values if log=True).
y_err: errorbar on y values (error_log if log=True).
fit (optional): fitting output dictionary, with values:
pars: fitted parameter.
cov: covariance of fitted parameters.
func: fitting function with fitted parameter.
func_plus: fitting function with fitted parameter plus 1x scatter.
func_minus: fitting function with fitted parameter minus 1x scatter.
func_scat: scatter of fited function.
func_dist: P(y|x) - Probability of having y given a value for x, assumes normal distribution and uses scatter of the fitted function.
func_scat_interp: interpolated scatter from data.
func_dist_interp: P(y|x) using interpolated scatter.
plots (optional): additional plots:
fit: fitted data
errorbar: binned data
- Return type
dict
- clevar.match_metrics.scaling.catalog_funcs.plot_density(cat1, cat2, matching_type, col, **kwargs)[source]¶
Scatter plot with errorbars and color based on point density
- Parameters
cat1 (clevar.ClCatalog) – ClCatalogs with matching information.
cat2 (clevar.ClCatalog) – ClCatalogs with matching information.
matching_type (str) – Type of matching to be considered. Must be in: ‘cross’, ‘cat1’, ‘cat2’
col (str) – Name of column to be plotted
bins1 (array, None) – Bins for component x and y (for density colors).
bins2 (array, None) – Bins for component x and y (for density colors).
add_err (bool) – Add errorbars
mask1 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
mask2 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
ax (matplotlib.axes, None) – Ax to add plot. If equals None, one is created.
plt_kwargs (dict, None) – Additional arguments for pylab.scatter
add_cb (bool) – Plot colorbar
cb_kwargs (dict, None) – Colorbar arguments
err_kwargs (dict, None) – Additional arguments for pylab.errorbar
ax_rotation (float) – Angle (in degrees) for rotation of axis of binning. Overwrites use of (bins1, bins2)
rotation_resolution (int) – Number of bins to be used when ax_rotation!=0.
xlabel (str) – Label of x/y axis (default=cat1.labels[col]/cat2.labels[col]).
ylabel (str) – Label of x/y axis (default=cat1.labels[col]/cat2.labels[col]).
xscale (str) – Scale for x/y axis.
yscale (str) – Scale for x/y axis.
add_bindata (bool) – Plot binned data used for fit (default=False).
add_fit (bool) – Fit and plot binned dat (default=False).
**fit_kwargs – Other fit arguments (see fit_* paramters in scaling.catalog_funcs.plot for more info).
- Returns
info –
Information of data in the plots, it contains the sections:
ax: ax used in the plot.
ax_cb (optional): ax of colorbar
binned_data (optional): input data for fitting (see scaling.catalog_funcs.plot for more info).
fit (optional): fitting output dictionary (see scaling.catalog_funcs.plot for more info).
plots (optional): fit and binning plots (see scaling.catalog_funcs.plot for more info).
- Return type
dict
- clevar.match_metrics.scaling.catalog_funcs.plot_density_dist(cat1, cat2, matching_type, col, **kwargs)[source]¶
Scatter plot with errorbars and color based on point density with distribution panels.
- Parameters
cat1 (clevar.ClCatalog) – ClCatalogs with matching information.
cat2 (clevar.ClCatalog) – ClCatalogs with matching information.
matching_type (str) – Type of matching to be considered. Must be in: ‘cross’, ‘cat1’, ‘cat2’
col (str) – Name of column to be plotted
bins1 (array, None) – Bins for component x and y (for density colors).
bins2 (array, None) – Bins for component x and y (for density colors).
add_err (bool) – Add errorbars
mask1 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
mask2 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
fig_kwargs (dict, None) – Additional arguments for plt.subplots
ax_rotation (float) – Angle (in degrees) for rotation of axis of binning. Overwrites use of (bins1, bins2) on main plot.
rotation_resolution (int) – Number of bins to be used when ax_rotation!=0.
plt_kwargs (dict, None) – Additional arguments for pylab.scatter
add_cb (bool) – Plot colorbar
cb_kwargs (dict, None) – Colorbar arguments
err_kwargs (dict, None) – Additional arguments for pylab.errorbar
metrics_kwargs (dict, None) – Dictionary of dictionary configs for each metric plots.
xscale (str) – Scale for x/y axis.
yscale (str) – Scale for x/y axis.
fig_pos (tuple) – List with edges for the figure. Must be in format (left, bottom, right, top)
fig_frac (tuple) – Sizes of each panel in the figure. Must be in the format (main_panel, gap, colorbar) and have values: [0, 1]. Colorbar is only used with add_cb key.
add_bindata (bool) – Plot binned data used for fit (default=False).
add_fit (bool) – Fit and plot binned dat (default=False).
**fit_kwargs – Other fit arguments (see fit_* paramters in scaling.catalog_funcs.plot for more info).
- Returns
info –
Information of data in the plots, it contains the sections:
fig: matplotlib.figure.Figure object.
axes: dictionary with each ax of the plot.
binned_data (optional): input data for fitting (see scaling.catalog_funcs.plot for more info).
fit (optional): fitting output dictionary (see scaling.catalog_funcs.plot for more info).
plots (optional): fit and binning plots (see scaling.catalog_funcs.plot for more info).
- Return type
dict
- clevar.match_metrics.scaling.catalog_funcs.plot_density_metrics(cat1, cat2, matching_type, col, bins1=30, bins2=30, **kwargs)[source]¶
Scatter plot with errorbars and color based on point density with scatter and bias panels
- Parameters
cat1 (clevar.ClCatalog) – ClCatalogs with matching information.
cat2 (clevar.ClCatalog) – ClCatalogs with matching information.
matching_type (str) – Type of matching to be considered. Must be in: ‘cross’, ‘cat1’, ‘cat2’
col (str) – Name of column to be plotted
bins1 (array, None) – Bins for component x and y.
bins2 (array, None) – Bins for component x and y.
metrics_mode (str) –
Mode to run metrics (default=`simple`). Options are:
simple : metrics for values2.
log : metrics for log10(values2).
diff : metrics for values2-values1.
diff_log : metrics for log10(values2)-log10(values1).
diff_z : metrics for (values2-values1)/(1+values1).
metrics (list) –
List of mettrics to be plotted (default=[mean, std]). Possibilities are:
mean : compute the mean of values for points within each bin.
std : compute the standard deviation within each bin.
median : compute the median of values for points within each bin.
count : compute the count of points within each bin.
sum : compute the sum of values for points within each bin.
min : compute the minimum of values for points within each bin.
max : compute the maximum of values for point within each bin.
p_# : compute half the width where a percentile of data is found. Number must be between 0-100 (ex: p_68, p_95, p_99).
add_err (bool) – Add errorbars
mask1 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
mask2 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
fig_kwargs (dict, None) – Additional arguments for plt.subplots
ax_rotation (float) – Angle (in degrees) for rotation of axis of binning. Overwrites use of (bins1, bins2) on main plot.
rotation_resolution (int) – Number of bins to be used when ax_rotation!=0.
plt_kwargs (dict, None) – Additional arguments for pylab.scatter
add_cb (bool) – Plot colorbar
cb_kwargs (dict, None) – Colorbar arguments
err_kwargs (dict, None) – Additional arguments for pylab.errorbar
metrics_kwargs (dict, None) – Dictionary of dictionary configs for each metric plots.
xscale (str) – Scale for x/y axis.
yscale (str) – Scale for x/y axis.
fig_pos (tuple) – List with edges for the figure. Must be in format (left, bottom, right, top)
fig_frac (tuple) – Sizes of each panel in the figure. Must be in the format (main_panel, gap, colorbar) and have values: [0, 1]. Colorbar is only used with add_cb key.
add_bindata (bool) – Plot binned data used for fit (default=False).
add_fit (bool) – Fit and plot binned dat (default=False).
**fit_kwargs – Other fit arguments (see fit_* paramters in scaling.catalog_funcs.plot for more info).
- Returns
info –
Information of data in the plots, it contains the sections:
fig: matplotlib.figure.Figure object.
axes: dictionary with each ax of the plot.
metrics: dictionary with the plots for each metric.
binned_data (optional): input data for fitting (see scaling.catalog_funcs.plot for more info).
fit (optional): fitting output dictionary (see scaling.catalog_funcs.plot for more info).
plots (optional): fit and binning plots (see scaling.catalog_funcs.plot for more info).
- Return type
dict
- clevar.match_metrics.scaling.catalog_funcs.plot_density_panel(cat1, cat2, matching_type, col, col_panel, bins_panel, panel_cat1=True, log_panel=False, **kwargs)[source]¶
Scatter plot with errorbars and color based on point density with panels
- Parameters
cat1 (clevar.ClCatalog) – ClCatalogs with matching information.
cat2 (clevar.ClCatalog) – ClCatalogs with matching information.
matching_type (str) – Type of matching to be considered. Must be in: ‘cross’, ‘cat1’, ‘cat2’
col (str) – Name of column to be plotted
col_panel (str) – Name of column to make panels
bins_panel (array, int) – Bins to make panels
panel_cat1 (bool) – Used catalog 1 for col_panel. If false uses catalog 2
bins1 (array, None) – Bins for component x and y (for density colors).
bins2 (array, None) – Bins for component x and y (for density colors).
log_panel (bool) – Scale of the panel values
add_err (bool) – Add errorbars
mask1 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
mask2 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
ax (matplotlib.axes, None) – Ax to add plot. If equals None, one is created.
plt_kwargs (dict, None) – Additional arguments for pylab.scatter
add_cb (bool) – Plot colorbar
cb_kwargs (dict, None) – Colorbar arguments
err_kwargs (dict, None) – Additional arguments for pylab.errorbar
ax_rotation (float) – Angle (in degrees) for rotation of axis of binning. Overwrites use of (bins1, bins2)
rotation_resolution (int) – Number of bins to be used when ax_rotation!=0.
panel_kwargs_list (list, None) – List of additional arguments for plotting each panel (using pylab.plot). Must have same size as len(bins2)-1
panel_kwargs_errlist (list, None) – List of additional arguments for plotting each panel (using pylab.errorbar). 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
xlabel (str) – Label of x/y axis (default=cat1.labels[col]/cat2.labels[col]).
ylabel (str) – Label of x/y axis (default=cat1.labels[col]/cat2.labels[col]).
xscale (str) – Scale for x/y axis.
yscale (str) – Scale for x/y axis.
add_bindata (bool) – Plot binned data used for fit (default=False).
add_fit (bool) – Fit and plot binned dat (default=False).
**fit_kwargs – Other fit arguments (see fit_* paramters in scaling.catalog_funcs.plot for more info).
- Returns
info –
Information of data in the plots, it contains the sections:
fig: matplotlib.figure.Figure object.
axes: matplotlib.axes used in the plot.
ax_cb (optional): ax of colorbar
binned_data (optional): input data for fitting (see scaling.catalog_funcs.plot for more info).
fit (optional): fitting output dictionary (see scaling.catalog_funcs.plot for more info).
plots (optional): fit and binning plots (see scaling.catalog_funcs.plot for more info).
- Return type
dict
- clevar.match_metrics.scaling.catalog_funcs.plot_dist(cat1, cat2, matching_type, col, bins1=30, bins2=5, col_aux=None, bins_aux=5, log_vals=False, log_aux=False, transpose=False, **kwargs)[source]¶
Plot distribution of a cat1 column, binned by the cat2 column in panels, with option for a second cat2 column in lines.
- Parameters
cat1 (clevar.ClCatalog) – ClCatalogs with matching information.
cat2 (clevar.ClCatalog) – ClCatalogs with matching information.
matching_type (str) – Type of matching to be considered. Must be in: ‘cross’, ‘cat1’, ‘cat2’
col (str) – Name of column to be plotted
bins1 (array, int) – Bins for distribution of the cat1 column.
bins2 (array, int) – Bins for cat2 column (for panels/lines).
col_aux (array) – Auxiliary colum of cat2 (to bin data in lines/panels).
bins_aux (array, int) – Bins for component aux
log_vals (bool) – Log scale for values (and int bins)
log_aux (bool) – Log scale for aux values (and int bins)
transpose (bool) – Invert lines and panels
fig_kwargs (dict, None) – Additional arguments for plt.subplots
shape (str) – Shape of the lines. Can be steps or line.
plt_kwargs (dict, None) – Additional arguments for pylab.plot
line_kwargs_list (list, None) – List of additional arguments for plotting each line (using pylab.plot). Must have same size as len(bins_aux)-1
legend_kwargs (dict, None) – Additional arguments for plt.legend
add_panel_label (bool) – Add bin label to panel
panel_label_format (function) – Function to format the values of the bins
add_line_label (bool) – Add bin label to line
line_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.
- Return type
dict
- clevar.match_metrics.scaling.catalog_funcs.plot_dist_self(cat, col, bins1=30, bins2=5, col_aux=None, bins_aux=5, log_vals=False, log_aux=False, transpose=False, mask=None, **kwargs)[source]¶
Plot distribution of a cat1 column, binned by the same column in panels, with option for a second column in lines. Is is useful to compare with plot_dist results.
- Parameters
cat (clevar.ClCatalog) – Input catalog
col (str) – Name of column to be plotted
bins1 (array, int) – Bins for distribution of the cat1 column.
bins2 (array, int) – Bins for cat2 column (for panels/lines).
col_aux (array) – Auxiliary colum of cat2 (to bin data in lines/panels).
bins_aux (array, int) – Bins for component aux
log_vals (bool) – Log scale for values (and int bins)
log_aux (bool) – Log scale for aux values (and int bins)
transpose (bool) – Invert lines and panels
mask (ndarray) – Mask for catalog
fig_kwargs (dict, None) – Additional arguments for plt.subplots
shape (str) – Shape of the lines. Can be steps or line.
plt_kwargs (dict, None) – Additional arguments for pylab.plot
line_kwargs_list (list, None) – List of additional arguments for plotting each line (using pylab.plot). Must have same size as len(bins_aux)-1
legend_kwargs (dict, None) – Additional arguments for plt.legend
add_panel_label (bool) – Add bin label to panel
panel_label_format (function) – Function to format the values of the bins
add_line_label (bool) – Add bin label to line
line_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.
- Return type
dict
- clevar.match_metrics.scaling.catalog_funcs.plot_metrics(cat1, cat2, matching_type, col, bins1=30, bins2=30, **kwargs)[source]¶
Plot metrics.
- Parameters
cat1 (clevar.ClCatalog) – ClCatalogs with matching information.
cat2 (clevar.ClCatalog) – ClCatalogs with matching information.
matching_type (str) – Type of matching to be considered. Must be in: ‘cross’, ‘cat1’, ‘cat2’
col (str) – Name of column to be plotted
bins1 (array, None) – Bins for component of catalog 1 and 2.
bins2 (array, None) – Bins for component of catalog 1 and 2.
mode (str) –
Mode to run (default=`simple`). Options are:
simple : metrics for values2.
log : metrics for log10(values2).
diff : metrics for values2-values1.
diff_log : metrics for log10(values2)-log10(values1).
diff_z : metrics for (values2-values1)/(1+values1).
metrics (list) –
List of mettrics to be plotted (default=[mean, std]). Possibilities are:
mean : compute the mean of values for points within each bin.
std : compute the standard deviation within each bin.
median : compute the median of values for points within each bin.
count : compute the count of points within each bin.
sum : compute the sum of values for points within each bin.
min : compute the minimum of values for points within each bin.
max : compute the maximum of values for point within each bin.
p_# : compute half the width where a percentile of data is found. Number must be between 0-100 (ex: p_68, p_95, p_99).
mask1 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
mask2 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
metrics_kwargs (dict, None) – Dictionary of dictionary configs for each metric plots.
fig_kwargs (dict, None) – Additional arguments for plt.subplots
legend_kwargs (dict, None) – Additional arguments for plt.legend
label1 (str) – Label for catalog 1/2 components.
label2 (str) – Label for catalog 1/2 components.
scale1 (str) – Scale of catalog 1/2 components.
scale2 (str) – Scale of catalog 1/2 components.
- Returns
info –
Information of data in the plots, it contains the sections:
fig: matplotlib.figure.Figure object.
axes: matplotlib.axes used in the plot.
- Return type
dict
- clevar.match_metrics.scaling.catalog_funcs.plot_panel(cat1, cat2, matching_type, col, col_panel, bins_panel, panel_cat1=True, col_color=None, color1=True, log_panel=False, **kwargs)[source]¶
Scatter plot with errorbars and color based on input with panels
- Parameters
cat1 (clevar.ClCatalog) – ClCatalogs with matching information.
cat2 (clevar.ClCatalog) – ClCatalogs with matching information.
matching_type (str) – Type of matching to be considered. Must be in: ‘cross’, ‘cat1’, ‘cat2’
col (str) – Name of column to be plotted
col_panel (str) – Name of column to make panels
bins_panel (array, int) – Bins to make panels
panel_cat1 (bool) – Used catalog 1 for col_panel. If false uses catalog 2
col_color (str, None) – Name of column for color.
color1 (bool) – Use catalog 1 for color. If false uses catalog 2
log_panel (bool) – Scale of the panel values
add_err (bool) – Add errorbars
mask1 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
mask2 (array, None) – Masks for clusters 1(2), must have size=cat1(2).size
plt_kwargs (dict, None) – Additional arguments for pylab.scatter
add_cb (bool) – Plot colorbar
cb_kwargs (dict, None) – Colorbar arguments
err_kwargs (dict, None) – Additional arguments for pylab.errorbar
panel_kwargs_list (list, None) – List of additional arguments for plotting each panel (using pylab.plot). Must have same size as len(bins2)-1
panel_kwargs_errlist (list, None) – List of additional arguments for plotting each panel (using pylab.errorbar). 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
xlabel (str) – Label of x/y axis (default=cat1.labels[col]/cat2.labels[col]).
ylabel (str) – Label of x/y axis (default=cat1.labels[col]/cat2.labels[col]).
xscale (str) – Scale for x/y axis.
yscale (str) – Scale for x/y axis.
add_bindata (bool) – Plot binned data used for fit (default=False).
add_fit (bool) – Fit and plot binned dat (default=False).
**fit_kwargs – Other fit arguments (see fit_* paramters in scaling.catalog_funcs.plot for more info).
- Returns
info –
Information of data in the plots, it contains the sections:
fig: matplotlib.figure.Figure object.
axes: matplotlib.axes used in the plot.
ax_cb (optional): ax of colorbar
binned_data (optional): input data for fitting (see scaling.catalog_funcs.plot for more info).
fit (optional): fitting output dictionary (see scaling.catalog_funcs.plot for more info).
plots (optional): fit and binning plots (see scaling.catalog_funcs.plot for more info).
- Return type
dict