atomcloud.fits.sum_fit module
Created on Mon Mar 21 14:51:16 2022
@author: hofer
- class atomcloud.fits.sum_fit.SumFit2D(function_names, constraints=None, scipy_length=10000.0, fixed_length=None)[source]
Bases:
objectThis object sums the image data on the x and y axes and then x and y fits are done on the 1D sums. The x and y fits are then used to construct a 2D function parameters. The functions passed in must be defined in both thev1D function registry as well as the sumfunction registry as both sets of objects are used in the fitting process.
- Parameters:
function_names (list[str]) –
constraints (list[str] | None) –
scipy_length (int) –
fixed_length (int | None) –
- convert_2d_params_to_1d(coords, params2d)[source]
Converts the 2D fit parameters to the 1D fit parameters along the x and y axes. :param coords: x and y coordinates of image data :param params2d: 2D fit parameters for all fit functions
- Returns:
x axis parameters in 1D format for all fit functions yparams: y axis parameters in 1D format for all fit functions
- Return type:
xparams
- Parameters:
coords (Iterable[ndarray]) –
params2d (list[list[float]]) –
- convert_all_sums_2d(coords, xparams, yparams)[source]
Converts the 1D fit parameters for the x and y axes to the 2D fit parameters. :param coords: x and y coordinates of image data :param xparams: x axis fit parameters in 1D format :param yparams: y axis fit parameters in 1D format
- Returns:
2D fit parameters for all fit functions
- Return type:
params_2d
- Parameters:
coords (Iterable[ndarray]) –
xparams (list[list[float]]) –
yparams (list[list[float]]) –
- get_bounds(bounds, data_shape)[source]
Bounds needs more work, but basically passes None to both of the 1D stage fits which operate on the x and y axes respectively.
- get_fit(coords, data, seed=None, bounds=None, mask=None, verbose=False)[source]
Sums the image data on the x and y axes and then x and y fits are done on the 1D sums. The x and y fits are then used to construct a 2D fit params. The x and y fits and 2d params are returned as dictionaries.
- Parameters:
coords (Iterable[ndarray]) – x and y coordinates of image data
data (ndarray) – image data to be fit
seed (list[list[float]] | None) – initial guess for fit parameters in 2d format?
bounds (list[list[float]] | None) – bounds for fit parameters in 2d format?
mask (ndarray | None) – mask for image data
verbose (bool) – boolean to print out fit info
- Returns:
- x sum fit parameters, y sum fit parameters, 2d fit
parameters in a list
- fit_dicts: dictionary with x sum fit info, y sum fit info and
2d fit info
- Return type:
fit_params
- get_fit_dicts(params_2d, xfit_dicts, yfit_dicts, data_sum)[source]
Creates a dictionary with 2d fit parameters, as well as the x and y sum fit parameters. :param params_2d: 2D fit parameters :param xfit_dicts: dictionary with x sum fit parameters :param yfit_dicts: dictionary with y sum fit parameters :param data_sum: The average of the x and y sum data.
- Returns:
dictionary with 2D fit parameters, as well as the x and y sum fit parameters.
- Return type:
all_fit_dicts
- Parameters:
params_2d (list[list[float]]) –
xfit_dicts (dict) –
yfit_dicts (dict) –
data_sum (float) –
- get_initial_seed(coords, data, mask=None)[source]
Generates the 1D seed parameters based on image data and coords. However just using the initial seed functions from each of the respective 1d function classes.
- Parameters:
coords (Iterable[ndarray]) – x and y coordinates of image data
data (ndarray) – image data to be fit
mask (ndarray | None) –
- Returns:
x axis seeds in 1D format yseeds: y axis seeds in 1D format
- Return type:
xseeds
- get_seed(seed, coords, data)[source]
Converts the 2D seed parameters to the 1D seed parameters if they are in the 2D format or if they are None then it generates the 1D seed parameters based on image data and coords
- Parameters:
seed (None | list[list[float]] | list[list[list[float]]]) – initial guess for fit parameters which is either None or in the 2D format or 1D format.
coords (Iterable[ndarray]) – x and y coordinates of image data
data (ndarray) – image data to be fit
- Returns:
x axis seeds in 1D format yseeds: y axis seeds in 1D format
- Return type:
xseeds
- get_xy_params(coords, params)[source]
Converts the 2D fit parameters to the 1D fit parameters if they are in the 2D format.
- Parameters:
coords (Iterable[ndarray]) – x and y coordinates of image data
params (list[list[float]] | list[list[list[float]]]) – parameters either in 2D format or 1D format
- Returns:
x axis parameters in 1D format yparams: y axis parameters in 1D format
- Return type:
xparams
- is_axes_params(seeds)[source]
Checks if the seeds are in the 2D format or the 1D format.
- Parameters:
seeds (list[list[float]] | list[list[list[float]]]) – seeds for the fit parameters either in 2D format or 1D format.
- Returns:
- boolean that is True if the seeds are in the 1D
format and False if the seeds are in the 2D format.
- Return type:
is_axes_params