fitspy.utils module

utilities functions

fitspy.utils.closest_item(element_list, value)

Return the closest element in the given list

fitspy.utils.closest_index(element_list, value)

Return the closest element index in the given list

fitspy.utils.hsorted(list_)

Sort the given list in the way that humans expect

fitspy.utils.fileparts(filename)

Returns different file parts of a file

fitspy.utils.check_or_rename(filename, add=0)

Return filename with increment xx_{add}.yy if file access is denied

fitspy.utils.load_from_json(filename)

Load a dictionary from a ‘.json’ file

Parameters:

filename (str) – Pathname of the .json file

Return type:

a dict object

fitspy.utils.save_to_json(filename, dictionary, indent=3)

Function to save dictionary in a ‘.json’ file with a compact format

Parameters:
  • filename (str) – Pathname of the .json file

  • dictionary (dict object) – The dictionary to save

  • indent (int, optional) – json keyword for indentation. See dedicated doc for more details

fitspy.utils.load_models_from_txt(fname, MODELS)

Load models from ‘.txt’ file

Parameters:
  • fname (str or WindowsPath) – Filename of the .txt file with the models expressions: model_name1 = expression1 model_name2 = expression2

  • MODELS (dict) – Dictionary corresponding to fitspy.PEAK_MODELS or fitspy.BKG_MODELS

fitspy.utils.load_models_from_py(fname)

Load models from ‘.py’ file (See the documentation for more details)

fitspy.utils.get_dim(fname)

Return the dimension (1, 2 or None) of the spectrum/spectra field

fitspy.utils.get_reader_from_rsciio(fname)

Return the reader object using the Rosettasciio library

fitspy.utils.get_x_data_from_rsciio(fname)

Return the spectrum/spectra support (‘x’) and the related intensities (‘data’) using the Rosettasciio library

fitspy.utils.get_1d_profile(fname)

Return the spectrum support (‘x0’) and its intensity (‘y0’)

fitspy.utils.get_2d_map(fname)

Return the array related to a 2D-map. For more details about the array shape, see: https://cea-metrocarac.github.io/fitspy/doc/user_guide/input_data.html#d-map-spectra

fitspy.utils.eval_noise_amplitude(y)

Evaluate the noise amplitude wrt oscillations at every other point