tiltlib.sample.Sample

class tiltlib.sample.Sample(oris: Orientation, phase: Phase, axes: list[Axis])[source]

Bases: SampleHolder

__init__(oris: Orientation, phase: Phase, axes: list[Axis]) None[source]

Sample of spatially distinct orientations

Parameters:
  • oris (Orientation) – The orientations at each point of the sample

  • phase (Phase) – Crystallographic phase of the sample. Only single-phase crystals are supported

  • axes (list[Axis]) – Tilt axes

Methods

TEM_frame_to_sample_frame(v)

Convert a vector in TEM coordinates to sample coordinates

__init__(oris, phase, axes)

Sample of spatially distinct orientations

angle_with(zone_axis[, degrees])

Calculate the angle between the optical axis and the target zone axis, for all pixels in the sample.

as_matrix()

Returns the 3x3 rotation matrix transforming the TEM coordinate system to the sample holder coordinate system

crop(roi)

Crop the sample with a hyperspy ROI and return a new cropped sample

find_tilt_angles(zone_axis[, degrees, ...])

Calculate the tilt angle(s) necessary to align the sample with a given optical axis

from_crystal_map(xmap, axes)

Initialize a Sample from a CrystalMap

mean_zone_axis()

Calculate the mean orientation in the sample, and return the zone axis.

plot()

Plot IPF colormap of the orientations at the given tilt angle(s)

plot_angle_with(zone_axis[, resolution, ...])

Make a plot of similarity score as function of tilt angle(s).

plot_interactive()

Make a IPF colormap plot with a slider for the tilt angle of each tilt axis

plot_orientations()

IPF scatterplot of orientations

plot_orientations_interactive()

Interactive scatterplot of the orientations, with sliders to control the tilt axes

reset_rotation()

Resets the sample holder to the angles it was initialized with

rotate(*angles[, degrees])

Rotates the sample holder by the given angles from the current position

rotate_to(*angles[, degrees])

Sets the angles of all rotation axes to the given angles

rotation_matrix()

Returns the 3x3 rotation matrix transforming the TEM coordinate system to the sample holder coordinate system

sample_frame_to_TEM_frame(v)

Convert a vector in sample coordinates to TEM coordinates

to_matrix()

Returns the 3x3 rotation matrix transforming the TEM coordinate system to the sample holder coordinate system

to_navigator()

Create a IPF-z colormap as a hyperspy signal

to_signal()

Hyperspy signal containing the quaternion data of the orientations at each sample point

Attributes

angles

Current tilt angles, in radians

orientations

The orientations of the sample at the current tilts

TEM_frame_to_sample_frame(v: Vector3d) Vector3d

Convert a vector in TEM coordinates to sample coordinates

Parameters:

v (Vector3d) – TEM vector

Returns:

Sample vector

Return type:

Vector3d

angle_with(zone_axis: Miller, degrees: bool = True) ndarray[source]

Calculate the angle between the optical axis and the target zone axis, for all pixels in the sample.

Parameters:
  • zone_axis (Miller) – Zone axis to calculate for

  • degrees (bool, optional) – Whether to return output in degrees(True) or radians(False), defaults to True

Returns:

Array of angles at all points in the sample

Return type:

np.ndarray

property angles: list[float]

Current tilt angles, in radians

as_matrix() ndarray

Returns the 3x3 rotation matrix transforming the TEM coordinate system to the sample holder coordinate system

Returns:

Rotation matrix

Return type:

np.ndarray

crop(roi: BaseROI) Sample[source]

Crop the sample with a hyperspy ROI and return a new cropped sample

Parameters:

roi (BaseROI) – Region of interest to keep

Raises:

NotImplementedError – If an unsupported ROI is supplied

Returns:

Cropped sample

Return type:

Sample

find_tilt_angles(zone_axis: Miller, degrees: bool = True, use_mean_orientation: bool = False) tuple[float, ...][source]

Calculate the tilt angle(s) necessary to align the sample with a given optical axis

