AstropyFitter1D#

class glue.core.fitters.AstropyFitter1D(**params)#

Bases: BaseFitter1D

A base class for wrapping astropy.modeling.

Subclasses must override model_cls fitting_cls to point to the desired Astropy model and fitter classes.

In addition, they should override label with a better label, and parameter_guesses() to generate initial guesses

Attributes Summary

fitting_cls

label

model_cls

param_names

Built-in mutable sequence.

Methods Summary

fit(x, y, dy, constraints)

Fit the model to data.

parameter_guesses(x, y, dy)

Provide initial guesses for each model parameter.

predict(fit_result, x)

Evaluate the model at a set of locations.

summarize(fit_result, x, y[, dy])

Return a textual summary of the fit.

Attributes Documentation

fitting_cls = None#
label = 'Base Astropy Fitter'#
model_cls = None#
param_names#

Methods Documentation

fit(x, y, dy, constraints)#

Fit the model to data.

This must be overriden by a subclass.

Parameters:
  • x (numpy.ndarray) – The x values of the data

  • y (numpy.ndarray) – The y values of the data

  • dy (numpy.ndarray) – 1 sigma uncertainties on each datum (optional)

  • constraints – The current value of the constraints property

  • options – kwargs for model hyperparameters.

Returns:

An object representing the fit result.

parameter_guesses(x, y, dy)#

Provide initial guesses for each model parameter.

The base implementation does nothing, and should be overridden

Parameters:
Returns:

A dict mapping {parameter_name: value guess} for each parameter

predict(fit_result, x)#

Evaluate the model at a set of locations.

This must be overridden in a subclass.

Parameters:
  • fit_result – The result from the fit method

  • x (numpy.ndarray) – Locations to evaluate model at

Returns:

model(x)

Return type:

numpy.ndarray

summarize(fit_result, x, y, dy=None)#

Return a textual summary of the fit.

Parameters:
  • fit_result – The return value from fit()

  • x – The x values passed to fit()

Returns:

A description of the fit result

Return type:

str