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
- 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
- get_objects(fname)
Return spectrum and parent (spectra or spectra map) related to ‘fname’
- 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, fit_only=False, tk_progressbar=None, **fit_kwargs)
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)
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 work with in fitting
fit_only (bool, optional) – Activation key to process only fitting
tk_progressbar (ProgressBar obj, optional) – Progression bar using tkinter.ttk.Progressbar to follow the ‘apply_model’ progression
fit_kwargs (dict) – Keywords arguments passed to spectrum.fit()
- save(fname_json, fnames=None)
Save spectra in a .json file
- Parameters:
fname_json (str) – 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)
Return a Spectra object from a .json file
- fitspy.spectra.progressbar(queue_incr, ntot, tk_progressbar=None)
Progress bar