wsssss.plotting package

Submodules

wsssss.plotting.kipp module

wsssss.plotting.plotting module

This module contains various functions to create plots using MESA and/or GYRE data.

Examples

Create an HRD from a history file from the MS onwards using a simple mask to skip the PMS.

>>> import wsssss.load_data as ld
>>> import wsssss.plotting.plotting as pl
>>> hist = ld.History('path/to/LOGS/history.data')
>>> pl.make_hrd(hist, use_mask=hist.data.center_h1<hist.data.center_h1[0] * 0.99)
wsssss.plotting.plotting.calc_vhrd(hist, norm)
wsssss.plotting.plotting.plot_vhrd(f, ax, hist, vHRD_norm, use_mask, norm, add_cbar, add_label)
wsssss.plotting.plotting.make_vhrd(hist, add_cbar=True, vHRD_norm=1.0, use_mask=True, ax=None, bounds=None, add_label=False)
wsssss.plotting.plotting.plot_hrd_data(f, ax, hist, zdata, znorm, use_mask, norm, add_cbar, cmap, sdat=None, small_cbar=False, label_func=None, vmin=None, vmax=None, linecolor='k', linear=False, linestyle='-')
wsssss.plotting.plotting.make_hrd(hist, zdata=None, zlabel='', add_cbar=True, znorm=1.0, use_mask=None, ax=None, norm=None, cmap='viridis', add_const_rad=True, label_func=None, vmin=None, vmax=None, linecolor='k', linear=False)
wsssss.plotting.plotting.make_propagation(p, hist, xname='logR', l=1, ax=None, only_NS=True, do_reduced=False, only_reduced=False, add_legend=True, n_col_legend=3, fill_cavity=False, show_burn_level=0, do_numax=True)
wsssss.plotting.plotting.make_propagation2(p, hist, xname='logR', l=1, ax=None, only_NS=True, do_reduced=True, only_reduced=False, add_legend=True, fill_cavity=False, show_burn_level=0)
wsssss.plotting.plotting.make_echelle(gs, hist=None, ax=None, l_list=(0, 1, 2), offset='auto', delta_nu='weighted', prefix='profile', suffix='.data.GYRE.sgyre_l', freq_units='uHz', legend_loc='upper right')
wsssss.plotting.plotting.make_inertia(gs, ax=None, l_list=(0, 1, 2), freq_units='uHz', div=True, legend_loc='upper right', scale_marker=False)
wsssss.plotting.plotting.make_resolutions(profs, ax=None, yres=100, xname='model_number', yname='mass', zorder=0)
wsssss.plotting.plotting.make_hrd_profiles(hist, add_cbar=True, vHRD_norm=1.0, use_mask=True, ax=None, show_prof_num=-1)
wsssss.plotting.plotting.make_hrd_models(hist, add_cbar=True, vHRD_norm=1.0, use_mask=True, ax=None, show_mod_num=1000, bounds=None)
wsssss.plotting.plotting.make_age_nu(hist, gss, l=1, ax=None, gyre_summary_prefix='profile', gyre_summary_suffix='.data.GYRE.sgyre_l', age_unit='Myr', marker='k.')
wsssss.plotting.plotting.make_mesa_gyre_delta_nu(hist, gss, l_list=(0, 1, 2), xaxis='model_number', gyre_summary_prefix='profile', gyre_summary_suffix='.data.GYRE.sgyre_l', ax=None)
wsssss.plotting.plotting.make_composition(prof, elements='all', xname='mass', ax=None, add_burnmix=True, legend_loc='best', add_cbar=True, add_legend=False, add_label_lines=True, num_line_label=4, normalize_comp=False, grad=False, fontsize=7, hist=None)
wsssss.plotting.plotting.make_gradients(prof, xname='mass', hist=None, ax=None, add_legend=True, n_cols_legend=2)
wsssss.plotting.plotting.make_period_spacing(gs, hist=None, ax=None, freq_units='uHz', prefix='profile', suffix='.data.GYRE.sgyre_l', l_list=(0, 1, 2), legend_loc='upper right')
wsssss.plotting.plotting.make_structural(prof, ax=None, xname='mass', hist=None, normalize=False)
wsssss.plotting.plotting.make_eigenfunc_compare(gs, gefs, prof, hist, l_list=(1,), prop_y_lims=(3.0, 50000.0), eig_y_lims=None, x_lims=(0.001, 0.5), prop_kwargs={}, inertia_kwargs={})
wsssss.plotting.plotting.make_kipp(hist, profs=None, ax=None, xaxis='model_number', yaxis='mass', caxis='eps_net', zone_filename='zones_wsssss.dat', verbose=False, save_zones=True, clobber_zones=False, prof_prefix='profile', prof_suffix='.data', mixing_min_height=0, prof_resolution=500, xlims=None, ylims=None, clims=None, kwargs_mixing=None, norm=None, cmap=None, kwargs_profile_color=None, return_Kipp_data=False, parallel=True, ignore_monotonic=False, legend_loc=None, add_cbar=False)

