gcfit.analysis.ModelCollection#

class gcfit.analysis.ModelCollection(visualizers)#

Analysis and visualization of a collection of multiple models.

Provides easy and uniform access to the analysis and visualization of a collection of different model visualizer instances, representing either different clusters, or different representations of the same cluster.

This class is intimately tied to the analysis.RunCollection class, and provides it’s access to the models corresponding to each of it’s runs. The most likely way to initialize this class is therefore through the RunCollection.get_models/RunCollection.get_CImodels method.

Parameters:
visualizerslist of ModelVisualizer or CIModelVisualizer

List of model visualizer objects which will make up this collection. Note that they must all be of the same type (ModelVisualizer or CIModelVisualizer), and the other classes provided here (e.g. ObservationsVisualizer) will not work.

Methods

__init__(visualizers)

from_chains(chains, obs_list[, ci])

Initialize from a collection of parameter chains.

from_models(models[, obs_list])

Initialize from a collection of models.

iter_plots(plot_func[, yield_model])

Iterator yielding a call to plot_func for each visualizer.

load(filenames)

Load the model outputs previously saved in the a list of files.

save(filenames[, overwrite])

Save the model outputs of all visualizers in the a list of files.

save_plots(plot_func[, fn_pattern, save_kw, ...])

Iterate over calls to plot_func on each model and save the figures.

classmethod from_chains(chains, obs_list, ci=True, *args, **kwargs)#

Initialize from a collection of parameter chains.

Initializes a ModelCollection instance of either ModelVisualizer or `CIModelVisualizer`s based on a list of chains.

If each chain is an array of shape (Nsamples, Nparams), each visualizer will be initialized using from_chain, otherwise if size (Nparams), will be initialized using from_theta.

Parameters:
chainslist of np.ndarray[Nsamples, Nparams] or np.ndarray[Nparams]

List of parameter chains for each model, used to create each model. Either a single theta value or a full chain of values for each. Final axis of the chains must be of the size of the number of model parameters (13).

obs_listlist of gcfit.Observations or None

List of observations corresponding to each model.

cibool, optional

If True (default) creates collection of CIModelVisualizer, otherwise ModelVisualizer.

*args, **kwargs

Optional arguments passed to each individual visualizer init.

Returns:
ModelCollection

The created model collection object.

classmethod from_models(models, obs_list=None)#

Initialize from a collection of models.

Initializes a ModelCollection instance of single ModelVisualizer`s based on a list of already computed models. A `ModelVisualizer instance will be created for every given model.

Parameters:
modelslist of gcfit.Model

Collection of models to create a collection of visualizers for.

obs_listlist of gcfit.Observations, optional

List of observations corresponding to each model. Must be the same size as models. If None (default), all observations will attempt to be read from each model (as is default in ModelVisualizer).

Returns:
ModelCollection

The created model collection object.

iter_plots(plot_func, yield_model=False, *args, **kwargs)#

Iterator yielding a call to plot_func for each visualizer.

classmethod load(filenames)#

Load the model outputs previously saved in the a list of files.

save(filenames, overwrite=False)#

Save the model outputs of all visualizers in the a list of files.

save_plots(plot_func, fn_pattern=None, save_kw=None, size=None, *args, **kwargs)#

Iterate over calls to plot_func on each model and save the figures.

Iterates over the iter_plots function and saves all individual figures to separate files, under a custom iterative file naming schema.

Parameters:
plot_funcstr

The name of the plotting function called on each run.

fn_patternstr, optional

A format string, which is passed the argument “cluster” representing each model’s name, and is used to create the filename each figure is saved under. Defaults to f’./{cluster}_{plot_func[5:]}’.

save_kwdict, optional

Optional arguments are passed to the fig.savefig function.

size2-tuple of float, optional

Optional resizing of the figure, using fig.set_size_inches.

**kwargsdict

All other arguments are passed to iter_plots.