stemtool.nbed package¶
Submodules¶
stemtool.nbed.nbed_strain module¶
-
stemtool.nbed.nbed_strain.ROI_strain_map(strain_ROI, ROI)[source]¶ Convert the strain in the ROI array to a strain map
-
stemtool.nbed.nbed_strain.angle_fun(angle, image_orig, axis=0)[source]¶ Rotation Sum Finder
Parameters: - angle (float) – Angle to rotate
- image_orig ((2,2) shape ndarray) – Input Image
- axis (int, optional) – Axis along which to perform sum
Returns: rotmin – Sum of the rotated image multiplied by -1 along the axis specified
Return type: float
Notes
This is an internal minimization function for finding the minimum sum of the image at a particular rotation angle.
See also
-
stemtool.nbed.nbed_strain.aperture_image(data4D, center, radius)[source]¶ Generate Virtual DF image for a given aperture
Parameters: - data4D (ndarray of shape (4,4)) – the first two dimensions are Fourier space, while the next two dimensions are real space
- center (ndarray of shape (1,2)) – Center of the circular aperture
- radius (float) – Radius of the circular aperture
Returns: df_image – Generated virtual dark field image from the aperture and 4D data
Return type: ndarray of shape (2,2)
Notes
We generate the aperture first, and then make copies of the aperture to generate a 4D dataset of the same size as the 4D data. Then we do an element wise multiplication of this aperture 4D data with the 4D data and then sum it along the two Fourier directions.
-
stemtool.nbed.nbed_strain.custom_detector(data4D, det_inner, det_outer, det_center=(0, 0), mrad_calib=0)[source]¶ Generate an image with a custom annular detector located anywhere in diffraction space
Parameters: - data4D (ndarray of shape (4,4)) – the first two dimensions are Fourier space, while the next two dimensions are real space
- center (ndarray of shape (1,2)) – Center of the circular aperture
- radius (float) – Radius of the circular aperture
Returns: df_image – Generated virtual dark field image from the aperture and 4D data
Return type: ndarray of shape (2,2)
Notes
We generate the aperture first, and then make copies of the aperture to generate a 4D dataset of the same size as the 4D data. Then we do an element wise multiplication of this aperture 4D data with the 4D data and then sum it along the two Fourier directions.
-
stemtool.nbed.nbed_strain.data4Dto2D(data4D)[source]¶ Convert 4D data to 2D data
Parameters: data4D (ndarray of shape (4,4)) – the first two dimensions are Fourier space, while the next two dimensions are real space Returns: data2D – Raveled 2D data where the first two dimensions are positions while the next two dimensions are spectra Return type: ndarray of shape (2,2)
-
stemtool.nbed.nbed_strain.rotate_and_center_ROI(data4D_ROI, rotangle, xcenter, ycenter)[source]¶ Rotation Corrector
Parameters: - data4D_ROI (ndarray) – Region of interest of the 4D-STEM dataset in the form of ROI pixels (scanning), CBED_Y, CBED_x
- rotangle (float) – angle in counter-clockwise direction to rotate individual CBED patterns
- xcenter (float) – X pixel co-ordinate of center of mean pattern
- ycenter (float) – Y pixel co-ordinate of center of mean pattern
Returns: corrected_ROI – Each CBED pattern from the region of interest first centered and then rotated along the center
Return type: ndarray
Notes
We start by centering each 4D-STEM CBED pattern and then rotating the patterns with respect to the pattern center
-
stemtool.nbed.nbed_strain.rotation_finder(image_orig, axis=0)[source]¶ Angle Finder
Parameters: - image_orig ((2,2) shape ndarray) – Input Image
- axis (int, optional) – Axis along which to perform sum
Returns: min_x – Angle by which if the image is rotated by, the sum of the image along the axis specified is maximum
Return type: float
Notes
Uses the angle_fun function as the minimizer.
See also
-
stemtool.nbed.nbed_strain.test_aperture(pattern, center, radius, showfig=True)[source]¶ Test an aperture position for Virtual DF image
Parameters: - pattern (ndarray of shape (2,2)) – Diffraction pattern, preferably the mean diffraction pattern for testing out the aperture location
- center (ndarray of shape (1,2)) – Center of the circular aperture
- radius (float) – Radius of the circular aperture
- showfig (bool, optional) – If showfig is True, then the image is displayed with the aperture overlaid
Returns: aperture – A matrix of the same size of the input image with zeros everywhere and ones where the aperture is supposed to be
Return type: ndarray of shape (2,2)
Notes
Use the showfig option to visually test out the aperture location with varying parameters