posydon.visualization

posydon.visualization.VHdiagram

posydon.visualization.combine_TF

Module for combining termination flags for visualization purposes.

posydon.visualization.combine_TF.combine_TF12(IC, TF2, verbose=False)[source]

Get the combination of interpolation classion and termination flag 2.

posydon.visualization.interpolation

Module to evaluate IFInterpolator class

class posydon.visualization.interpolation.EvaluateIFInterpolator(interpolator, test_grid)[source]

Bases: object

Class that is helpful for evaluating interpolation performance

Initialize the EvaluateIFInterpolator class

Parameters:
  • interpolator (IFInterpolator) – Interpolator that user wants to test

  • test_grid (PSyGrid) – Grid object containing testing tracks

classifiers()[source]

Method that lists classifiers available

confusion_matrix(key, params={}, save_path=None, close_fig=False)[source]

Method that plots confusion matrices to evaluate classification

Parameters:
  • key (str) – The key for the classifier of interest

  • params (dict) – Extra params to pass to matplolib, x_labels (list), y_labels (list), title (str)

  • save_path (str) – The path where the figure should be saved to

  • close_fig (bool) – Flag whether figure should be closed

decision_boundaries()[source]
keys()[source]

Method that lists out keys available

plot2D(key, slice_3D_var_str, slice_3D_var_range, PLOT_PROPERTIES)[source]
violin_plots(err_type='relative', keys=None, save_path=None, close_fig=False)[source]

Method that plots distribution of specified error for given keys and optionally saves it.

Parameters:
  • err_type (str) – Either relative or absolute, default is relative

  • keys (list) – A list of keys for which the errors will be shown, by default is all of them

  • save_path (str) – The path where the figure should be saved to

  • close_fig (bool) – Flag whether figure should be closed

posydon.visualization.plot1D

Plotting class for 1D (MESA) psygrids.

The 1D visualization plotting class allows to plot 1D tracks of PsyGrid objects. The PsyGrid object is composed of nD MESA grid run with POSYDON and post processed with the psygrid object into an h5 file.

class posydon.visualization.plot1D.plot1D(run, x_var_str, y_var_str, z_var_str=None, history='binary_history', star_states=None, HR=False, verbose=False, **kwargs)[source]

Bases: object

Plotting class for 1D (MESA) grids.

Read a PsyGrid object and plot a 1D track of x vs y.

