ysoisochrone.plotting¶
Module Contents¶
Functions¶
Plots the likelihood distributions and the best-fit age and mass. |
|
Plots the Hertzsprung–Russell diagram with the stars from df_prop and isochrones from the Isochrone class. Allows for custom selection of ages and masses to plot, with the option to manually set annotations for ages and masses (positions and rotations). |
|
Plots the likelihood function for stellar mass. |
|
Plots HR diagrams using isochrone tracks from two different models (‘Feiden2016’ and ‘Baraffe2015’). |
|
Plots the Python grid (interpolated onto IDL grid), IDL grid, and their differences for both Teff and L/Lo. |
Data¶
API¶
- ysoisochrone.plotting.style = None¶
- ysoisochrone.plotting.plot_bayesian_results(log_age_dummy, log_masses_dummy, L, best_age, best_mass, age_unc, mass_unc, source=None, save_fig=False, fig_save_dir='figure', customized_fig_name='', color_bestfit='red', color_likelihood='blue', cmap_likelihood='viridis')¶
Plots the likelihood distributions and the best-fit age and mass.
Args:
- log_age_dummy: [array]
The log of stellar ages.
- log_masses_dummy: [array]
The log of stellar masses.
- L: [2D array]
The likelihood function grid.
- best_age: [float]
The best-fit age in log scale.
- best_mass: [float]
The best-fit mass in log scale.
- age_unc: [list]
The uncertainty range for age.
- mass_unc: [list]
The uncertainty range for mass.
- source: [str, optional]
The source name for labeling the plot.
- save_fig: [bool, optional]
Whether to save the figure.
- fig_save_dir: [str, optional]
Directory to save the figure if save_fig is True.
- customized_fig_name [str, optional]:
Customized figure name.
- color_bestfit [str, optional]:
Customized color to show the best fit point and uncertainties
- color_likelihood [str, optional]:
Customized color to show the the likelihood function
- cmap_likelihood [str, optional]:
Customized color to show the the likelihood cmap
Output:
a formatted figure (or save to the fig_save_dir)
Returns:
1 if the code could be ran through
- ysoisochrone.plotting.plot_hr_diagram(isochrone, df_prop=None, ax_set=None, ages_to_plot=None, masses_to_plot=None, age_positions=None, mass_positions=None, age_rotation=None, mass_rotation=None, age_xycoords='data', mass_xycoords='data', color_stars='C0', color_zams='magenta', color_masses='darkred', color_ages='grey', color_masses_text='', color_ages_text='', linestyle_zams='-.', linestyle_masses='-', linestyle_ages='--', xlim_set=None, ylim_set=None, no_uncertainties=False, zams_curve=True, bool_mass_annotate=True, bool_age_annotate=True, bool_labels=True, teff_range=None, annotate_unit_age='all', annotate_unit_mass='none', bare=False)¶
Plots the Hertzsprung–Russell diagram with the stars from df_prop and isochrones from the Isochrone class. Allows for custom selection of ages and masses to plot, with the option to manually set annotations for ages and masses (positions and rotations).
Args:
- isochrone: [Isochrone]
An instance of the Isochrone class containing the evolutionary tracks with attributes: log_age, masses, logtlogl (2D array for Teff and L/Lo).
- df_prop: [pd.DataFrame, optional]
DataFrame containing the stellar properties with columns: [‘Source’, ‘Teff[K]’, ‘e_Teff[K]’, ‘Luminosity[Lsun]’, ‘e_Luminosity[Lsun]’]. If None, no scatter points are plotted.
- ax_set: [axes, optional] Default is None
If not None, the ax_set is the ax for the plot
- ages_to_plot: [list, optional]
List of ages in years to plot as isochrones (default: [0.5e6, 1.0e6, 2.0e6, 3.0e6, 5.0e6, 10.0e6, 30.0e6, 100.0e6]).
- masses_to_plot: [list, optional]
List of masses in solar masses to plot as mass tracks (default: [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]).
- age_positions: [list of tuples, optional]
List of (x, y) positions for age annotations. Default is automatic placement.
- mass_positions: [list of tuples, optional]
List of (x, y) positions for mass annotations. Default is automatic placement.
- age_rotation: [list, optional]
List of rotation angles (degrees) for the age annotations. Default is 0 for all.
- mass_rotation: [list, optional]
List of rotation angles (degrees) for the mass annotations. Default is 0 for all.
- age_xycoords: [str, optional]
The xycoords for the age annotate. Default is ‘data’. Refer to plt.annotate for details on this arg
- mass_xycoords: [str, optional]
The xycoords for the mass annotate. Default is ‘data’. Refer to plt.annotate for details on this arg
- color_stars: [str, optional]
The colors for the stars, default is the default color ‘C0’ in Python.
- color_zams: [str, optional]
The color for the zams line, default is ‘magenta’.
- color_masses: [str, optional]
The color for evolutionary tracks for each mass, default is ‘darkred’
- color_masses_text: [str, optional]
The color for texts for evolutionary tracks for each mass, default is the same as color_masses
- color_ages: [str, optional]
The color for isochrones for ages, default is ‘grey’
- color_ages_text: [str, optional]
The color for the texts for isochrones for ages, default is ‘black’
- linestyle_zams: [str, optional]
The linestyle for zams, default is ‘-.’ (solid dashed lines)
- linestyle_masses: [str, optional]
The linestyle for evolutionary tracks for each mass, default is ‘-’ (solid lines)
- linestyle_ages: [str, optional]
The linestyle for isochrones for ages, default is ‘–’ (dashed lines)
- xlim_set: [list, optional]
The xlim from left to right [xlim_left, xlim_right]; default is None, so the code set it automatically
- ylim_set: [list, optional]
The ylim from bottom to top [ylim_bottom, ylim_top]; default is None, so the code set it automatically
- no_uncertainties: [bool, optional]
Whether to assume no uncertainties in Teff and Luminosity (default: False).
- zams_curve: [bool, optional]
Whether to plot the curve of zero-age-main-sequence (default it True) If True, the evolutionary tracks after ZAMS will not be plotted
- bool_age_annotate: [bool, optional]
If true, add the annotate for ages (isochrones)
- bool_mass_annotate: [bool, optional]
If true, add the annotate for mass (tracks)
- bool_labels: [bool, optional]
If true, add the labels as legend
- teff_range: [None or np.array(), optional]
e.g., teff_range = np.array([3000, 3900]) If set to an array, the plotted isochrone will only cover from selected teff_range
- annotate_unit_age: [array, optional]
if ‘simple’ plot only the unit for one time if ‘all’ plot unit on all annotates if ‘none’ do not plot the unit
- annotate_unit_mass: [array, optional]
if ‘simple’ plot only the unit for one time if ‘all’ plot unit on all annotates if ‘none’ do not plot the unit
- bare: [bool, optional]
If true, just plot the scatters from the DataFrame, and the isochromes, but do not add the annotates, legend, nor the labels.
- ysoisochrone.plotting.plot_likelihood_1d(log_masses_dummy, likelihood, best_log_mass, lower_mass, upper_mass, source=None)¶
Plots the likelihood function for stellar mass.
Args:
- log_masses_dummy: [array]
Array of log10(mass) values from the evolutionary track.
- likelihood: [array]
Likelihood function evaluated for each mass point.
- best_log_mass: [float]
The best-fit log10 mass.
- lower_mass: [float]
The lower bound of the uncertainty in log10 mass.
- upper_mass: [float]
The upper bound of the uncertainty in log10 mass.
- source: [str, optional]
The source name to include in the plot title. Default is None.
- ysoisochrone.plotting.simple_plot_hr_diagram_feiden_n_baraffe(df_prop=None, ax_set=None)¶
Plots HR diagrams using isochrone tracks from two different models (‘Feiden2016’ and ‘Baraffe2015’).
- Args:
- df_prop: [pd.DataFrame, optional]
DataFrame containing the stellar properties with columns: [‘Source’, ‘Teff[K]’, ‘e_Teff[K]’, ‘Luminosity[Lsun]’, ‘e_Luminosity[Lsun]’]. If None, no scatter points are plotted.
- ax_set: [axes, optional] Default is None
If not None, the ax_set is the ax for the plot
- ysoisochrone.plotting.plot_comparison(log_age_idl, masses_idl, logtlogl_interp_py, logtlogl_idl, logtlogl_diff, logtlogl_diff_norm, gridnames=['Python', 'IDL'])¶
Plots the Python grid (interpolated onto IDL grid), IDL grid, and their differences for both Teff and L/Lo.
Args:
- log_age_idl: [array]
Array of log(age) values from the IDL grid.
- masses_idl: [array]
Array of mass values from the IDL grid.
- logtlogl_interp_py: [array]
Python-generated logtlogl data (Teff and L/Lo) interpolated onto the IDL grid.
- logtlogl_idl: [array]
IDL-generated logtlogl data (Teff and L/Lo).
- logtlogl_diff: [array]
Difference between interpolated Python and IDL logtlogl data.
- logtlogl_diff_norm: [array]
Normalized difference between interpolated Python and IDL logtlogl data.
- gridnames: [list of strings, optional]
The names of the grid names, default is Python and IDL