save_fit_stats

threadcount.fit.save_fit_stats(filename=None, dataset=None, fit_info='auto', model_keys='auto', snr=None)[source]

Compile fit parameter summary and save to file.

This function will iterate over dataset (an array containing lmfit.model.ModelResult for each spaxel of the image), and extract the information for the fit quality (attributes listed in fit_info) and the fit parameters and their errors (parameter names given by model_keys).

These data entries, along with the spaxel coordinates given in (y, x) form, and the signal to noise value (if the snr parameter is specified) will be written in columns to filename (if given), and returned as a list of lists. (a list of the rows, where each row contains a list of the column entries.)

The parameter fit_info must be a list of the attributes to record, or may be the string “auto”. If it is “auto”, the constant DEFAULT_FIT_INFO defined in this module will be used.

The parameter model_keys must be a list of the parameter names to record, or the special strings “auto” or “all”. If either of these special strings is indicated, then model_keys will be set to the output of the function get_model_keys(), run on the first entry of dataset which is not None, with the parameter ignore = [‘fwhm’] or = None (for “auto” and “all” respectively.)

Parameters:
  • filename (str) – Name of output file

  • dataset (iterable of lmfit.model.ModelResult) – Loop over this to extract fit information

  • fit_info (list of str or "auto", optional) – List of lmfit.model.ModelResult attributes to be recorded, by default “auto”

  • model_keys (list of str, "auto", or "all", optional) – The ModelResult.params parameter names to be recorded, by default “auto”. The default will get this automatically with get_model_keys

  • snr (numpy.ndarray or None) – If not None, will save the snr to the parameters file.