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 coordinatesmass (
ndarray
) – Mass to charge ratiosmisc (
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
(
tuple
,tuple
)
- property dimensions: ndarray
Get the x/y/z dimensions of the dataset
- Return type
ndarray
- classmethod from_apt(filepath, verbose=False)[source]
Read the contents of an apt file into a Roi container
- Parameters
filepath (
str
) – Path to apt fileverbose (
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
- property mass: 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 daltonslower (
float
) – Minimum mass/charge ratioupper (
float
) – Minimum mass/charge ratiomultiplicity (
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
(
ndarray
,ndarray
)
- property misc: dict
Get the dictionary of miscellaneous data for each position. This is usually populated automatically when the
Roi
is create fromRoi.from_epos()
orRoi.from_ato()
.- Return type
dict
- property multiplicities: 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
- 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 Damultiplicity (
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
(
ndarray
,ndarray
)
- property xyz: ndarray
Get the Mx3 array of the x/y/z positions
- Return type
ndarray
- property xyz_center: 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 fromcenter (
Tuple
[float
,float
,float
]) – Geometric center to place the cylinderradius (
float
) – Radius of the cylinderheight (
float
) – Height of the cylinderaxis (
str
) – Axis to orient the cylinder. Either “x”, “y”, or “z”
RoiSphere
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 fromcenter (
Tuple
[float
,float
,float
]) – Geometric center to place the rectangular prismwidths (
Tuple
[float
,float
,float
]) – x, y, z lengths of the rectangular prism