BayesicFitting

Model Fitting and Evidence Calculation

View project on GitHub



class VoigtModel( NonLinearModel )Source

Voigt's Gauss Lorentz convoluted model for line profiles.

The Voigt function is a convolution of a Gauss and a Lorentz function. Physicaly it is the result of thermal and pressure broadening of a spectral line.

The models takes 4 parameters: amplitude, center frequency, half-width of the Gaussian, and half-width of the Lorentzian. These are initialised to [1, 0, 1, 1]. Parameters 2 & 3 ( widths ) is always kept positive ( >=0 ).

The implementation uses the Faddeeva function from scipy.special.wofz.

Examples

voigt = VoigtModel( )
voigt.setParameters( [5, 4, 1, 2] )
print( voigt( numpy.arange(  41 , dtype=float ) / 5 ) )      # from [0,8]

Attributes from Model

     npchain, parameters, stdevs, xUnit, yUnit

Attributes from FixedModel

     npmax, fixed, parlist, mlist

Attributes from BaseModel

     npbase, ndim, priors, posIndex, nonZero, tiny, deltaP, parNames

VoigtModel( copy=None, **kwargs )

Voigt model.

Number of parameters is 4.

Parameters

  • copy : VoigtModel
         to be copied

copy( )

Copy method.

baseResult( xdata, params )
Returns the result of the model function.

Note: both width in the parameter array ( items 2 & 3 ) are kept strictly positive. I.e. they are changed when upon input they are negative.

Parameters

  • xdata : array_like
         values at which to calculate the result
  • params : array_like
         values for the parameters.

basePartial( xdata, params, parlist=None )
Returns the partials at the input value.

     z = ( x - p1 + 1j * p3 ) / ( p2 * sqrt2 )
     z0 = 1j * p3 / ( p2 * sqrt2 )

     vgt = p0 * R( wofzz ) / R( wofz0 )

     dvdp = dvdz * dzdp

     dvdz = p0 * ( R(dwdz) * R(wofz0) - R(dwd0) * R(wofzz) ) / R(wofz0)2
     dvdp = p0 * ( R(dwdz * dzdp) * R(wofz0) - R(dwd0 * d0dp) * R(wofzz) ) / R(wofz0)2

     dwdz = 2j / sqrt(pi) - 2 * z * wofzz
     dwd0 = 2j / sqrt(pi) - 2 * z0 * wofz0

     ## p0 and p1 have no influence in wofz0
     dzdp0 = 0
     dzdp1 = -1 / ( p2 * sqrt2 )
     d0dp2 = - ( 1j * p3 / ( p22 * sqrt2 ) = -z0 / p2
     dzdp2 = - ( ( x - p1 + 1j * p3 ) / ( p22 * sqrt2 ) = -z / p2
     dzdp3 = d0dp3 = 1j / ( p2 * sqrt2 )

     dvdp0 = R(wofzz) / R(wofz0)
     ## The other partial follow from calculating dvdp for the parameters 1..3

Parameters

  • xdata : array_like
         values at which to calculate the partials
  • params : array_like
         values for the parameters.
  • parlist : array_like
         list of indices active parameters (or None for all)

baseDerivative( xdata, params )
Return the derivative df/dx at each xdata (=x).

     z = ( x - p1 + 1j * p3 ) / ( p2 * sqrt2 )
     z0 = 1j * p3 / ( p2 * sqrt2 )

     vgt = p0 / wofz0 * re( wofzz )
     dvdx = dvdz * dzdx

     dvdz = p0 / wofz0 * dwdz
     dwdz = 2j / sqrt(pi) - 2 * z * wofzz

     dzdx = 1 / ( p2 * sqrt2 )

Parameters

  • xdata : array_like
         values at which to calculate the result
  • params : array_like
         values for the parameters.

baseName( )
Returns a string representation of the model.

baseParameterUnit( k )
Return the name of a parameter.

Parameters

  • k : int
         parameter number.
Methods inherited from NonLinearModel
Methods inherited from Model
Methods inherited from FixedModel
Methods inherited from BaseModel