Create a Kippenhahn diagram.

Parameters:
  • hist (History) – MESA History with which to create a Kippenhahn diagram.

  • profs (list of Profile, optional) – MESA Profile used to create a Kippenhahn diagram. Is optional if caxis=’eps_net’ and burning_regions in the history columns is used.

  • ax (matplotlib axes, optional) – Matplotlib figure axis. If set to None will create one.

  • xaxis (str, optional) – x-axis column name. Defaults to ‘model_number’.

  • yaxis (str, optional) – y-axis column name. Must be one of mass or radius. Defaults to mass.

  • caxis (str, optional) – colour-axis column name. Must be ‘eps_net’ or a column in Profile.

  • zone_filename (str, optional) – Filename of zonefile.

  • verbose (bool, optional) – If True, prints extra information.

  • save_zones (bool, optional) – If True, will cache Kippenhahn regions in zone_filename.

  • clobber_zones (bool, optional) – If True, will generate Kippenhahn regions from scratch.

  • prof_prefix (str, optional) – Profile file name prefix.

  • prof_suffix (str, optional) – Profile file name suffix.

  • prof_resolution (int, optional) – y-axis resolution for Profiles.

  • mixing_min_height (float, optional) – Minimum fractional vertical extent of mixing region. If smaller, the region is not plotted.

  • xlims (length 2 array, optional) – Lower and upper limits of the x-axis.

  • ylims (length 2 array, optional) – Lower and upper limits of the y-axis.

  • clims (length 2 array, optional) – Lower and upper limits of the colour-axis. Cannot be used at the same time with norm.

  • kwargs_mixing (dict, optional) – kwargs used to draw mixing regions, if None, defaults to plotting.utils.pu.get_default_mixing_kwargs().

  • norm (optional) – Matplotlib normalize class.

  • cmap (optional) – Matplotlib colormap.

  • kwargs_profile_color (dict, optional) – Passed to tripcolor in add_color.

  • return_Kipp_data (bool, optional) – If True, also returns Kipp_data.

  • parallel (bool, optional) – If True, calculate Kippenhahn regions in parallel.

  • legend_loc (str, optional) – If set, create a legend along that side. Can be ‘top’ or ‘right’.

  • add_cbar (bool, optional) – If True, will create a colorbar for the color axis.

Returns:

Figure, axis, and optionally Kipp_data of the Kippenhahn diagram.

Return type:

tuple of matplotlib.figure.Figure, matplotlib.axes._axes.Axes, and optionally Kipp_data

wsssss.plotting.utils module

class wsssss.plotting.utils.HandlerDashedLines(marker_pad=0.3, numpoints=None, **kwargs)

Bases: HandlerLineCollection

Custom Handler for LineCollection instances.

create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)

Return the legend artists generated.

Parameters:
  • legend (~matplotlib.legend.Legend) – The legend for which these legend artists are being created.

  • orig_handle (~matplotlib.artist.Artist or similar) – The object for which these legend artists are being created.

  • xdescent (int) – The rectangle (xdescent, ydescent, width, height) that the legend artists being created should fit within.

  • ydescent (int) – The rectangle (xdescent, ydescent, width, height) that the legend artists being created should fit within.

  • width (int) – The rectangle (xdescent, ydescent, width, height) that the legend artists being created should fit within.

  • height (int) – The rectangle (xdescent, ydescent, width, height) that the legend artists being created should fit within.

  • fontsize (int) – The fontsize in pixels. The legend artists being created should be scaled according to the given fontsize.

  • trans (~matplotlib.transforms.Transform) – The transform that is applied to the legend artists being created. Typically from unit coordinates in the handler box to screen coordinates.

