atomcloud.process_fits.combine module

atomcloud.process_fits.combine.combine_level_fits(flat_dicts, df=False)[source]

If the fits are mixed level and only flattened for each multi-function fit and not entirely flattened then this function will combine each of the fit levels for multiple mixed level fits into a dictionary of dictionaries. However, each sub-dictionary will contain the fit results for all images at the fit level.

Parameters:
  • flat_dicts (dict) – The dictionary of image fit dictionaries to combine with the multi-function fits for each image flatted only at the level and not overall for each image.

  • df (bool) – If True, the output will be a pandas DataFrame.

Returns:

The combined fit dictionaries as a dictionary of dictionaries or a pandas DataFrame.

Return type:

dict | DataFrame

atomcloud.process_fits.combine.create_dict(fit_dicts)[source]

When we are dealing with fits from multiple images, we need to make sure that these fit dictionaries are themselves in a dictionary where each key corresponds to the run image and the value is the fit dictionary. This function will check to see if the fit dictionaries are already in this format. If the fit dictionaries are in a list rather than a dictionary, this function will create a dictionary where the keys are simply the index of the fit dictionary in the list.

Parameters:

fit_dicts (dict[dict] | list[dict]) – The fit dictionaries to check.

Returns:

The fit dictionaries in a dictionary format.

Return type:

dict[dict]

atomcloud.process_fits.combine.level_fits_df(fit_dicts)[source]

Convert the fit dictionaries for each multi function fit level in a mixed level fit (see function above for more details) into pandas DataFrames.

Parameters:
  • fit_dicts (dict) – The dictionary of fit dictionaries to convert to

  • DataFrames. (pandas) –

Returns:

Dictionary of pandas DataFrames where each key corresponds to a multi-function fit level and each row in the DataFrame corresponds to an image.

Return type:

dict[pandas.core.frame.DataFrame]

atomcloud.process_fits.combine.process_all_fitdicts(fit_dicts, scale_dict=None, dict_type=None, analyze=True, row_format=False, total_flatten=False)[source]

This is like process_fitdict, but it will process multiple image fit dictionaries at once. This is beneficial because certain processing objects only have to be instantiated once. This function will determine the type of fit dictionary and process it accordingly.

Parameters:
  • fit_dicts (dict) – Dictionary of image fit dictionaries to process.

  • scale_dict (dict | None) –

  • dict_type (str | None) –

  • analyze (bool) –

  • row_format (bool) –

  • total_flatten (bool) –

Return type:

dict[dict]

Returns

Dictionary of processed fit dictionaries.

See the documentation for process_fitdict for more information on the other input arguments as they are the same.

atomcloud.process_fits.combine.process_fitdict(fit_dicts, scale_dict=None, dict_type=None, analyze=True, row_format=False, total_flatten=False)[source]

Process the fit dictionaries for a single image fit. This can be a single multi-function fit or a mixes level fit. This function will determine the type of fit and process it accordingly.

Parameters:
  • fit_dicts (dict) – The fit dictionary to process

  • scale_dict (dict | None) – A dictionary of scaling parameters to use for rescaling the fit dictionary. If None, no rescaling will be performed.

  • dict_type (str | None) – The type of fit dictionary to process. If None, the type will be determined automatically.

  • analyze (bool) – If True, the fit dictionary will be analyzed and the analysis results will be added to the dictionary.

  • row_format (bool) – If True, the fit dictionary will be converted to a row format.

  • total_flatten (bool) – If True, and row_format is True and the fit dictionary corresponds to a mixed level fit, the mixed level multi-function fits will be completely flattened into a single row.

Returns:

The processed fit dictionary.

Return type:

dict

atomcloud.process_fits.combine.total_fit_df(fit_dict)[source]

Convert a dictionary of totally flattened fit dictionaries into a pandas DataFrame where each totallaly flattened fit dictionary is a row and corresponds to a different image.

Parameters:

fit_dict (dict[dict]) – The dictionary of totally flattened image fit dictionaries.

Returns:

The pandas DataFrame of the flattened image fit dictionaries.

Return type:

DataFrame