Common fitting models¶
Several often needed models are shipped with funcFit.
- Common fitting model available
Gaussian profile (class
GaussFit1d
)Multicomponent Gaussian (class
MultiGauss1d
)Cauchy-Lorentz profile (class
CauchyLorentz1d
)Voigt profile (class
Voigt1d
)Multicomponent Voigt (class
MultiVoigt1d
)Sine wave (class
SinusFit1d
)Exponential decay (class
ExpDecayFit1d
)Polynomial of degree n (class
PolyFit1d
)Hyperbolic secant (class
Sech1d
)Constant (class
ConstantFit1d
)2d Gaussian (class
GaussFit2d
)Multicomponent 2d Gaussian (class
MultiGauss2d
)
The use of these models is demonstrated in the tutorial.
Single Gaussian with linear continuum¶
- class PyAstronomy.funcFit.GaussFit1d(prm=('A', 'sig'))¶
A one-dimensional Gaussian
The functional form is:
\[\frac{A}{\sqrt{2\pi\sigma^2}}e^{-(x-\mu)^2/(2\sigma^2)} + x \times lin + off\]Here, lin and off denote the linear and the offset term.
- Fit parameters:
A - Area of the Gaussian (formerly called Amplitude)
mu - Center of the Gaussian
sig - Standard deviation
off - Offset
lin - Linear term
Note
Other parameterizations using FWHM and ‘height’ of the curve can be used.
- Parameters
- prmoptional tuple of two strings, {(“A”, “sig”), (“h”, “sig”), (“A”, “FWHM”), (“h”, “FWHM”)}
Can be used to adapt the parameterization of the Gaussian. By default, the curve is parameterized by Area (A) and standard deviation (sig). Alternatively, also the height (h) of the curve (h = A/sqrt(2*pi*sig**2)) and the Full Width at Half Maximum (FWHM) can be used. The naming of the fit parameters is updated accordingly.
Methods
MCMCautoParameters
(ranges[, picky, ...])Convenience function to generate parameters for MCMC fit.
addConditionalRestriction
(*args)Define a conditional restriction.
assignValue
(specval)Assign new values to variables.
assignValues
(specval)Assign new values to variables.
autoFitMCMC
(x, y, ranges[, picky, stepsize, ...])Convenience function to using auto-generated sampling parameters in MCMC.
availableParameters
()Provides a list of existing parameters.
delRestriction
(parName)Delete restriction
description
([parenthesis])Returns a description of the model based on the names of the individual components.
errorConfInterval
(par[, dstat, statTol, ...])Calculate confidence interval for a parameter.
evaluate_h_sig
(x, h, sig)Evaluates the model for given height and standard deviation (sig)-
fit
(x, y[, yerr, X0, minAlgo, mAA, ...])Carries out a fit.
fitEMCEE
([x, y, yerr, nwalker, priors, ...])MCMC sampling using emcee package.
fitMCMC
(x, y, X0, Lims, Steps[, yerr, ...])Carry out MCMC fit/error estimation.
freeParamNames
()Get the names of the free parameters.
freeParameters
()Get names and values of free parameters.
freeze
(specifiers)Consider variables free to float.
frozenParameters
()Get names and values of frozen parameters.
getRelationsOf
(specifier)Return relations of a variable.
getRestrictions
()Get all restrictions.
hasVariable
(specifier)Determine whether the variable exists.
numberOfFreeParams
()Get number of free parameters.
parameterSummary
([toScreen, prefix, sorting])Writes a summary of the parameters in text form.
parameters
()Obtain parameter names and values.
relate
(dependentVar, independentVars[, func])Define a relation.
removeConditionalRestriction
(*args)Remove an existing conditional constraint.
renameVariable
(oldName, newName)Change name of variable.
restoreState
(resource)Restores parameter values from file or dictionary.
saveState
(*args, **kwargs)Save the state of the fitting object.
setObjectiveFunction
([miniFunc])Define the objective function.
setPenaltyFactor
(penalFac)Change the penalty factor.
setRestriction
(restricts)Define restrictions.
setRootName
(root[, rename])Define the root name of the model.
showConditionalRestrictions
(**kwargs)Show conditional restrictions.
steppar
(pars, ranges[, extractFctVal, quiet])Allows to step a parameter through a specified range.
thaw
(specifiers)Consider variables fixed.
untie
(parName[, forceFree])Remove all relations of parameter parName, i.e., the parameter is not dependend on other parameters.
updateModel
()Recalculate the model using current settings.
evaluate
Multicomponent Gaussian with linear continuum¶
- class PyAstronomy.funcFit.MultiGauss1d(n)¶
A multicomponent Gaussian with a single linear continuum component.
The parameters are the same as for the GaussFit1d, except that all receive a number specifying the Gaussian component to which they belong. Therefore, they are, e.g., named A1, mu2, and so on, only off and lin remain unnumbered.
- Parameters
- nint
The number if Gaussian components.
Methods
MCMCautoParameters
(ranges[, picky, ...])Convenience function to generate parameters for MCMC fit.
addConditionalRestriction
(*args)Define a conditional restriction.
assignValue
(specval)Assign new values to variables.
assignValues
(specval)Assign new values to variables.
autoFitMCMC
(x, y, ranges[, picky, stepsize, ...])Convenience function to using auto-generated sampling parameters in MCMC.
availableParameters
()Provides a list of existing parameters.
delRestriction
(parName)Delete restriction
description
([parenthesis])Returns a description of the model based on the names of the individual components.
errorConfInterval
(par[, dstat, statTol, ...])Calculate confidence interval for a parameter.
evalComponent
(x, p)Evaluate the model considering only a single component.
evaluate
(x)Evaluates the model for current parameter values.
fit
(x, y[, yerr, X0, minAlgo, mAA, ...])Carries out a fit.
fitEMCEE
([x, y, yerr, nwalker, priors, ...])MCMC sampling using emcee package.
fitMCMC
(x, y, X0, Lims, Steps[, yerr, ...])Carry out MCMC fit/error estimation.
freeParamNames
()Get the names of the free parameters.
freeParameters
()Get names and values of free parameters.
freeze
(specifiers)Consider variables free to float.
frozenParameters
()Get names and values of frozen parameters.
getRelationsOf
(specifier)Return relations of a variable.
getRestrictions
()Get all restrictions.
hasVariable
(specifier)Determine whether the variable exists.
numberOfFreeParams
()Get number of free parameters.
parameterSummary
([toScreen, prefix, sorting])Writes a summary of the parameters in text form.
parameters
()Obtain parameter names and values.
relate
(dependentVar, independentVars[, func])Define a relation.
removeConditionalRestriction
(*args)Remove an existing conditional constraint.
renameVariable
(oldName, newName)Change name of variable.
restoreState
(resource)Restores parameter values from file or dictionary.
saveState
(*args, **kwargs)Save the state of the fitting object.
setObjectiveFunction
([miniFunc])Define the objective function.
setPenaltyFactor
(penalFac)Change the penalty factor.
setRestriction
(restricts)Define restrictions.
setRootName
(root[, rename])Define the root name of the model.
showConditionalRestrictions
(**kwargs)Show conditional restrictions.
steppar
(pars, ranges[, extractFctVal, quiet])Allows to step a parameter through a specified range.
thaw
(specifiers)Consider variables fixed.
untie
(parName[, forceFree])Remove all relations of parameter parName, i.e., the parameter is not dependend on other parameters.
updateModel
()Recalculate the model using current settings.
Cauchy-Lorentz with linear continuum¶
- class PyAstronomy.funcFit.CauchyLorentz1d¶
A Cauchy-Lorentz profile
- Fit parameters:
A - Amplitude
g - Scale parameter (usually gamma)
mu - Center
off - A constant offset
lin - A linear contribution
Methods
MCMCautoParameters
(ranges[, picky, ...])Convenience function to generate parameters for MCMC fit.
addConditionalRestriction
(*args)Define a conditional restriction.
assignValue
(specval)Assign new values to variables.
assignValues
(specval)Assign new values to variables.
autoFitMCMC
(x, y, ranges[, picky, stepsize, ...])Convenience function to using auto-generated sampling parameters in MCMC.
availableParameters
()Provides a list of existing parameters.
delRestriction
(parName)Delete restriction
description
([parenthesis])Returns a description of the model based on the names of the individual components.
errorConfInterval
(par[, dstat, statTol, ...])Calculate confidence interval for a parameter.
evaluate
(x)Evaluates the model for current parameter values.
fit
(x, y[, yerr, X0, minAlgo, mAA, ...])Carries out a fit.
fitEMCEE
([x, y, yerr, nwalker, priors, ...])MCMC sampling using emcee package.
fitMCMC
(x, y, X0, Lims, Steps[, yerr, ...])Carry out MCMC fit/error estimation.
freeParamNames
()Get the names of the free parameters.
freeParameters
()Get names and values of free parameters.
freeze
(specifiers)Consider variables free to float.
frozenParameters
()Get names and values of frozen parameters.
getRelationsOf
(specifier)Return relations of a variable.
getRestrictions
()Get all restrictions.
hasVariable
(specifier)Determine whether the variable exists.
numberOfFreeParams
()Get number of free parameters.
parameterSummary
([toScreen, prefix, sorting])Writes a summary of the parameters in text form.
parameters
()Obtain parameter names and values.
relate
(dependentVar, independentVars[, func])Define a relation.
removeConditionalRestriction
(*args)Remove an existing conditional constraint.
renameVariable
(oldName, newName)Change name of variable.
restoreState
(resource)Restores parameter values from file or dictionary.
saveState
(*args, **kwargs)Save the state of the fitting object.
setObjectiveFunction
([miniFunc])Define the objective function.
setPenaltyFactor
(penalFac)Change the penalty factor.
setRestriction
(restricts)Define restrictions.
setRootName
(root[, rename])Define the root name of the model.
showConditionalRestrictions
(**kwargs)Show conditional restrictions.
steppar
(pars, ranges[, extractFctVal, quiet])Allows to step a parameter through a specified range.
thaw
(specifiers)Consider variables fixed.
untie
(parName[, forceFree])Remove all relations of parameter parName, i.e., the parameter is not dependend on other parameters.
updateModel
()Recalculate the model using current settings.
Voigt with linear continuum¶
- class PyAstronomy.funcFit.Voigt1d¶
Implements a Voigt profile (convolution of Cauchy-Lorentz and Gaussian distribution).
Note
The profile is implemented so that al is half the FWHM of the Cauchy-Lorentz distribution.
- Fit parameters:
A - Area under the curve
al - Scale parameter of the Cauchy-Lorentz distribution (half its FWHM)
ad - The width (standard deviation) of the Gaussian (usually called sigma)
mu - Center
off - Constant offset
lin - Linear contribution
Notes
The Voigt profile V is defined as the convolution
\[V(x) = A\int G(x')L(x-x')dx'\]of a Gaussian distribution
\[G=1/(\sqrt{2 \pi} \ ad)\exp(-(x-mu)^2/(2 \ ad^2))\]and a Cauchy-Lorentz distribution
\[L=al/(\pi ((x-mu)^2+al^2)) .\]We here take into account an additional offset and linear term so that
\[V'(x) = V(x) + (lin \ x + off) .\]The Voigt profile is calculated via the real part of the Faddeeva function. For details, see http://en.wikipedia.org/wiki/Voigt_profile and http://en.wikipedia.org/wiki/Error_function.
Methods
FWHM
()Calculates an approximation of the FWHM.
MCMCautoParameters
(ranges[, picky, ...])Convenience function to generate parameters for MCMC fit.
addConditionalRestriction
(*args)Define a conditional restriction.
assignValue
(specval)Assign new values to variables.
assignValues
(specval)Assign new values to variables.
autoFitMCMC
(x, y, ranges[, picky, stepsize, ...])Convenience function to using auto-generated sampling parameters in MCMC.
availableParameters
()Provides a list of existing parameters.
delRestriction
(parName)Delete restriction
description
([parenthesis])Returns a description of the model based on the names of the individual components.
errorConfInterval
(par[, dstat, statTol, ...])Calculate confidence interval for a parameter.
evaluate
(x)Evaluates the model for current parameter values.
fit
(x, y[, yerr, X0, minAlgo, mAA, ...])Carries out a fit.
fitEMCEE
([x, y, yerr, nwalker, priors, ...])MCMC sampling using emcee package.
fitMCMC
(x, y, X0, Lims, Steps[, yerr, ...])Carry out MCMC fit/error estimation.
freeParamNames
()Get the names of the free parameters.
freeParameters
()Get names and values of free parameters.
freeze
(specifiers)Consider variables free to float.
frozenParameters
()Get names and values of frozen parameters.
getRelationsOf
(specifier)Return relations of a variable.
getRestrictions
()Get all restrictions.
hasVariable
(specifier)Determine whether the variable exists.
numberOfFreeParams
()Get number of free parameters.
parameterSummary
([toScreen, prefix, sorting])Writes a summary of the parameters in text form.
parameters
()Obtain parameter names and values.
relate
(dependentVar, independentVars[, func])Define a relation.
removeConditionalRestriction
(*args)Remove an existing conditional constraint.
renameVariable
(oldName, newName)Change name of variable.
restoreState
(resource)Restores parameter values from file or dictionary.
saveState
(*args, **kwargs)Save the state of the fitting object.
setObjectiveFunction
([miniFunc])Define the objective function.
setPenaltyFactor
(penalFac)Change the penalty factor.
setRestriction
(restricts)Define restrictions.
setRootName
(root[, rename])Define the root name of the model.
showConditionalRestrictions
(**kwargs)Show conditional restrictions.
steppar
(pars, ranges[, extractFctVal, quiet])Allows to step a parameter through a specified range.
thaw
(specifiers)Consider variables fixed.
untie
(parName[, forceFree])Remove all relations of parameter parName, i.e., the parameter is not dependend on other parameters.
updateModel
()Recalculate the model using current settings.
Multicomponent Voigt profile with linear continuum¶
- class PyAstronomy.funcFit.MultiVoigt1d(n)¶
Multicomponent Voigt with a single linear continuum component.
The parameters are the same as for Voigt1d, except that all are extended by a number specifying the component to which they belong. Therefore, they read, e.g., A1, mu2, and so on; only off and lin remain unnumbered.
- Parameters
- nint
The number of Voigt components.
Methods
MCMCautoParameters
(ranges[, picky, ...])Convenience function to generate parameters for MCMC fit.
addConditionalRestriction
(*args)Define a conditional restriction.
assignValue
(specval)Assign new values to variables.
assignValues
(specval)Assign new values to variables.
autoFitMCMC
(x, y, ranges[, picky, stepsize, ...])Convenience function to using auto-generated sampling parameters in MCMC.
availableParameters
()Provides a list of existing parameters.
delRestriction
(parName)Delete restriction
description
([parenthesis])Returns a description of the model based on the names of the individual components.
errorConfInterval
(par[, dstat, statTol, ...])Calculate confidence interval for a parameter.
evalComponent
(x, p)Evaluate the model considering only a single component.
evaluate
(x)Evaluates the model for current parameter values.
fit
(x, y[, yerr, X0, minAlgo, mAA, ...])Carries out a fit.
fitEMCEE
([x, y, yerr, nwalker, priors, ...])MCMC sampling using emcee package.
fitMCMC
(x, y, X0, Lims, Steps[, yerr, ...])Carry out MCMC fit/error estimation.
freeParamNames
()Get the names of the free parameters.
freeParameters
()Get names and values of free parameters.
freeze
(specifiers)Consider variables free to float.
frozenParameters
()Get names and values of frozen parameters.
getRelationsOf
(specifier)Return relations of a variable.
getRestrictions
()Get all restrictions.
hasVariable
(specifier)Determine whether the variable exists.
numberOfFreeParams
()Get number of free parameters.
parameterSummary
([toScreen, prefix, sorting])Writes a summary of the parameters in text form.
parameters
()Obtain parameter names and values.
relate
(dependentVar, independentVars[, func])Define a relation.
removeConditionalRestriction
(*args)Remove an existing conditional constraint.
renameVariable
(oldName, newName)Change name of variable.
restoreState
(resource)Restores parameter values from file or dictionary.
saveState
(*args, **kwargs)Save the state of the fitting object.
setObjectiveFunction
([miniFunc])Define the objective function.
setPenaltyFactor
(penalFac)Change the penalty factor.
setRestriction
(restricts)Define restrictions.
setRootName
(root[, rename])Define the root name of the model.
showConditionalRestrictions
(**kwargs)Show conditional restrictions.
steppar
(pars, ranges[, extractFctVal, quiet])Allows to step a parameter through a specified range.
thaw
(specifiers)Consider variables fixed.
untie
(parName[, forceFree])Remove all relations of parameter parName, i.e., the parameter is not dependend on other parameters.
updateModel
()Recalculate the model using current settings.
- evalComponent(x, p)¶
Evaluate the model considering only a single component.
- Parameters
- xarray
The abscissa.
- pint
Component number (starts with one).
- Returns
- Single component modelarray
The model considering a single component. Note that the linear continuum is included.
- evaluate(x)¶
Evaluates the model for current parameter values.
- Parameters
- xarray
Specifies the points at which to evaluate the model.
Sine fit¶
- class PyAstronomy.funcFit.SinusFit1d¶
- Implements a sinusoidal function of the form:
A * sin[ 2*pi * (nu * t + phi) ] + off.
- Fit parameters:
A - Amplitude
nu - Frequency (= 1/Period)
phi - Phase
off - Offset
Methods
MCMCautoParameters
(ranges[, picky, ...])Convenience function to generate parameters for MCMC fit.
addConditionalRestriction
(*args)Define a conditional restriction.
assignValue
(specval)Assign new values to variables.
assignValues
(specval)Assign new values to variables.
autoFitMCMC
(x, y, ranges[, picky, stepsize, ...])Convenience function to using auto-generated sampling parameters in MCMC.
availableParameters
()Provides a list of existing parameters.
delRestriction
(parName)Delete restriction
description
([parenthesis])Returns a description of the model based on the names of the individual components.
errorConfInterval
(par[, dstat, statTol, ...])Calculate confidence interval for a parameter.
evaluate
(x)Evaluates the model for current parameter values.
fit
(x, y[, yerr, X0, minAlgo, mAA, ...])Carries out a fit.
fitEMCEE
([x, y, yerr, nwalker, priors, ...])MCMC sampling using emcee package.
fitMCMC
(x, y, X0, Lims, Steps[, yerr, ...])Carry out MCMC fit/error estimation.
freeParamNames
()Get the names of the free parameters.
freeParameters
()Get names and values of free parameters.
freeze
(specifiers)Consider variables free to float.
frozenParameters
()Get names and values of frozen parameters.
getRelationsOf
(specifier)Return relations of a variable.
getRestrictions
()Get all restrictions.
hasVariable
(specifier)Determine whether the variable exists.
numberOfFreeParams
()Get number of free parameters.
parameterSummary
([toScreen, prefix, sorting])Writes a summary of the parameters in text form.
parameters
()Obtain parameter names and values.
relate
(dependentVar, independentVars[, func])Define a relation.
removeConditionalRestriction
(*args)Remove an existing conditional constraint.
renameVariable
(oldName, newName)Change name of variable.
restoreState
(resource)Restores parameter values from file or dictionary.
saveState
(*args, **kwargs)Save the state of the fitting object.
setObjectiveFunction
([miniFunc])Define the objective function.
setPenaltyFactor
(penalFac)Change the penalty factor.
setRestriction
(restricts)Define restrictions.
setRootName
(root[, rename])Define the root name of the model.
showConditionalRestrictions
(**kwargs)Show conditional restrictions.
steppar
(pars, ranges[, extractFctVal, quiet])Allows to step a parameter through a specified range.
thaw
(specifiers)Consider variables fixed.
untie
(parName[, forceFree])Remove all relations of parameter parName, i.e., the parameter is not dependend on other parameters.
updateModel
()Recalculate the model using current settings.
Exponential decay¶
- class PyAstronomy.funcFit.ExpDecayFit1d¶
- Implements an exponential decay function of the form
A * exp[ - (t-t0)/tau] + off.
- Fit parameters:
A - Amplitude
tau - Mean lifetime (=1/decay rate)
t0 - Onset time
off - Continuum offset
Methods
MCMCautoParameters
(ranges[, picky, ...])Convenience function to generate parameters for MCMC fit.
addConditionalRestriction
(*args)Define a conditional restriction.
assignValue
(specval)Assign new values to variables.
assignValues
(specval)Assign new values to variables.
autoFitMCMC
(x, y, ranges[, picky, stepsize, ...])Convenience function to using auto-generated sampling parameters in MCMC.
availableParameters
()Provides a list of existing parameters.
delRestriction
(parName)Delete restriction
description
([parenthesis])Returns a description of the model based on the names of the individual components.
errorConfInterval
(par[, dstat, statTol, ...])Calculate confidence interval for a parameter.
evaluate
(x)Evaluates the model for current parameter values.
fit
(x, y[, yerr, X0, minAlgo, mAA, ...])Carries out a fit.
fitEMCEE
([x, y, yerr, nwalker, priors, ...])MCMC sampling using emcee package.
fitMCMC
(x, y, X0, Lims, Steps[, yerr, ...])Carry out MCMC fit/error estimation.
freeParamNames
()Get the names of the free parameters.
freeParameters
()Get names and values of free parameters.
freeze
(specifiers)Consider variables free to float.
frozenParameters
()Get names and values of frozen parameters.
getRelationsOf
(specifier)Return relations of a variable.
getRestrictions
()Get all restrictions.
hasVariable
(specifier)Determine whether the variable exists.
numberOfFreeParams
()Get number of free parameters.
parameterSummary
([toScreen, prefix, sorting])Writes a summary of the parameters in text form.
parameters
()Obtain parameter names and values.
relate
(dependentVar, independentVars[, func])Define a relation.
removeConditionalRestriction
(*args)Remove an existing conditional constraint.
renameVariable
(oldName, newName)Change name of variable.
restoreState
(resource)Restores parameter values from file or dictionary.
saveState
(*args, **kwargs)Save the state of the fitting object.
setObjectiveFunction
([miniFunc])Define the objective function.
setPenaltyFactor
(penalFac)Change the penalty factor.
setRestriction
(restricts)Define restrictions.
setRootName
(root[, rename])Define the root name of the model.
showConditionalRestrictions
(**kwargs)Show conditional restrictions.
steppar
(pars, ranges[, extractFctVal, quiet])Allows to step a parameter through a specified range.
thaw
(specifiers)Consider variables fixed.
untie
(parName[, forceFree])Remove all relations of parameter parName, i.e., the parameter is not dependend on other parameters.
updateModel
()Recalculate the model using current settings.
Polynomial of degree n¶
- class PyAstronomy.funcFit.PolyFit1d(degree, xoff=0.0)¶
Implements a polynomial fit.
- Fit parameters:
- cn - Here n is a number indicating degree
(e.g., c0 + c1*x + c2*x**2 …)
If xoff is specified, the polynomial will be evaluated at the points x-xoff. This can be useful to suppress correlation.
Methods
MCMCautoParameters
(ranges[, picky, ...])Convenience function to generate parameters for MCMC fit.
addConditionalRestriction
(*args)Define a conditional restriction.
asNPPoly
()Construct a numpy.poly1d object from the coefficients.
assignValue
(specval)Assign new values to variables.
assignValues
(specval)Assign new values to variables.
autoFitMCMC
(x, y, ranges[, picky, stepsize, ...])Convenience function to using auto-generated sampling parameters in MCMC.
availableParameters
()Provides a list of existing parameters.
delRestriction
(parName)Delete restriction
description
([parenthesis])Returns a description of the model based on the names of the individual components.
errorConfInterval
(par[, dstat, statTol, ...])Calculate confidence interval for a parameter.
evaluate
(x)Evaluates the model for current parameter values.
fit
(x, y[, yerr, X0, minAlgo, mAA, ...])Carries out a fit.
fitEMCEE
([x, y, yerr, nwalker, priors, ...])MCMC sampling using emcee package.
fitMCMC
(x, y, X0, Lims, Steps[, yerr, ...])Carry out MCMC fit/error estimation.
freeParamNames
()Get the names of the free parameters.
freeParameters
()Get names and values of free parameters.
freeze
(specifiers)Consider variables free to float.
frozenParameters
()Get names and values of frozen parameters.
getRelationsOf
(specifier)Return relations of a variable.
getRestrictions
()Get all restrictions.
hasVariable
(specifier)Determine whether the variable exists.
numberOfFreeParams
()Get number of free parameters.
parameterSummary
([toScreen, prefix, sorting])Writes a summary of the parameters in text form.
parameters
()Obtain parameter names and values.
relate
(dependentVar, independentVars[, func])Define a relation.
removeConditionalRestriction
(*args)Remove an existing conditional constraint.
renameVariable
(oldName, newName)Change name of variable.
restoreState
(resource)Restores parameter values from file or dictionary.
saveState
(*args, **kwargs)Save the state of the fitting object.
setObjectiveFunction
([miniFunc])Define the objective function.
setPenaltyFactor
(penalFac)Change the penalty factor.
setRestriction
(restricts)Define restrictions.
setRootName
(root[, rename])Define the root name of the model.
showConditionalRestrictions
(**kwargs)Show conditional restrictions.
steppar
(pars, ranges[, extractFctVal, quiet])Allows to step a parameter through a specified range.
thaw
(specifiers)Consider variables fixed.
untie
(parName[, forceFree])Remove all relations of parameter parName, i.e., the parameter is not dependend on other parameters.
updateModel
()Recalculate the model using current settings.
Hyperbolic secant¶
- class PyAstronomy.funcFit.Sech1d¶
Implements a one dimensional hyperbolic secant
The functional form is:
\[\frac{2 A}{e^{(x-mu)/w} + e^{-(x-mu)/w} } + x \times lin + off\]Here, lin and off denote the linear and the offset term.
Note
The area under the curve is given by \(\pi \times A\)
- Fit parameters:
A - Amplitude (maximum/minimum of the curve, not area)
mu - Center of the hyperbolic secant
w - Width parameter
off - Offset
lin - Linear term
Methods
MCMCautoParameters
(ranges[, picky, ...])Convenience function to generate parameters for MCMC fit.
addConditionalRestriction
(*args)Define a conditional restriction.
assignValue
(specval)Assign new values to variables.
assignValues
(specval)Assign new values to variables.
autoFitMCMC
(x, y, ranges[, picky, stepsize, ...])Convenience function to using auto-generated sampling parameters in MCMC.
availableParameters
()Provides a list of existing parameters.
delRestriction
(parName)Delete restriction
description
([parenthesis])Returns a description of the model based on the names of the individual components.
errorConfInterval
(par[, dstat, statTol, ...])Calculate confidence interval for a parameter.
evaluate
(x)Evaluates the model for current parameter values.
fit
(x, y[, yerr, X0, minAlgo, mAA, ...])Carries out a fit.
fitEMCEE
([x, y, yerr, nwalker, priors, ...])MCMC sampling using emcee package.
fitMCMC
(x, y, X0, Lims, Steps[, yerr, ...])Carry out MCMC fit/error estimation.
freeParamNames
()Get the names of the free parameters.
freeParameters
()Get names and values of free parameters.
freeze
(specifiers)Consider variables free to float.
frozenParameters
()Get names and values of frozen parameters.
getRelationsOf
(specifier)Return relations of a variable.
getRestrictions
()Get all restrictions.
hasVariable
(specifier)Determine whether the variable exists.
numberOfFreeParams
()Get number of free parameters.
parameterSummary
([toScreen, prefix, sorting])Writes a summary of the parameters in text form.
parameters
()Obtain parameter names and values.
relate
(dependentVar, independentVars[, func])Define a relation.
removeConditionalRestriction
(*args)Remove an existing conditional constraint.
renameVariable
(oldName, newName)Change name of variable.
restoreState
(resource)Restores parameter values from file or dictionary.
saveState
(*args, **kwargs)Save the state of the fitting object.
setObjectiveFunction
([miniFunc])Define the objective function.
setPenaltyFactor
(penalFac)Change the penalty factor.
setRestriction
(restricts)Define restrictions.
setRootName
(root[, rename])Define the root name of the model.
showConditionalRestrictions
(**kwargs)Show conditional restrictions.
steppar
(pars, ranges[, extractFctVal, quiet])Allows to step a parameter through a specified range.
thaw
(specifiers)Consider variables fixed.
untie
(parName[, forceFree])Remove all relations of parameter parName, i.e., the parameter is not dependend on other parameters.
updateModel
()Recalculate the model using current settings.
Constant¶
- class PyAstronomy.funcFit.ConstantFit1d¶
Implements a constant model.
- Fit parameters:
c - The constant.
Methods
MCMCautoParameters
(ranges[, picky, ...])Convenience function to generate parameters for MCMC fit.
addConditionalRestriction
(*args)Define a conditional restriction.
assignValue
(specval)Assign new values to variables.
assignValues
(specval)Assign new values to variables.
autoFitMCMC
(x, y, ranges[, picky, stepsize, ...])Convenience function to using auto-generated sampling parameters in MCMC.
availableParameters
()Provides a list of existing parameters.
delRestriction
(parName)Delete restriction
description
([parenthesis])Returns a description of the model based on the names of the individual components.
errorConfInterval
(par[, dstat, statTol, ...])Calculate confidence interval for a parameter.
evaluate
(x)Evaluates the model for current parameter values.
fit
(x, y[, yerr, X0, minAlgo, mAA, ...])Carries out a fit.
fitEMCEE
([x, y, yerr, nwalker, priors, ...])MCMC sampling using emcee package.
fitMCMC
(x, y, X0, Lims, Steps[, yerr, ...])Carry out MCMC fit/error estimation.
freeParamNames
()Get the names of the free parameters.
freeParameters
()Get names and values of free parameters.
freeze
(specifiers)Consider variables free to float.
frozenParameters
()Get names and values of frozen parameters.
getRelationsOf
(specifier)Return relations of a variable.
getRestrictions
()Get all restrictions.
hasVariable
(specifier)Determine whether the variable exists.
numberOfFreeParams
()Get number of free parameters.
parameterSummary
([toScreen, prefix, sorting])Writes a summary of the parameters in text form.
parameters
()Obtain parameter names and values.
relate
(dependentVar, independentVars[, func])Define a relation.
removeConditionalRestriction
(*args)Remove an existing conditional constraint.
renameVariable
(oldName, newName)Change name of variable.
restoreState
(resource)Restores parameter values from file or dictionary.
saveState
(*args, **kwargs)Save the state of the fitting object.
setObjectiveFunction
([miniFunc])Define the objective function.
setPenaltyFactor
(penalFac)Change the penalty factor.
setRestriction
(restricts)Define restrictions.
setRootName
(root[, rename])Define the root name of the model.
showConditionalRestrictions
(**kwargs)Show conditional restrictions.
steppar
(pars, ranges[, extractFctVal, quiet])Allows to step a parameter through a specified range.
thaw
(specifiers)Consider variables fixed.
untie
(parName[, forceFree])Remove all relations of parameter parName, i.e., the parameter is not dependend on other parameters.
updateModel
()Recalculate the model using current settings.
Two-dimensional Gaussian¶
- class PyAstronomy.funcFit.GaussFit2d¶
Implements a two dimensional Gaussian.
Expects a coordinate array to evaluate model.
The functional form is:
\[\frac{A}{2\pi\sigma_x\sigma_y\sqrt{1-\rho^2}} exp\left(-\frac{1}{2(1-\rho^2)}\left( \frac{(x-\mu_x)^2}{\sigma_x^2} + \frac{(y-\mu_y)^2}{\sigma_y^2} - \frac{2\rho(x-\mu_x)(y-\mu_y)}{\sigma_x\sigma_y} \right)\right)\]Here, lin and off denote the linear and the offset term.
- Fit parameters:
A - Amplitude (the area of the Gaussian)
mux - Center of the Gaussian (x-axis)
muy - Center of the Gaussian (y-axis)
sigx - Standard deviation (x-axis)
sigy - Standard deviation (y-axis)
rho - Correlation
Methods
MCMCautoParameters
(ranges[, picky, ...])Convenience function to generate parameters for MCMC fit.
addConditionalRestriction
(*args)Define a conditional restriction.
assignValue
(specval)Assign new values to variables.
assignValues
(specval)Assign new values to variables.
autoFitMCMC
(x, y, ranges[, picky, stepsize, ...])Convenience function to using auto-generated sampling parameters in MCMC.
availableParameters
()Provides a list of existing parameters.
delRestriction
(parName)Delete restriction
description
([parenthesis])Returns a description of the model based on the names of the individual components.
errorConfInterval
(par[, dstat, statTol, ...])Calculate confidence interval for a parameter.
evaluate
(co)Evaluates the model for current parameter values.
fit
(x, y[, yerr, X0, minAlgo, mAA, ...])Carries out a fit.
fitEMCEE
([x, y, yerr, nwalker, priors, ...])MCMC sampling using emcee package.
fitMCMC
(x, y, X0, Lims, Steps[, yerr, ...])Carry out MCMC fit/error estimation.
freeParamNames
()Get the names of the free parameters.
freeParameters
()Get names and values of free parameters.
freeze
(specifiers)Consider variables free to float.
frozenParameters
()Get names and values of frozen parameters.
getRelationsOf
(specifier)Return relations of a variable.
getRestrictions
()Get all restrictions.
hasVariable
(specifier)Determine whether the variable exists.
numberOfFreeParams
()Get number of free parameters.
parameterSummary
([toScreen, prefix, sorting])Writes a summary of the parameters in text form.
parameters
()Obtain parameter names and values.
relate
(dependentVar, independentVars[, func])Define a relation.
removeConditionalRestriction
(*args)Remove an existing conditional constraint.
renameVariable
(oldName, newName)Change name of variable.
restoreState
(resource)Restores parameter values from file or dictionary.
saveState
(*args, **kwargs)Save the state of the fitting object.
setObjectiveFunction
([miniFunc])Define the objective function.
setPenaltyFactor
(penalFac)Change the penalty factor.
setRestriction
(restricts)Define restrictions.
setRootName
(root[, rename])Define the root name of the model.
showConditionalRestrictions
(**kwargs)Show conditional restrictions.
steppar
(pars, ranges[, extractFctVal, quiet])Allows to step a parameter through a specified range.
thaw
(specifiers)Consider variables fixed.
untie
(parName[, forceFree])Remove all relations of parameter parName, i.e., the parameter is not dependend on other parameters.
updateModel
()Recalculate the model using current settings.
Multicomponent two-dimensional Gaussian¶
- class PyAstronomy.funcFit.MultiGauss2d(n)¶
Implements a multicomponent, two dimensional Gaussian.
Expects a coordinate array to evaluate model.
The functional form is:
\[\frac{A}{2\pi\sigma_x\sigma_y\sqrt{1-\rho^2}} exp\left(-\frac{1}{2(1-\rho^2)}\left( \frac{(x-\mu_x)^2}{\sigma_x^2} + \frac{(y-\mu_y)^2}{\sigma_y^2} - \frac{2\rho(x-\mu_x)(y-\mu_y)}{\sigma_x\sigma_y} \right)\right)\]- Parameters
- nint
The number of Gaussian components.
- *Fit parameters*:
A - Amplitude (the area of the Gaussian)
mux - Center of the Gaussian (x-axis)
muy - Center of the Gaussian (y-axis)
sigx - Standard deviation (x-axis)
sigy - Standard deviation (y-axis)
rho - Correlation
off - Constant offset
Methods
MCMCautoParameters
(ranges[, picky, ...])Convenience function to generate parameters for MCMC fit.
addConditionalRestriction
(*args)Define a conditional restriction.
assignValue
(specval)Assign new values to variables.
assignValues
(specval)Assign new values to variables.
autoFitMCMC
(x, y, ranges[, picky, stepsize, ...])Convenience function to using auto-generated sampling parameters in MCMC.
availableParameters
()Provides a list of existing parameters.
delRestriction
(parName)Delete restriction
description
([parenthesis])Returns a description of the model based on the names of the individual components.
errorConfInterval
(par[, dstat, statTol, ...])Calculate confidence interval for a parameter.
evaluate
(co)Evaluates the model for current parameter values.
fit
(x, y[, yerr, X0, minAlgo, mAA, ...])Carries out a fit.
fitEMCEE
([x, y, yerr, nwalker, priors, ...])MCMC sampling using emcee package.
fitMCMC
(x, y, X0, Lims, Steps[, yerr, ...])Carry out MCMC fit/error estimation.
freeParamNames
()Get the names of the free parameters.
freeParameters
()Get names and values of free parameters.
freeze
(specifiers)Consider variables free to float.
frozenParameters
()Get names and values of frozen parameters.
getRelationsOf
(specifier)Return relations of a variable.
getRestrictions
()Get all restrictions.
hasVariable
(specifier)Determine whether the variable exists.
numberOfFreeParams
()Get number of free parameters.
parameterSummary
([toScreen, prefix, sorting])Writes a summary of the parameters in text form.
parameters
()Obtain parameter names and values.
relate
(dependentVar, independentVars[, func])Define a relation.
removeConditionalRestriction
(*args)Remove an existing conditional constraint.
renameVariable
(oldName, newName)Change name of variable.
restoreState
(resource)Restores parameter values from file or dictionary.
saveState
(*args, **kwargs)Save the state of the fitting object.
setObjectiveFunction
([miniFunc])Define the objective function.
setPenaltyFactor
(penalFac)Change the penalty factor.
setRestriction
(restricts)Define restrictions.
setRootName
(root[, rename])Define the root name of the model.
showConditionalRestrictions
(**kwargs)Show conditional restrictions.
steppar
(pars, ranges[, extractFctVal, quiet])Allows to step a parameter through a specified range.
thaw
(specifiers)Consider variables fixed.
untie
(parName[, forceFree])Remove all relations of parameter parName, i.e., the parameter is not dependend on other parameters.
updateModel
()Recalculate the model using current settings.
Demonstration models¶
Models mainly used for demonstration purposes.
Simple circular orbit¶
- class PyAstronomy.funcFit.Circle2d¶
Implements a simple, two-dimensional circular orbit.
The functional form is:
\[(x,y) = (r \cos(\omega (t-t_0)), r \sin(\omega (t-t_0)))\]where \(\omega\) is \(2\pi/Period\).
- Fit parameters:
r - Radius of the circle
per - Period of orbit
t0 - Starting time of orbit
Methods
MCMCautoParameters
(ranges[, picky, ...])Convenience function to generate parameters for MCMC fit.
addConditionalRestriction
(*args)Define a conditional restriction.
assignValue
(specval)Assign new values to variables.
assignValues
(specval)Assign new values to variables.
autoFitMCMC
(x, y, ranges[, picky, stepsize, ...])Convenience function to using auto-generated sampling parameters in MCMC.
availableParameters
()Provides a list of existing parameters.
delRestriction
(parName)Delete restriction
description
([parenthesis])Returns a description of the model based on the names of the individual components.
errorConfInterval
(par[, dstat, statTol, ...])Calculate confidence interval for a parameter.
evaluate
(t)Evaluates the model for current parameter values.
fit
(x, y[, yerr, X0, minAlgo, mAA, ...])Carries out a fit.
fitEMCEE
([x, y, yerr, nwalker, priors, ...])MCMC sampling using emcee package.
fitMCMC
(x, y, X0, Lims, Steps[, yerr, ...])Carry out MCMC fit/error estimation.
freeParamNames
()Get the names of the free parameters.
freeParameters
()Get names and values of free parameters.
freeze
(specifiers)Consider variables free to float.
frozenParameters
()Get names and values of frozen parameters.
getRelationsOf
(specifier)Return relations of a variable.
getRestrictions
()Get all restrictions.
hasVariable
(specifier)Determine whether the variable exists.
numberOfFreeParams
()Get number of free parameters.
parameterSummary
([toScreen, prefix, sorting])Writes a summary of the parameters in text form.
parameters
()Obtain parameter names and values.
relate
(dependentVar, independentVars[, func])Define a relation.
removeConditionalRestriction
(*args)Remove an existing conditional constraint.
renameVariable
(oldName, newName)Change name of variable.
restoreState
(resource)Restores parameter values from file or dictionary.
saveState
(*args, **kwargs)Save the state of the fitting object.
setObjectiveFunction
([miniFunc])Define the objective function.
setPenaltyFactor
(penalFac)Change the penalty factor.
setRestriction
(restricts)Define restrictions.
setRootName
(root[, rename])Define the root name of the model.
showConditionalRestrictions
(**kwargs)Show conditional restrictions.
steppar
(pars, ranges[, extractFctVal, quiet])Allows to step a parameter through a specified range.
thaw
(specifiers)Consider variables fixed.
untie
(parName[, forceFree])Remove all relations of parameter parName, i.e., the parameter is not dependend on other parameters.
updateModel
()Recalculate the model using current settings.