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)