lib.samples.plotting.ProfilesPlotStyle

class lib.samples.plotting.ProfilesPlotStyle(style=None, **kwargs)

Bases: lib.samples.plotting.ParameterPlotStyle

Plotting style for profiles. It holds default attributes (truths, colors, etc.) that can be set at initialization (style = ProfilesPlotStyle(colors='r')) or at any time using update().

Initialize ProfilesPlotStyle.

Parameters

Methods

copy

Return shallow copy of self.

deepcopy

from_state

Instantiate and initalize class with state dictionary.

get

Return value if not None, else attribute name if not None, else default.

get_color

Return color corresponding to label label.

get_default_parameters

If parameters is None, return varied parameters from profiles.

get_default_truths

Return default truth / reference values for parameters.

get_list

Same as get(), but ensuring returned value is a list.

get_parameters

Return parameters.

is_mpi_broadcast

is_mpi_gathered

is_mpi_root

is_mpi_scattered

load

Load class in numpy binary format from disk.

load_auto

If different formats are possible, this method should between them based on file name extension.

log_critical

log_debug

log_error

log_info

log_warning

plot_1d

Plot 1D distribution of best fits.

plot_2d

Plot 2D distribution of best fits.

plot_aligned

Plot best fit estimates for single parameter.

plot_aligned_stacked

Plot best fit estimates for several parameters.

plot_corner

Make corner plot of best fits.

save

Save class to disk.

save_auto

If different formats are possible, this method should between them based on file name extension.

savefig

Save figure to filename.

update

Update attibutes with those in kwargs.

Attributes

logger

mpiattrs

MPI attributes

mpicomm

mpiroot

mpistate

copy()

Return shallow copy of self.

classmethod from_state(state, mpiroot=0, mpicomm=None)

Instantiate and initalize class with state dictionary.

get(name, value=None, default=None)

Return value if not None, else attribute name if not None, else default.

Parameters
  • name (string) – Attribute name. If None, defaults to default.

  • value (object, default=None) – Value. If None, returns attribute name.

  • default (object, default=None) – Default value.

get_color(label, labels=None)

Return color corresponding to label label. If colors is a list, return color at index of label in list of labels labels.

static get_default_parameters(parameters, profiles)

If parameters is None, return varied parameters from profiles.

get_default_truths(parameters, truths=None)

Return default truth / reference values for parameters.

Parameters
  • parameters (Parameter, tuple, list, ParameterCollection) – Parameters to return truth values for.

  • truths (list, default=None) – List of truth values. If None, return truths if exists, else set all truths to None. If 'value', return list of Parameter.value.

Returns

truths – Return single value if parameters is a single parameter.

Return type

float, list

get_list(name, value=None, default=None)

Same as get(), but ensuring returned value is a list. Default length (see make_list()) is taken as default length.

static get_parameters(parameters, chains=None)

Return parameters.

Parameters
  • parameters (tuple, list, ParameterCollection) – List of parameter (names). If parameter name, get the xorresponding parameter in the first element in chains that contains this parameter.

  • chains (list) – List of classes with parameters attribute.

Returns

toret – Return single parameter if parameters is a single parameter (name).

Return type

Parameter, ParameterCollection

classmethod load(filename, mpiroot=0, mpicomm=None)

Load class in numpy binary format from disk. If the loaded state contains __class__ and that exists in cls._registry, return instance of cls._registry[__class__] (instead of cls).

load_auto(*args, **kwargs)

If different formats are possible, this method should between them based on file name extension.

property mpiattrs

MPI attributes

plot_1d(profiles=None, parameter=None, select='min', residual='parabolic_errors', truth=None, filename=None, **kwargs)

Plot 1D distribution of best fits.

Parameters
  • profiles (list, default=None) – List of Profiles instances. Defaults to profiles.

  • parameter (Parameter, ParamName, string, tuple) – Parameter name.

  • select (string, default='min') – Rule to select the best fit in each Profiles instance.

  • residual (string, default='parabolic_errors') – If not None, divide distance to truth (or mean of truth is None) by this quantity.

  • truth (float, string, default=None) – Plot this truth / reference value for parameter. If 'value', take Parameter.value.

  • filename (string, default=None) – If not None, file name where to save figure.

  • kwargs (dict) – Arguments for SamplesPlotStyle.plot_1d().