Parameters:
  • zone_axis (Miller) – The zone axis to align to

  • degrees (bool, optional) – Whether to return degrees(True) or radians(False), defaults to True

  • use_mean_orientation (bool, optional) – Whether to perform optimization using the mean orientation of the sample(True) or the mean angle with the zone axis(False), defaults to False

Returns:

Tilt angles

Return type:

tuple[float, …]

classmethod from_crystal_map(xmap: CrystalMap, axes: list[Axis]) Sample[source]

Initialize a Sample from a CrystalMap

Parameters:
  • xmap (CrystalMap) – Orientation map

  • axes (list[Axis]) – Tilt axes

mean_zone_axis() Miller[source]

Calculate the mean orientation in the sample, and return the zone axis. This is mostly useful for single-grain or cropped samples.

Returns:

Zone axis

Return type:

Miller

property orientations: Orientation

The orientations of the sample at the current tilts

Returns:

Tilted orientations

Return type:

Orientation

plot() Figure[source]

Plot IPF colormap of the orientations at the given tilt angle(s)

Returns:

IPFs

Return type:

plt.Figure

plot_angle_with(zone_axis: Miller, resolution: float = 1.0, use_mean_orientation: bool = False) Figure[source]

Make a plot of similarity score as function of tilt angle(s).

Parameters:
  • zone_axis (Miller) – Zone axis to calculate for

  • resolution (float, optional) – Angular resolution of the tilt axes, in degrees, defaults to 1.0

  • use_mean_orientation (bool, optional) – Whether to perform optimization using the mean orientation of the sample(True) or the mean angle with the zone axis(False), defaults to False

Raises:

NotImplementedError – If more than 2 tilt axes are present, as up to 2 are supported

Returns:

Line plot or colormap, depending on the number of tilt angles

Return type:

plt.Figure

plot_interactive() tuple[Figure, Slider][source]

Make a IPF colormap plot with a slider for the tilt angle of each tilt axis

Returns:

Figure and sliders. Returning the slider avoids their functionality being deleted when the function returns

Return type:

tuple[plt.Figure, Slider]

plot_orientations() Figure[source]

IPF scatterplot of orientations

Returns:

IPFs

Return type:

plt.Figure

plot_orientations_interactive() tuple[Figure, Slider][source]

Interactive scatterplot of the orientations, with sliders to control the tilt axes

Returns:

Figure and sliders. Returning the slider avoids their functionality being deleted when the function returns

Return type:

tuple[plt.Figure, Slider]

reset_rotation()

Resets the sample holder to the angles it was initialized with

rotate(*angles: float, degrees: bool = False)

Rotates the sample holder by the given angles from the current position

Parameters:
  • angles (float) – tilt angles, in order of tilt axes

  • degrees (bool, optional) – Whether angles are in degrees(True) or radians(False), defaults to False

rotate_to(*angles: float, degrees: bool = False)

Sets the angles of all rotation axes to the given angles

Parameters:
  • angles (float) – tilt angles, in order of tilt axes

  • degrees (bool, optional) – Whether angles are in degrees(True) or radians(False), defaults to False

rotation_matrix() ndarray

Returns the 3x3 rotation matrix transforming the TEM coordinate system to the sample holder coordinate system

Returns:

Rotation matrix

Return type:

np.ndarray

sample_frame_to_TEM_frame(v: Vector3d) Vector3d

Convert a vector in sample coordinates to TEM coordinates

Parameters:

v (Vector3d) – Sample vector

Returns:

TEM vector

Return type:

Vector3d

to_matrix() ndarray

Returns the 3x3 rotation matrix transforming the TEM coordinate system to the sample holder coordinate system

Returns:

Rotation matrix

Return type:

np.ndarray

to_navigator() Signal1D[source]

Create a IPF-z colormap as a hyperspy signal

Returns:

IPF-z

Return type:

Signal1D

to_signal() Signal1D[source]

Hyperspy signal containing the quaternion data of the orientations at each sample point

Returns:

Quaternion data

Return type:

Signal1D