Roi

Roi

class apav.Roi(xyz, mass, misc=None)[source]

High level container for operating on atom probe data sets.

This data structure is the entry point for loading or constructing atom probe data set for use with other components of APAV. Fictitious atom probe data set can be created by providing the required XYZ and mass/charge arrays, or by the alternate constructors for loading from common file types. For example:

Manual data set:

>>> xyz = np.array([[1.2, 0.3, 12.6], [-76.2, 45.6, 0.7]])
>>> mass = np.array([12.4, 6.1, 14.9])
>>> fake_data = Roi(xyz, mass)

Load from file:

>>> pos_data = Roi.from_pos("path_to_pos_file.pos")  # load a pos file
>>> epos_data = Roi.from_epos("path_to_epos_file.epos")  # load a epos file
>>> ato_data = Roi.from_ato("path_to_ato_file.ato")  # load a ato file
Parameters
  • xyz (ndarray) – xyz atom coordinates

  • mass (ndarray) – Mass to charge ratios

  • misc (Optional[dict]) – Dict of other data, (i.e. ions per pulse or detector x pos)

property counts: float

Get the total number of detected ions

Return type

float

property detector_extents: (<class 'tuple'>, <class 'tuple'>)

Get the min/max spatial values in x/y detector coordinates

Return type

(<class ‘tuple’>, <class ‘tuple’>)

property dimensions: numpy.ndarray

Get the x/y/z dimensions of the dataset

Return type

ndarray

property filepath: str

Get the file path, if the Roi was loaded from a file

Return type

str

classmethod from_apt(filepath, verbose=False)[source]

Read the contents of an apt file into a Roi container

Parameters
  • filepath (str) – Path to apt file

  • verbose (bool) – Print the structure of the apt file as it is read (for debug purposes)

classmethod from_ato(filepath)[source]

Read the contents of an extended ato file into an Roi container. Suitable for multiple-hit analysis.

Parameters

filepath (str) – Path to ato file

classmethod from_epos(filepath)[source]

Read the contents of an extended pos file into an Roi container. Suitable for multiple-hit analysis.

Parameters

filepath (str) – Path to epos file

classmethod from_pos(filepath)[source]

Read the contents of a pos file into a Roi container

Parameters

filepath (str) – Path to pos file

has_detailed_info()[source]

Get if the Roi has any supplementary information available (other than x/y/z/mass-charge).

Return type

bool

has_multiplicity_info()[source]

Get if the Roi has multiple detector event information

Return type

bool

has_tof_info()[source]

Get if the the Roi has time of flight information

Return type

bool

property mass: numpy.ndarray

Get the Mx1 array of the mass/charge ratios of each position

Return type

ndarray

property mass_extents: Tuple[float, float]

Get the min and max detected mass/charge ratio

Return type

Tuple[float, float]

mass_histogram(bin_width=0.05, lower=0, upper=200, multiplicity='all', norm=False)[source]

Get the mass/charge ratio histogram of the given Roi. This function is cached to increase speed under repeated calls.

Parameters
  • bin_width (float) – Bin width in daltons

  • lower (float) – Minimum mass/charge ratio

  • upper (float) – Minimum mass/charge ratio

  • multiplicity (Union[str, int]) – The portion of multiplicity to generate the histogram from. “All” for all hits, int >= 1 for a specific multiplicity, “multiples” for all multiple hits.

  • norm (Union[bool, Tuple[float, float]]) – Normalize the histogram to unity. True/False to generate normalization constant from the whole spectrum, or Tuple[float, float] to generate normalization constant from a range on the spectrum.

Return type

(<class ‘numpy.ndarray’>, <class ‘numpy.ndarray’>)

memory_size()[source]

Get the approximate memory footprint in Mb

Return type

float

property misc: dict

Get the dictionary of miscellaneous data for each position. This is usually populated automatically when the Roi is create from Roi.from_epos() or Roi.from_ato().

Return type

dict

property multiplicities: numpy.ndarray

Get an array of the sorted multiplicities.

Return type

ndarray

multiplicity_counts()[source]

Get the statistical count of each degree of multiple-detector events

Return type

Tuple[ndarray, ndarray]

multiplicity_fraction()[source]

Get the statistical fraction of each degree of multiple-detector events

multiplicity_percentage()[source]

Get the statistical percentage of each degree of multiple-detector events

plot_mass_spectrum()[source]

Get an interactive plot of the mass spectrum of the Roi.

require_detector_info()[source]

Use when a function/argument requires detector information

require_multihit_info()[source]

Use when a function/argument requires multiple hit information

require_tof_info()[source]

Use when a function/argument requires time of flight information

to_epos(filepath)[source]

Write the roi to a standard extended pos file

Parameters

filepath (str) – path of the epos file

to_pos(filepath)[source]

Write the roi to a standard pos file

Parameters

filepath (str) – path of the pos file

tof_histogram(bin_width=1, multiplicity='all', norm=False, cutoff=2000)[source]

Get the time-of-flight histogram of the given Roi. This function is cached to increase speed under repeated calls.

Parameters
  • bin_width (float) – Bin width in Da

  • multiplicity (Union[str, int]) – The portion of multiplicity to generate the histogram from. “All” for all hits, int >= 1 for a specific multiplicity, “multiples” for all multiple hits.

  • norm (Union[bool, Tuple[float, float]]) – Normalize the histogram to unity. True/False to generate normalization constant from the whole spectrum, or Tuple[float, float] to generate normalization constant from a range on the spectrum.

  • cutoff (float) – Maximum time of flight value to generate the histogram

Return type

(<class ‘numpy.ndarray’>, <class ‘numpy.ndarray’>)

property xyz: numpy.ndarray

Get the Mx3 array of the x/y/z positions

Return type

ndarray

property xyz_center: numpy.ndarray

Get the center of all positions as the mean of all x/y/z values

Return type

ndarray

property xyz_extents: Tuple[Tuple[float, float], ...]

Get the min/max spatial values of the x/y/z coordinates in nm.

Return type

Tuple[Tuple[float, float], …]

RoiCylinder

class apav.RoiCylinder(parent, center, radius, height, axis='z')[source]

Creates a new roi from an existing roi, containing ions within a cylinder

Parameters
  • parent (Roi) – Parent Roi to generate the subset from

  • center (Tuple[float, float, float]) – Geometric center to place the cylinder

  • radius (float) – Radius of the cylinder

  • height (float) – Height of the cylinder

  • axis (str) – Axis to orient the cylinder. Either “x”, “y”, or “z”

RoiSphere

class apav.RoiSphere(parent, center, radius)[source]

Creates a new roi from an existing roi, containing ions within a sphere

Parameters
  • parent (Roi) – Parent Roi to generate the subset from

  • center (Tuple[float, float, float]) – Geometric center of the sphere

  • radius (float) – Radius of the sphere

RoiRectPrism

class apav.RoiRectPrism(parent, center, widths)[source]

Creates a new roi from an existing roi, containing ions within a rectangular prism

Parameters
  • parent (Roi) – Parent Roi to generate the subset from

  • center (Tuple[float, float, float]) – Geometric center to place the rectangular prism

  • widths (Tuple[float, float, float]) – x, y, z lengths of the rectangular prism