ModelFit

class gdt.core.plot.model.ModelFit(fitter=None, canvas=None, view='counts', resid=True, interactive=True)[source]

Bases: GdtPlot

Class for plotting spectral fits.

Parameters:
  • fitter (SpectralFitter, optional) – The spectral fitter

  • view (str, optional) – The plot view, one of ‘counts’, ‘photon’, ‘energy’ or ‘nufnu’. Default is ‘counts’

  • resid (bool, optional) – If True, plots the residuals in counts view. Default is True.

  • **kwargs – Options to pass to GdtPlot

Attributes Summary

ax

The matplotlib axes object for the plot

canvas

The plotting canvas, if set upon initialization.

colors

A list of default plotting colors to cycle through

count_data

(PlotElementCollection of ModelData): The count data plot elements

count_models

(PlotElementCollection of Histo): The count model plot elements

fig

The matplotlib figure object

residuals

(PlotElementCollection of ModelData): The fit residual plot elements

spectrum_model

(PlotElementCollection of ModelSamples): The model spectrum sample elements

view

The current plot view

xlim

The plotting range of the x axis

xscale

The scale of the x axis, either 'linear' or 'log'.

ylim

The plotting range of the y axis.

yscale

The scale of the y axis, either 'linear' or 'log'.

Methods Summary

count_spectrum()

Plot the count spectrum fit.

energy_spectrum(**kwargs)

Plot the energy spectrum model.

hide_residuals()

Hide the fit residuals.

nufnu_spectrum(**kwargs)

Plot the nuFnu spectrum model.

photon_spectrum(**kwargs)

Plot the photon spectrum model.

set_fit(fitter[, resid])

Set the fitter.

show_residuals([sigma])

Show the fit residuals.

Attributes Documentation

ax

The matplotlib axes object for the plot

Type:

(matplotlib.axes)

canvas

The plotting canvas, if set upon initialization.

Type:

(Canvas Backend object)

colors = ['#7F3C8D', '#11A579', '#3969AC', '#F2B701', '#E73F74', '#80BA5A', '#E68310', '#008695', '#CF1C90', '#f97b72', '#4b4b8f', '#A5AA99']

A list of default plotting colors to cycle through

Type:

(list)

count_data

(PlotElementCollection of ModelData): The count data plot elements

count_models

(PlotElementCollection of Histo): The count model plot elements

fig

The matplotlib figure object

Type:

(matplotlib.figure)

residuals

(PlotElementCollection of ModelData): The fit residual plot elements

spectrum_model

(PlotElementCollection of ModelSamples): The model spectrum sample elements

view

The current plot view

Type:

(str)

xlim

The plotting range of the x axis

Type:

(float, float)

xscale

The scale of the x axis, either ‘linear’ or ‘log’.

Type:

(str)

ylim

The plotting range of the y axis.

Type:

(float, float)

yscale

The scale of the y axis, either ‘linear’ or ‘log’.

Type:

(str)

Methods Documentation

count_spectrum()[source]

Plot the count spectrum fit.

energy_spectrum(**kwargs)[source]

Plot the energy spectrum model.

Parameters:
  • num_samples (int, optional) – The number of sample spectra. Default is 100.

  • plot_components (bool, optional) – Set to False to only plot the overall model, not each component. Default is False.

hide_residuals()[source]

Hide the fit residuals.

nufnu_spectrum(**kwargs)[source]

Plot the nuFnu spectrum model.

Parameters:
  • num_samples (int, optional) – The number of sample spectra. Default is 100.

  • plot_components (bool, optional) – Set to False to only plot the overall model, not each component. Default is False.

photon_spectrum(**kwargs)[source]

Plot the photon spectrum model.

Parameters:
  • num_samples (int, optional) – The number of sample spectra. Default is 10.

  • plot_components (bool, optional) – Set to False to only plot the overall model, not each component. Default is False.

set_fit(fitter, resid=False)[source]

Set the fitter. If a fitter already exists, this triggers a replot of the fit.

Parameters:
  • fitter (SpectralFitter) – The spectral fitter for which a fit has been performed

  • resid (bool, optional) – If True, plot the fit residuals

show_residuals(sigma=True)[source]

Show the fit residuals.

Parameters:

sigma (bool, optional) – If True, plot the residuals in units of model sigma, otherwise in units of counts. Default is True.