posydon.visualization
posydon.visualization.VHdiagram
The definition of the VHdiagram class.
posydon.visualization.combine_TF
Module for combining termination flags for visualization purposes.
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
- confusion_matrix(key, params={}, save_path=None, close_fig=False)[source]
Method that plots confusion matrices to evaluate classification
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.
- set_color_bar(scatter)[source]
Add colorbar.
- Parameters:
scatters (object) – matplotlib scatter object.
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.
- 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.
- 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.
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_pop
- posydon.visualization.plot_pop.get_population_data(pop, metallicity, grid_type, channel=None, prop=None)[source]
get the population data of a given metallicity for plotting
- Parameters:
pop (Population) – Population object
metallicity (float) – Metallicity of the population in solar units
grid_type (str) – Grid type to get data for. Options are ‘HMS-HMS’, ‘CO-HMS_RLO’, ‘CO-HeMS’, ‘CO-HeMS_RLO’.
channel (str) – Formation channel to be plotted
- Returns:
data – Population data of the given metallicity and channel and grid type
- Return type:
DataFrame
- posydon.visualization.plot_pop.plot_grid_slice(grid, slice_3D_var_str, slice_3D_var_range, termination_flag='combined_TF12', PLOT_PROPERTIES=None)[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_perley16_rate_density(ax=None)[source]
Plot the GRB rate density from Perley et al. (2016)
plot the long gamma-ray burst rate density from Perley et al. (2016) if ax is None, it plotted on the latest axis, otherwise it is added to the given axis
- Parameters:
ax (matplotlib.axes.Axes (optional)) – Axes object to plot the data on
- posydon.visualization.plot_pop.plot_popsyn_over_grid_slice(pop, grid_type, met_Zsun, termination_flag='combined_TF12', 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]
Plot the population synthesis data over a grid slice
Outputs one or multiple plots of the population synthesis data over a grid slice. Either stores the plots in a directory or shows them.
- Parameters:
pop (Population) – Population object
grid_type (str) – Grid type to get data for. Options are ‘HMS-HMS’, ‘CO-HMS_RLO’, ‘CO-HeMS’, ‘CO-HeMS_RLO’.
met_Zsun (float) – Metallicity of the population in solar units
termination_flag (str) – Termination flag for the grid
slices (list (optional)) – List of slices to plot
channel (str (optional)) – Formation channel to be plotted
plot_dir (str (optional)) – Directory to save the plots
prop (str (optional)) – Property to plot on top of the grid slice
prop_range (list (optional)) – Range of the property to plot
log_prop (bool (optional)) – Logarithmic scale for the property
alpha (float (optional)) – Transparency of the data points
s (float (optional)) – Size of the data points
show_fig (bool (optional)) – Show the figure
save_fig (bool (optional)) – Save the figure
close_fig (bool (optional)) – Close the figure
plot_extension (str (optional)) – File extension for saving the plot
verbose (bool (optional)) – Print information
- posydon.visualization.plot_pop.plot_population_data(data, slice_3D_var_str, slice_3D_var_range, prop=None, prop_range=None, log_prop=False, alpha=0.3, s=5)[source]
Plot the population data based on the grid slice parameters
- Parameters:
data (DataFrame) – Population data
slice_3D_var_str (str) – String of the 3D variable to slice the grid
slice_3D_var_range (list) – Range of the 3D variable to slice the grid
prop (str (optional)) – Property to plot on top of the grid slice
prop_range (list (optional)) – Range of the property to plot
log_prop (bool (optional)) – Logarithmic scale for the property
alpha (float (optional)) – Transparency of the data points
s (float (optional)) – Size of the data points
- posydon.visualization.plot_pop.plot_rate_density(intrinsic_rates, channels=False, **kwargs)[source]
- posydon.visualization.plot_pop.setup_grid_slice_plotting(grid, grid_type, plot_extension)[source]
Setup the values for plotting the grid slice
- Parameters:
- Returns:
bin_centers (list) – List of bin centers
bin_edges (list) – List of bin edges
PLOT_PROPERTIES (dict) – Dictionary of plot properties
slice_3D_var_str (str) – String of the 3D variable to slice the grid
tmp_fname (str) – Template file name for saving the plot