lib.samples.plotting.ProfilesPlotStyle¶
- class lib.samples.plotting.ProfilesPlotStyle(style=None, **kwargs)¶
Bases:
lib.samples.plotting.ParameterPlotStylePlotting style for profiles. It holds default attributes (
truths,colors, etc.) that can be set at initialization (style = ProfilesPlotStyle(colors='r')) or at any time usingupdate().Initialize
ProfilesPlotStyle.- Parameters
style (ProfilesPlotStyle, default=None) – A plotting style to start from, which will be updated with
kwargs.kwargs (dict) – Attributes for
ProfilesPlotStyle.
Methods
Return shallow copy of
self.deepcopyInstantiate and initalize class with state dictionary.
Return
valueif notNone, else attributenameif notNone, elsedefault.Return color corresponding to label
label.If parameters is
None, return varied parameters fromprofiles.Return default truth / reference values for parameters.
Same as
get(), but ensuring returned value is a list.Return parameters.
is_mpi_broadcastis_mpi_gatheredis_mpi_rootis_mpi_scatteredLoad class in numpy binary format from disk.
If different formats are possible, this method should between them based on file name extension.
log_criticallog_debuglog_errorlog_infolog_warningPlot 1D distribution of best fits.
Plot 2D distribution of best fits.
Plot best fit estimates for single parameter.
Plot best fit estimates for several parameters.
Make corner plot of best fits.
Save class to disk.
If different formats are possible, this method should between them based on file name extension.
Save figure to
filename.Update attibutes with those in
kwargs.Attributes
loggerMPI attributes
mpicommmpirootmpistate- 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
valueif notNone, else attributenameif notNone, elsedefault.- Parameters
name (string) – Attribute name. If
None, defaults todefault.value (object, default=None) – Value. If
None, returns attributename.default (object, default=None) – Default value.
- get_color(label, labels=None)¶
Return color corresponding to label
label. Ifcolorsis a list, return color at index oflabelin list of labelslabels.
- static get_default_parameters(parameters, profiles)¶
If parameters is
None, return varied parameters fromprofiles.
- 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, returntruthsif exists, else set all truths toNone. If'value', return list ofParameter.value.
- Returns
truths – Return single value if
parametersis 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 (seemake_list()) is taken asdefaultlength.
- 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
chainsthat contains this parameter.chains (list) – List of classes with
parametersattribute.
- Returns
toret – Return single parameter if
parametersis a single parameter (name).- Return type
- classmethod load(filename, mpiroot=0, mpicomm=None)¶
Load class in numpy binary format from disk. If the loaded state contains
__class__and that exists incls._registry, return instance ofcls._registry[__class__](instead ofcls).
- 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
Profilesinstances. Defaults toprofiles.parameter (Parameter, ParamName, string, tuple) – Parameter name.
select (string, default='min') – Rule to select the best fit in each
Profilesinstance.residual (string, default='parabolic_errors') – If not
None, divide distance to truth (or mean of truth isNone) by this quantity.truth (float, string, default=None) – Plot this truth / reference value for parameter. If
'value', takeParameter.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
Profilesinstances. Defaults toprofiles.parameters (tuple, list, ParameterCollection) – The two parameter name(s).
select (string, default='min') – Rule to select the best fit in each
Profilesinstance.residual (string, default='parabolic_errors') – If not
None, divide distance to truth (or mean of truth isNone) 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
Profilesinstances. Defaults toprofiles.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
Profilesinstance.truth (float, string, default=None) – Plot this truth / reference value for parameter. If
'value', takeParameter.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
Profilesinstances. Defaults toprofiles.parameters (list, ParameterCollection) – The parameter names.
ids (list, string) – Label(s) for input profiles.
labels (list, string) – Label(s) for best fits within each
Profilesinstance.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. Seeplot_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
Profilesinstances. Defaults toprofiles.parameters (tuple, list, ParameterCollection) – The two parameter name(s).
select (string, default='min') – Rule to select the best fit in each
Profilesinstance.residual (string, default='parabolic_errors') – If not
None, divide distance to truth (or mean of truth isNone) 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
ParamNameand tomatplotlib.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.