Returns

ax

Return type

matplotlib.axes.Axes

plot_2d(profiles=None, parameters=None, select='min', residual='parabolic_errors', truths=None, filename=None, **kwargs)

Plot 2D distribution of best fits.

Parameters
  • profiles (list, default=None) – List of Profiles instances. Defaults to profiles.

  • parameters (tuple, list, ParameterCollection) – The two parameter name(s).

  • select (string, default='min') – Rule to select the best fit in each Profiles instance.

  • residual (string, default='parabolic_errors') – If not None, divide distance to truth (or mean of truth is None) by this quantity.

  • truths (list, default=None) – Plot this truths / reference values for parameters. See get_default_truths().

  • filename (string, default=None) – If not None, file name where to save figure.

  • kwargs (dict) – Arguments for SamplesPlotStyle.plot_2d().

Returns

ax

Return type

matplotlib.axes.Axes

plot_aligned(profiles=None, parameter=None, ids=None, labels=None, truth=None, yband=None, ax=None, filename=None)

Plot best fit estimates for single parameter.

Parameters
  • profiles (list, default=None) – List of Profiles instances. Defaults to profiles.

  • parameter (Parameter, ParamName, string, tuple) – Parameter name.

  • ids (list, string) – Label(s) for input profiles.

  • labels (list, string) – Label(s) for best fits within each Profiles instance.

  • truth (float, string, default=None) – Plot this truth / reference value for parameter. If 'value', take Parameter.value.

  • yband (float, tuple, default=None) – If not None, plot horizontal band. If tuple and last element set to 'abs', absolute lower and upper y-coordinates of band; lower and upper fraction around truth. If float, fraction around truth.

  • ax (matplotlib.axes.Axes, default=None) – Axes where to plot profiles. If None, takes current axes.

  • filename (string, default=None) – If not None, file name where to save figure.

Returns

ax

Return type

matplotlib.axes.Axes

plot_aligned_stacked(profiles=None, parameters=None, ids=None, labels=None, truths=None, ybands=None, ylimits=None, filename=None)

Plot best fit estimates for several parameters.

Parameters
  • profiles (list, default=None) – List of Profiles instances. Defaults to profiles.

  • parameters (list, ParameterCollection) – The parameter names.

  • ids (list, string) – Label(s) for input profiles.

  • labels (list, string) – Label(s) for best fits within each Profiles instance.

  • truths (list, default=None) – Plot this truths / reference values for parameters. See get_default_truths().

  • ybands (list, default=None) – If not None, plot horizontal bands. See plot_aligned().

  • ylimits (list, default=None) – If not None, limits for y axis.

  • filename (string, default=None) – If not None, file name where to save figure.

Returns

  • fig (matplotlib.figure.Figure) – Figure.

  • lax (array) – Array of axes.

plot_corner(profiles=None, parameters=None, select='min', residual='parabolic_errors', truths=None, **kwargs)

Make corner plot of best fits.

Parameters
  • profiles (list, default=None) – List of Profiles instances. Defaults to profiles.

  • parameters (tuple, list, ParameterCollection) – The two parameter name(s).

  • select (string, default='min') – Rule to select the best fit in each Profiles instance.

  • residual (string, default='parabolic_errors') – If not None, divide distance to truth (or mean of truth is None) by this quantity.

  • truths (list, default=None) – Plot this truths / reference values for parameters. See get_default_truths().

  • filename (string, default=None) – If not None, file name where to save figure.

  • kwargs (dict) – Arguments for SamplesPlotStyle.plot_corner().

Returns

  • fig (matplotlib.figure.Figure) – Figure.

  • dax (dict) – Dictionary of ParamName and to matplotlib.axes.Axes: name: axes for 1D plots and (name1, name2): axes for 2D plots.

save(filename)

Save class to disk.

save_auto(*args, **kwargs)

If different formats are possible, this method should between them based on file name extension.

savefig(filename, fig=None)

Save figure to filename.

Parameters
  • filename (string) – Path where to save figure.

  • fig (matplotlib.figure.Figure, default=None) – Figure to save. Defaults to current figure.

update(**kwargs)

Update attibutes with those in kwargs.