EISFitTemplate

class eispac.core.EISFitTemplate(filename=None, template=None, parinfo=None, **kwargs)[source]

Bases: object

Multigaussian fitting template for use with MPFIT and fit_spectra

Parameters:
  • filename (str or pathlib.Path, optional) – Path to the template file. Default is “unknown_file”. Note: passing a filename directly to EISFitTemplate will NOT automatically load the file; please use read_template instead.

  • template (dict, optional) –

    Dictionary of template parameters. Valid keys include:

    • n_gauss (int) - number of Gaussian components

    • n_poly (int) - Number of background polynomial terms.

      Common values are: 0 (no background), 1 (constant), and 2 (linear).

    • line_ids (array_like) - Strings giving the line identification

      for each Gaussian component. For example, “Fe XII 195.119”. If not specified, placeholder values of “unknown I {INITAL CENTROID VALUE}” will be used.

    • wmin (float) - min wavelength value of data to use for fitting

    • wmax (float) - max wavelength value of data to use for fitting

  • parinfo (list or dict, optional) –

    Either a list of dicts or a dict of lists giving the initial fitting parameters and constraints. If given a list, each entry must be a dict with the correct keys for a single fit parameter. If given a dict, each key must contain an array of list for all parameters. The order of parameters is assumed to be sets of [PEAK, CENTROID, WIDTH] for each Gaussian component followed by any coefficients for the background polynomial, starting with the LOWEST (constant) order term first. Valid keys include:

    • value (float) - initial parameter guess

    • fixed (0 or 1) - If set to “1”, will not fit and just use initial value

    • limited (two-element array_like) - If set to “1” in the first/second

      value, will apply and limit to the parameter on the lower/upper side

    • limits (two-element array_like) - Values of the limits on the

      lower/upper side. Both “limited” and “limits” must be give together.

    • tied (str) - String defining a fixed relationship between this

      parameters one or more others. For example “p[0] / 2” would define a parameter to ALWAYS be exactly half the value of the first parameter.

    Additional keys are available, please see the MPFIT documentation in the EISPAC user’s guide for more details.

  • kwargs (value or array_like, optional) – For convenience, users can also pass in any “template” or “parinfo” value or array as a seperate keyword. Any values defined in this way will take priority and overwrite any previous values for that key.

template

Dictoary of template paramaters

Type:

dict

parinfo

List of parameter constraint dicts

Type:

list of dicts

Attributes Summary

central_wave

Wavelength value in the center of the template wavelength range

funcinfo

List of dicts specifying each subcomponent function used in the template

Methods Summary

get_funcinfo(template)

Generate the funcinfo dict

read_template(filename)

Load an EISFitTemplate from an HDF5 or TOML template file

Attributes Documentation

central_wave

Wavelength value in the center of the template wavelength range

Note: this is calculated using the current values of ‘wmin’ and ‘wmax’ contained in the template dict.

funcinfo

List of dicts specifying each subcomponent function used in the template

Note: this is generated on-demand using the current template dict and the get_funcinfo class method.

Methods Documentation

static get_funcinfo(template)[source]

Generate the funcinfo dict

Returns a list of dictionaries where each entry describes the parameters for one of the fitting basis functions

Parameters:

template (dict) –

Returns:

funcinfo

Return type:

list

classmethod read_template(filename)[source]

Load an EISFitTemplate from an HDF5 or TOML template file

Parameters:

filename (str or pathlib.Path) – Path to a HDF5 template file provided with eispac or a user-made TOML template file.

Returns:

cls – Object containing the fit template

Return type:

EISFitTemplate class instance