coolest.api.plotting#
Classes#
Create pyplot panels from a lens model stored in the COOLEST format. |
|
Wrapper around a set of ModelPlotter instances to produce panels that |
|
Handles plot of analytical models in a comparative way |
Module Contents#
- class ModelPlotter(coolest_object, coolest_directory=None, color_bad_values='#222222')[source]#
Create pyplot panels from a lens model stored in the COOLEST format.
- Parameters:
coolest_object (COOLEST) – COOLEST instance
coolest_directory (str, optional) – Directory which contains the COOLEST template, by default None
color_bad_values (str, optional) – Color assigned to NaN values (typically negative values in log-scale), by default ‘#111111’ (dark gray)
- plot_data_image(ax, title=None, norm=None, cmap=None, xylim=None, neg_values_as_bad=False, add_colorbar=True, add_scalebar=True, scalebar_size=1)[source]#
plt.imshow panel with the data image
- plot_surface_brightness(ax, title=None, coordinates=None, extent_irreg=None, norm=None, cmap=None, xylim=None, neg_values_as_bad=True, plot_points_irreg=False, add_colorbar=True, add_scalebar=False, scalebar_size=0.4, kwargs_light=None, plot_caustics=None, caustics_color='white', caustics_alpha=0.5, coordinates_lens=None, kwargs_lens_mass=None)[source]#
plt.imshow panel showing the surface brightness of the (unlensed) lensing entity selected via kwargs_light (see ComposableLightModel docstring)
- plot_model_image(ax, title=None, norm=None, cmap=None, xylim=None, neg_values_as_bad=False, add_colorbar=True, add_scalebar=True, scalebar_size=1, auto_selection=False, kwargs_lens_mass=None, kwargs_lens_light=None, kwargs_source=None, **model_image_kwargs)[source]#
plt.imshow panel showing the surface brightness of the (lensed) selected lensing entities (see ComposableLensModel docstring)
- plot_model_residuals(ax, title=None, mask=None, norm=None, cmap=None, xylim=None, add_chi2_label=False, chi2_fontsize=12, kwargs_source=None, kwargs_lens_mass=None, kwargs_lens_light=None, add_colorbar=True, add_scalebar=True, scalebar_size=1, **model_image_kwargs)[source]#
plt.imshow panel showing the normalized model residuals image
- plot_convergence(ax, title=None, coordinates=None, norm=None, cmap=None, xylim=None, neg_values_as_bad=False, add_colorbar=True, add_scalebar=True, scalebar_size=1, kwargs_lens_mass=None)[source]#
plt.imshow panel showing the 2D convergence map associated to the selected lensing entities (see ComposableMassModel docstring)
- plot_convergence_diff(ax, reference_map, title=None, relative_error=True, norm=None, cmap=None, xylim=None, coordinates=None, add_colorbar=True, add_scalebar=True, scalebar_size=1, kwargs_lens_mass=None, plot_crit_lines=False, crit_lines_color='black', crit_lines_alpha=0.5)[source]#
plt.imshow panel showing the 2D convergence map associated to the selected lensing entities (see ComposableMassModel docstring)
- plot_magnification(ax, title=None, norm=None, cmap=None, xylim=None, add_colorbar=True, add_scalebar=True, scalebar_size=1, coordinates=None, kwargs_lens_mass=None)[source]#
plt.imshow panel showing the 2D magnification map associated to the selected lensing entities (see ComposableMassModel docstring)
- plot_magnification_diff(ax, reference_map, title=None, relative_error=True, norm=None, cmap=None, xylim=None, add_colorbar=True, add_scalebar=True, scalebar_size=1, coordinates=None, kwargs_lens_mass=None)[source]#
plt.imshow panel showing the (absolute or relative) difference between 2D magnification maps
- class MultiModelPlotter(coolest_objects, coolest_directories=None, **kwargs_plotter)[source]#
Wrapper around a set of ModelPlotter instances to produce panels that consistently compare different models, evaluated on the same coordinates systems.
- Parameters:
coolest_objects (list) – List of COOLEST instances
coolest_directories (list, optional) – List of directories corresponding to each COOLEST instance, by default None
kwargs_plotter (dict, optional) – Additional keyword arguments passed to ModelPlotter
- class ParametersPlotter(parameter_id_list, coolest_objects, coolest_directories=None, coolest_names=None, ref_coolest_objects=None, ref_coolest_directories=None, ref_coolest_names=None, posterior_bool_list=None, colors=None, linestyles=None, add_multivariate_margin_samples=False, num_samples_per_model_margin=5000)[source]#
Handles plot of analytical models in a comparative way
- Parameters:
parameter_id_list (array) – A list of parameter unique ids obtained from lensing entities. Their order determines the order of the plot panels.
coolest_objects (array) – A list of coolest objects that have a chain file associated to them.
coolest_directories (array) – A list of paths matching the coolest files in ‘chain_objs’.
coolest_names (array, optional) – A list of labels for the coolest models in the ‘chain_objs’ list. Must have the same order as ‘chain_objs’.
ref_coolest_objects (array, optional) – A list of coolest objects that will be used as point estimates.
ref_coolest_directories (array) – A list of paths matching the coolest files in ‘point_estimate_objs’.
ref_coolest_names (array, optional) – A list of labels for the models in the ‘point_estimate_objs’ list. Must have the same order as ‘point_estimate_objs’.
posterior_bool_list (list, optional) – List of bool to toggle errorbars on point-estimate values
colors (list, optional) – List of pyplot color names to associate to each coolest model.
linestyles (list, optional) – List of pyplot linesyles to associate to each coolest model.
add_multivariate_margin_samples (bool, optional) – If True, will append to the list of compared models a new chain that is resampled from the multi-variate normal distribution, where its covariance matrix is computed from the marginalization of all samples from all models. By default False.
num_samples_per_model_margin (int, optional) – Number of samples to (randomly) draw from each model samples to concatenate before estimating the multi-variate normal marginalization.
- init_getdist(shift_sample_list=None, settings_mcsamples=None, add_multivariate_margin_samples=False)[source]#
Initializes the getdist plotter.
- Parameters:
shift_sample_list (dict) – Dictionary keyed by parameter ID to apply a uniform additive shift to all samples of that parameters posterior distribution.
settings_mcsamples (dict, optional) – Keyword arguments passed as the settings argument of getdist.MCSamples, by default None
- Raises:
ValueError – If the csv file containing samples is is not coma (,) separated.
- plot_triangle_getdist(filled_contours=True, angles_range=None, linewidth_hist=2, linewidth_cont=2, linewidth_margin=4, marker_linewidth=2, marker_size=15, axes_labelsize=None, legend_fontsize=None, **subplot_kwargs)[source]#
Corner array of subplots using getdist.triangle_plot method.
- Parameters:
subplot_size (int, optional) – Size of the getdist plot, by default 1
filled_contours (bool, optional) – Wether or not to fill the 2D contours, by default True
angles_range (_type_, optional) – Restrict the range of angle (containing ‘phi’ in their name) parameters, by default None
linewidth_hist (int, optional) – Line width for 1D histograms, by default 2
linewidth_cont (int, optional) – Line width for 2D contours, by default 1
marker_size (int, optional) – Size of the reference (scatter) markers on 2D contours plots, by default 15
- Returns:
Instance of GetDistPlotter corresponding to the figure
- Return type:
GetDistPlotter
- plot_rectangle_getdist(x_param_ids, y_param_ids, subplot_size=1, legend_ncol=None, legend_fontsize=None, filled_contours=True, linewidth=1, marker_size=15, axes_labelsize=None, **subplot_kwargs)[source]#
Array of (2D contours) subplots using getdist.rectangle_plot method.
- Parameters:
subplot_size (int, optional) – Size of the getdist plot, by default 1
filled_contours (bool, optional) – Wether or not to fill the 2D contours, by default True
linewidth (int, optional) – Line width for 2D contours, by default 1
marker_size (int, optional) – Size of the reference (scatter) markers on 2D contours plots, by default 15
legend_ncol (number of columns in the legend)
- Returns:
Instance of GetDistPlotter corresponding to the figure
- Return type:
GetDistPlotter
- plot_1d_getdist(num_columns=None, legend_ncol=None, legend_fontsize=None, axes_labelsize=None, linewidth=1, **subplot_kwargs)[source]#
Array of 1D histogram subplots using getdist.plots_1d method.
- Parameters:
subplot_size (int, optional) – Size of the getdist plot, by default 1
linewidth (int, optional) – Line width for 2D contours, by default 1
marker_size (int, optional) – Size of the reference (scatter) markers on 2D contours plots, by default 15
legend_ncol (int, optional) – number of columns in the legend
num_columns (int, optional) – number of columns of the subplot array
- Returns:
Instance of GetDistPlotter corresponding to the figure
- Return type:
GetDistPlotter
- plotting_routine(param_dict, idx_file=0)[source]#
plot the parameters
INPUT#
param_dict: dict, organized dictonnary with all parameters results of the different files idx_file: int, chooses the file on which the choice of plotted parameters will be made (not very clear: basically in file 0 you may have a sersic fit and in file 1 sersic+shapelets. If you choose
idx_file=0, you will plot the sersic results of both file. If you choose idx_file=1, you will plot all the sersic and shapelets parameters when available)