Parameters:
  • run (int or list of int) – Index or list of indeces of the PsyGrid object you would like to plot.

  • x_var_str (str) – String of values to plot on the x axis. Allowed strings are the one in psygrid.history.dtype.names where “history” needs to be chosen accordingly.

  • y_var_str (str or list of str) – String or list of stringvalues to plot on the y axis. Allowed strings are the one in psygrid.history.dtype.names where “history” needs to be chosen accordingly.

  • z_var_str (str) – String of values to plot on the z axis (displayed with a color). Allowed strings are the one in psygrid.history.dtype.names where “history” needs to be chosen accordingly.

  • history (str) – The x, y, z variables are read from either: “binary_history”, “history1”, “history2”.

  • HR (bool) – If True, an HR diagram will be plotted.

  • verbose (bool) – If True, the object reports by printing to standard output.

  • **kwargs (dict) – Dictionary containing extra visualisation options (cf. PLOT_PROPERTIES in plot_defaults.py.

HR_diagram()[source]

Plot and HR diagram.

lines_constant_radius()[source]

Constant radius lines for the HR diagram.

plot_panel(ax, i, y_var_str)[source]

Plot the 1D pannel.

Parameters:
  • ax (object) – matplotlib figure axes.

  • i (int) – Index of the run to plot.

  • y_var_str (str) – String or list of stringvalues to plot on the y axis.

set_color_bar(scatter)[source]

Add colorbar.

Parameters:

scatters (object) – matplotlib scatter object.

set_legend(ax, lines)[source]

Add legend.

Parameters:
  • ax (object) – matplotlib figure axes.

  • lines (object) – matplotlib lines object.

set_title(fig)[source]

Add title.

Parameters:

fig (object) – matplotlib figure object.

set_xlabel()[source]

Add x label.

set_xlim()[source]

Set x axes limits.

set_ylabel(i)[source]

Add y label.

set_ylim()[source]

Set y axes limits.

update_values_to_plot(y_var_str)[source]

Update all values to plot.

Parameters:

y_var_str (str) – String or list of stringvalues to plot on the y axis.

posydon.visualization.plot2D

Plotting class for 2D (MESA) psygrids.

The 2D visualization plotting class allows to plot 2D slices of PsyGrid objects. The PsyGrid object is composed of 2D/3D/4D MESA grid run with POSYDON and post processed with the psygrid object into an h5 file.

class posydon.visualization.plot2D.plot2D(psygrid, x_var_str, y_var_str, z_var_str=None, selected_star_history_for_z_var=1, termination_flag='termination_flag_1', grid_3D=False, slice_3D_var_str=None, slice_3D_var_range=None, grid_4D=False, slice_4D_var_str=None, slice_4D_var_range=None, extra_grid=None, slice_at_RLO=False, MARKERS_COLORS_LEGENDS=None, max_cols=3, legend_pos=(3, 3), verbose=False, **kwargs)[source]

Bases: object

Plotting class for 2D (MESA) grids.

Read a PsyGrid object and plot a 2D slice of x vs y.

Parameters:
  • psygrid (object) – PsyGrid object containing a 2D/3D/4D MESA grid.

  • x_var_str (str) – String of the initial value to plot on the x axis. Allowed strings are psygrid.initial_values.dtype.names.

  • y_var_str (str) – String of the initial value to plot on the y axis. Allowed strings are psygrid.initial_values.dtype.names.

  • z_var_str (str) – String of the initial value to plot on the z axis (displayed as a color). Allowed strings are psygrid.final_values.dtype.names, psygrid.history1.dtype.names or psygrid.history2.dtype.names depending on “selected_star_history_for_z_var” value, and psygrid.binary_history.dtype.names.

  • selected_star_history_for_z_var (int) – Accepted valuess: 1 or 2. In case z_var_str is an attribute of history1 or history2, then selected_star_history_for_z_var determines which of the two to select.

  • termination_flag (str) – Termination flag to display, allowed values are: “termination_flag_1”, “termination_flag_2”, “termination_flag_3”, “termination_flag_4”, “all”.

  • grid_3D (bool) – If True, the psygrid object is a 3D grid and needs to be sliced.

  • slice_3D_var_str (str) – Variable along which the 3D space will be sliced. Allowed values are psygrid.initial_values.dtype.names.

  • slice_3D_var_range (tuple or a list of tuples) – Range between which you want to slice the variable slice_3D_var_str e.g., (2.5,3.). In case of a list of tuples, one will get a large plot with one subplot for each tuple in the list.

  • grid_4D (bool) – If True, the psygrid object is a 4D grid and needs to be sliced.

  • slice_4D_var_str (str) – Variable along which the 4D space will be sliced. Allowed values are psygrid.initial_values.dtype.names.

  • slice_4D_var_range (tuple or a list of tuples) – Range between which you want to slice the variable slice_4D_var_str e.g., (2.5,3.). In case of a list of tuples, one will get a large plot with one subplot for each tuple in the list.

  • extra_grid (object or array of objects) – If subset of the grid was rerun a or an extention was added, one can overlay the new psygrid by passing it here.

  • slice_at_RLO (bool) – If True, the object plots the tracks until onset of Roche Lobe overflow.

  • MARKERS_COLORS_LEGENDS (dict) – Each termination flag is associated with a marker shape, size, color and label (cf. MARKERS_COLORS_LEGENDS in plot_defaults.py).

  • DEFAULT_LABELS (dict) – Each varaible is associated to an axis label. (cf. DEFAULT_LABELS in plot_defaults.py).

  • max_cols (int) – Defines the maximum number of columns of subplots. Default: 3

  • legend_pos (SubplotSpec (int or tuple)) – Defines which subplots won’t contain an axis but are used to display the legend there. Default: (3, 3)

  • verbose (bool) – If True, the object reports by printing to standard output.

  • **kwargs (dict) – Dictionary containing extra visualisation options (cf. PLOT_PROPERTIES in plot_defaults.py.

add_properties_to_final_values(termination_flag=None)[source]

Add extra initial values.

add_properties_to_initial_values()[source]

Add extra initial values.

get_x_var()[source]

Get x value to plot.

get_y_var()[source]

Get y value to plot.

get_z_var()[source]

Get z value to plot.

plot_panel(ax, extra_grid_call=False)[source]

Plot the 2D pannel.

Parameters:
  • ax (object) – matplotlib figure axes.

  • extra_grid_call (bool) – If True, one ore more extra grids are passed.

plot_panels(axs, l_ax=None, legend_idxs=[2])[source]

Plot the 2D panels.

Parameters:
  • axs (array of axes) – matplotlib figure axes. Its dimensions should be stored in self.n_cols and self.n_rows.

  • legend_idxs (list of indices) – Tells where to place the legend instead of a plot.

set_color_bar(scatter, ax=None)[source]

Add colorbar.

Parameters:
  • scatters (object) – matplotlib scatter object.

  • ax (object) – matplotlib figure axes.

set_legend(ax, scatters, scatters_legend)[source]

Add legend.

Parameters:
  • ax (object) – matplotlib figure axes.

  • scatters (object) – matplotlib scatter object.

  • scatters_legend (list of str) – List of strings which will be used as labels.

set_title(fig)[source]

Add title.

Parameters:

fig (object) – matplotlib figure object.

set_xlabel(ax=None)[source]

Add x label.

Parameters:

ax (object) – matplotlib figure axes.

set_xlim(ax=None)[source]

Set x axes limits.

Parameters:

ax (object) – matplotlib figure axes.

set_ylabel(ax=None)[source]

Add y label.

Parameters:

ax (object) – matplotlib figure axes.

set_ylim(ax=None)[source]

Set y axes limits.

Parameters:

ax (object) – matplotlib figure axes.

update_markers_colors_legends(termination_flag, MARKERS_COLORS_LEGENDS=None)[source]

Udpdate markers, colors and legend.

Parameters:
  • termination_flag (string) – Termination flag to display, allowed values are: “termination_flag_1”, “termination_flag_2”, “termination_flag_3”, “termination_flag_4”.

  • MARKERS_COLORS_LEGENDS (dict) – Each termination flag is associated with a marker shape, size, color and label.

update_values_to_plot(termination_flag)[source]

Update all values to plot.

Parameters:

termination_flag (string) – Termination flag to display, allowed values are: “termination_flag_1”, “termination_flag_2”, “termination_flag_3”, “termination_flag_4”.

posydon.visualization.plot_defaults

Default values for plotting routines.

This file contains the default parameters of each plotting routines. PLOT_PROPERTIES:

Each default plotting variable is contained in this dictionary.

DEFAULT_MARKERS_COLORS_LEGENDS:

Each termination condition is associated with a marker shape, size, color and label.

posydon.visualization.plot_defaults.add_flag_to_MARKERS_COLORS_LEGENDS(MARKERS_COLORS_LEGENDS, flag)[source]

Add not pre defined stuff to DEFAULT_MARKERS_COLORS_LEGENDS.

Parameters:
  • MARKERS_COLORS_LEGENDS (dict of lists) – Dictionary with flags as keys given a list with marker, size, color, and legend text for each flag.

  • flag (str) – The flag itself.

posydon.visualization.plot_pop

posydon.visualization.plot_pop.plot_grb_rate_density(z, rate_density, zmax=10., channels=False, grb_components=False, Perley16=False, **kwargs)[source]
posydon.visualization.plot_pop.plot_hist_properties(df, ax=None, df_intrinsic=None, df_observable=None, channel=None, show=True, path=None, alpha=0.5, range=None, bins=20, normalise=False, color=COLORS[0], label='', **kwargs)[source]
posydon.visualization.plot_pop.plot_merger_efficiency(met, merger_efficiency, show=True, path=None, channels=False)[source]
posydon.visualization.plot_pop.plot_merger_rate_density(z, rate_density, zmax=10., channels=False, GWTC3=False, label='DCO', **kwargs)[source]
posydon.visualization.plot_pop.plot_popsyn_over_grid_slice(pop, grid_type, met_Zsun, slices=None, channel=None, plot_dir='./', prop=None, prop_range=None, log_prop=False, alpha=0.3, s=5., show_fig=True, save_fig=True, close_fig=True, plot_extension='png', verbose=False)[source]
posydon.visualization.plot_pop.plot_rate_density(intrinsic_rates, channels=False, **kwargs)[source]