qem.refine
Functions
Find the center of mass of a NumPy array. |
|
|
- qem.refine.calculate_center_of_mass(arr)[source]
Find the center of mass of a NumPy array.
Find the center of mass of a single 2D array, or a list (or multidimensional array) of 2D arrays.
- Parameters:
arr (
Numpy 2D Array (or list/nd-array
ofsuch)
)- Returns:
cy, cx (
array
offloats (or nd-array
offloats)
) – Giving centre coordinates with sub-pixel accuracy
Examples
>>> import atomap.atom_finding_refining as afr >>> arr = np.random.randint(100, size=(10, 10)) >>> data = afr.calculate_center_of_mass(arr)
Notes
This is a much simpler center of mass approach than the one from scipy. Gotten from stackoverflow: https://stackoverflow.com/questions/37519238/python-find-center-of-object-in-an-image
- qem.refine.gauss2d(xy_meshgrid: numpy.ndarray, amplitude: float, x0: float, y0: float, sigma_x: float, sigma_y: float, theta: float, offset: float) numpy.ndarray
2D Gaussian function for fitting.
- Parameters:
xy_meshgrid (
tuple
ofnp.ndarray
) – Tuple containing the X and Y meshgridsamplitude (
float
) – Peak amplitudex0 (
float
) – Peak center coordinatesy0 (
float
) – Peak center coordinatessigma_x (
float
) – Standard deviations in x and y directionssigma_y (
float
) – Standard deviations in x and y directionstheta (
float
) – Rotation angle in radiansoffset (
float
) – Background offset
- Returns:
np.ndarray
– 2D Gaussian evaluated on the meshgrid