Fitting in redback returns a redback.result object. This object provides a homogenous format for all further analysis and plotting the results of the fitting. The redback.result object inherits from the bilby.result object so all functionality in the bilby.result such as making pp_plots, walker_plots, getting credible intervals etc. is automatically implemented. See the bilby API for a full list of features.

The result file is by default saved to the transient/transient_name/model/, but the user can of course change this. It is by default saved in a json format, which can be changed to ‘hdf5’ for more compression.

Fitting your favourite transient

The interface to fit is simple. Once a user has defined a transient object, a model object and a prior object, the user can fit the data via,

result = redback.fit_model(transient, model, priors)

The more advanced user can change things such as the sampler/likelihood etc

Changing the likelihood used for fitting

Some advanced users may wish to change the default likelihood used in redback to another likelihood implemented in redback or use a likelihood. For example, you may want to fit an additional noise source. Or fit non-detections. Or fit with errors in time etc.

Changing the likelihood used can be done easily by

import redback
transient = redback.transient.Transient(transient_name, data_mode, filters)
likelihood = redback.likelihood.Likelihood(transient, model)
result = redback.fit_model(likelihood, priors, sampler, outdir=outdir, label=label)

Plotting lightcurves and corner plots

Plotting a corner plot is as simple as


The user can pass in different keyword arguments to change the look/format/what parameters are plotted. See the bilby API.

We can also plot the fit


Here the first line will plot the lightcurve on a single panel with a 100 random models randomly drawn from the posterior and the maximum likelihood model. The second line will plot the lightcurve on multiple panels, each panel corresponding to a particular band/frequency.

In both functions, users can pass additional keyword arguments to change the aesthetics or what is plotted. See the redback API for more details.

Further analysis

The result file provides the posterior values as a pandas data frame accessible via result.posterior. Other properties such as the evidence etc are also stored.

These posteriors and properties can be used for further analysis such as different diagnostic plots, model selection, reweighting or hierarchical inference.

The redback.analysis object enables users to easily make plots for diagnostics or further plots for specific models/transients.

Loading a result file

We also provide functionality for loading in a result file.

import redback

Here filepath is the path to file, the result file recreates the transient object exactly as it was used when fitted. This ensures users can keep their results consistent with the data_mode/filters etc of the transient they chose.