- eispac.core.fit_spectra(inten, template, parinfo=None, wave=None, errs=None, min_points=7, ncpu='max', unsafe_mp=False, ignore_warnings=False, skip_fitting=False, debug=False)[source]
Fit one or more EIS line spectra using mpfit (with multiprocessing).
inten (EISCube object, array_like, or filepath) – One or more intensity profiles to be fit. The code will loop over the data according to its dimensionality. 3D data is assumed to be a full EIS raster (or a sub region), 2D data is assumed to be a single EIS slit, and 1D data is assumed to be a single profile.
template (EISFitTemplate object, dict, or filepath) – Either an EISFitTemplate, a ‘template’ dictionary, or the path to a template file.
parinfo (list, optional) – List of dictionaries with fit parameters formatted for use with mpfit. Will supercede any parinfo lists loaded from an EISFitTemplate. Required if the ‘template’ parameter is given as a dictionary.
wave (array_like, optional) – Associated wavelength values for the spectra. Required if ‘inten’ is given as an array and ignored otherwise.
errs (array_like, optional) – Intensity error values for the spectra. Required if ‘inten’ is given as an array and ignored otherwise.
min_points (int, optional) – Minimum number of good quality data points (i.e. non-zero values & errs) to be used in each fit. Spectra with fewer data points will be skipped. Must be a number >= the total number of fit parameters. Default is 7.
ncpu (int, optional) – Number of cpu processes to parallelize over. Must be less than or equal to the total number of cores the system has. If set to ‘max’ or None, the code will use the maximum number of cores available. Default is ‘max’. Important: due to the specifics of how the multiprocessing library works, any statements that call fit_spectra() using ncpu > 1 MUST be wrapped in a “if __name__ == ‘__main__’:” statement in the top-level program. If such a “name guard” statement is not detected, this function will fall back to using a single process.
unsafe_mp (bool, optional) – If set to True (and ncpu > 0), will use multiprocessing even if there is no “name guard” in use (see above). Used by the console script “eit_fit_files”. Default is False (name guard enforced). Disabling the name guard runs the risk of spawning infinite processes if run incorrectly. USE AT YOUR OWN RISK!
ignore_warnings (bool, optional) – If set to True, will silence the warning about a missing or disabled name guard (we are serious at it, be careful). Default is False.
skip_fitting (bool, optional) – If set to True, will skip the fitting altogether and just return an empty EISFitResult instance. Used mainly for testing. Default is False.
debug (bool, optional) – If set to True, will print some extra information useful for debugging development versions of the code. Default is False.
fit_res – An EISFitResult object containing the output fit parameters.
- Return type:
EISFitResult class instance