class wsssss.plotting.utils.MidpointBoundaryNorm(boundaries, ncolors, midpoint, clip=False, away_from_midpoint=True, singular_midpoint=True)

Bases: BoundaryNorm

Generate a colormap index based on discrete intervals.

Unlike Normalize or LogNorm, MidpointBoundaryNorm maps values to integers instead of to the interval 0-1.

Mapping to the 0-1 interval could have been done via piece-wise linear interpolation, but using integers seems simpler, and reduces the number of conversions back and forth between integer and floating point.

__init__(boundaries, ncolors, midpoint, clip=False, away_from_midpoint=True, singular_midpoint=True)
Parameters:
  • boundaries (array-like) – Monotonically increasing sequence of boundaries.

  • ncolors (int) – Number of colors in the colormap to be used.

  • midpoint (scalar) – Value to assign the middle color to.

  • clip (bool, optional) –

    If clip is True, out of range values are mapped to 0 if they are below boundaries[0] or mapped to ncolors - 1 if they are above boundaries[-1].

    If clip is False, out of range values are mapped to -1 if they are below boundaries[0] or mapped to ncolors if they are above boundaries[-1]. These are then converted to valid indices by Colormap.__call__().

  • away_from_midpoint (bool, optional) – If away_from_midpoint is True, determine colors away from the midpoint value instead of all in one direction.

  • singular_midpoint (bool, optional) – If singular_midpoint is True, only values which equal midpoint are set to that color. Only used when away_from_midpoint is True.

Notes

boundaries defines the edges of bins, and data falling within a bin is mapped to the color with the same index.

If the number of bins doesn’t equal ncolors, the color is chosen by linear interpolation of the bin number onto color numbers.

inverse(value)
Raises:

ValueError – MidpointBoundaryNorm is not invertible, so calling this method will always raise an error

wsssss.plotting.utils.get_figure(ax)
wsssss.plotting.utils.top_legend(ax, ncol=2, **kwargs)
wsssss.plotting.utils.top_figure_legend(f, ncol, top=0.9, **kwargs)
wsssss.plotting.utils.side_figure_legend(f, ncol, right=0.75, **kwargs)
wsssss.plotting.utils.colored_line(f, ax, xdat, ydat, cdat, norm=None, cmap='viridis', lw=2, add_cbar=True, do_lims=False, **kwargs)
wsssss.plotting.utils.hrd_const_rad(ax, fontsize=8, radii=None, angle=None, linear=False)
wsssss.plotting.utils.get_x_and_set_xlabel(p, xname, ax=None, func_on_xaxis=None, hist=None)
wsssss.plotting.utils.get_mix_dict(profile)
wsssss.plotting.utils.get_mixing(profile, min_width)
Parameters:
  • profile

  • min_width

Returns:

wsssss.plotting.utils.get_default_mixing_kwargs()

Get the default coloring scheme for mixing. :returns:

Each dict contains kwargs for PathPatch and show, which if False mean that it will not be

drawn.

Return type:

dict of dict

wsssss.plotting.utils.add_mixing(ax, profile, xname='mass', min_width=5, ymin=0, ymax=1, alpha=1, add_legend=True, func_on_xaxis=None, kwargs_mixing=None)

kwargs_mixing (dict, optional): kwargs used to draw mixing regions, if None, defaults to plotting.utils.get_default_mixing_kwargs().

wsssss.plotting.utils.add_burning(ax, profile, xname='mass', ymin=0, ymax=1, num_levels=None, vmin=-2, vmax=8, add_cbar=True, kind='net_nuclear_energy', norm=None, kipp_scaling=True, func_on_xaxis=None)
wsssss.plotting.utils.add_hrd_instabilities(ax, classic=True, sdB=True)
wsssss.plotting.utils.calc_inertia_marker_size(gs, l, freq_units='uHz')
wsssss.plotting.utils.line_legend(ax, edge_space=0.05, num_line_label=4, fontsize=7, background=None, background_width=3, ignore_nolabel=False)
wsssss.plotting.utils.decimate_RDP(pts, epsilon, return_index=False)

Ramer–Douglas–Peucker decimation algorithm with some adjustments. :param pts: 2-d array containing points to decimate. :type pts: np.array :param epsilon: Tolerance for keeping line segments :param return_index: If True, return indeces instead of values. Defaults to False. :type return_index: bool, optional

Returns:

Decimated version of pts.

Return type:

np.array

Module contents