fitspy.spectra module

Class dedicated to handle ‘Spectrum’ objects contained in a list managed by “Spectra”

class fitspy.spectra.Spectra(spectra_list=None)

Bases: list

Class dedicated to handle ‘Spectrum’ objects contained in a list

spectra_maps
Type:

list of SpectraMap objects

pbar_index

Index related to the Progress bar during the fit processing

Type:

int

Parameters:

spectra_list (list of Spectrum objects, optional) –

property fnames

Return all the fnames related to spectra AND spectra maps

property all

Return all the spectra related to spectra AND spectra maps

intensity()

Return the raw intensity array related to spectra AND spectra maps

get_objects(fname)

Return spectrum and parent (spectra or spectra map) related to ‘fname’

outliers_limit_calculation(coef=1.5, nmax=5)

Calculate the outliers limit from ‘coef’ * intensity_ref

save_results(dirname_res, fnames=None)

Save spectra results (peaks parameters and statistics) in .csv files

Parameters:
  • dirname_res (str) – Dirname where to save the .csv files

  • fnames (list of str, optional) – List of the spectrum ‘fnames’ to save. If None, consider all the spectrum contained in the ‘spectra’ list

save_figures(dirname_fig, fnames=None, bounds=None)

Save spectra figures

Parameters:
  • dirname_fig (str) – Dirname where to save the figures

  • fnames (list of str, optional) – List of the spectrum ‘fnames’ to save. If None, consider all the spectrum contained in the ‘spectra’ list

  • bounds (tuple of 2 tuples, optional) – Axis limits corresponding to ((xmin, xmax), (ymin, ymax))

static load_model(fname_json, ind=0)

Return a fitspy model (‘model_dict’) from a ‘.json’ file

Parameters:
  • fname_json (str) – Filename associated to the spectra .json file where to extract the fitspy model

  • ind (int, optional) – Spectrum index to consider as model in the spectra issued from the .json file reloading

Returns:

model_dict – The corresponding fitspy model

Return type:

dict

apply_model(model_dict, fnames=None, ncpus=1, show_progressbar=True)

Apply ‘model’ to all or part of the spectra

Parameters:
  • model_dict (dict) – Dictionary related to the Spectrum object attributes (obtained from Spectrum.save() for instance) to be applied

  • fnames (list of str, optional) – List of the spectrum.fname to handle. If None, apply the model to all the spectra

  • ncpus (int, optional) – Number of CPU to use during the fit processing

  • show_progressbar (bool, optional) – Activation key to show the progress bar

progressbar(queue_incr, ntot, ncpus, show_progressbar)

Progress bar

save(fname_json=None, fnames=None)

Return a ‘dict_spectra’ dictionary with all the spectrum attributes and Save it in a .json file if a ‘fname_json’ is given

Parameters:
  • fname_json (str, optional) – Filename associated to the .json file for the spectra saving

  • fnames (list of str, optional) – List of the spectrum ‘fnames’ to save. If None, consider all the spectrum contained in the ‘spectra’ list

static load(fname_json, preprocess=False)

Return a Spectra object from a .json file