Base classes¶
Module for often-used base classes.
-
class
abtem.base_classes.
Accelerator
(energy=None, lock_energy=False)[source]¶ Accelerator object describes the energy of wave functions and transfer functions.
- Parameters
energy (float) – Acceleration energy [eV].
-
check_match
(other)[source]¶ Raise error if the accelerator of another object is different from this object.
- Parameters
other (Accelerator object) – The accelerator that should be checked.
-
property
energy
¶ Acceleration energy [eV].
- Return type
float
-
match
(other, check_match=False)[source]¶ Set the parameters of this accelerator to match another accelerator.
- Parameters
other (Accelerator object) – The accelerator that should be matched.
check_match (bool) – If true check whether accelerators can match without overriding an already defined energy.
-
property
sigma
¶ Interaction parameter.
- Return type
float
-
property
wavelength
¶ Relativistic wavelength [Å].
- Return type
float
-
class
abtem.base_classes.
Cache
(max_size)[source]¶ Cache object.
Class for handling a dictionary-based cache. When the cache is full, the first inserted item is deleted.
- Parameters
max_size (int) – The maximum number of values stored by this cache.
-
property
cached
¶ Dictionary of cached data.
- Return type
dict
-
property
hits
¶ Number of times a previously calculated object was retrieved.
- Return type
int
-
insert
(key, value)[source]¶ Insert new value into the cache.
- Parameters
key (Any) – The dictionary key of the cached object.
value (Any) – The object to cache.
-
property
misses
¶ Number of times a new object had to be calculated.
- Return type
int
-
class
abtem.base_classes.
Event
[source]¶ Event class for registering callbacks.
-
property
notify_count
¶ Number of times this event has been notified.
-
property
-
class
abtem.base_classes.
Grid
(extent=None, gpts=None, sampling=None, dimensions=2, endpoint=False, lock_extent=False, lock_gpts=False, lock_sampling=False)[source]¶ Grid object.
The grid object represent the simulation grid on which the wave functions and potential are discretized.
- Parameters
extent (two float) – Grid extent in each dimension [Å].
gpts (two int) – Number of grid points in each dimension.
sampling (two float) – Grid sampling in each dimension [1 / Å].
dimensions (int) – Number of dimensions represented by the grid.
endpoint (bool) – If true include the grid endpoint. Default is False. For periodic grids the endpoint should not be included.
-
check_match
(other)[source]¶ Raise error if the grid of another object is different from this object.
- Parameters
other (Grid object) – The grid that should be checked.
-
property
dimensions
¶ Number of dimensions represented by the grid.
- Return type
int
-
property
endpoint
¶ Include the grid endpoint.
- Return type
tuple
-
property
extent
¶ Grid extent in each dimension [Å].
- Return type
tuple
-
property
gpts
¶ Number of grid points in each dimension.
- Return type
tuple
-
match
(other, check_match=True)[source]¶ Set the parameters of this grid to match another grid.
- Parameters
other (Grid object) – The grid that should be matched.
check_match (bool) – If true check whether grids can match without overriding already defined grid parameters.
-
round_to_power
(power=2)[source]¶ Round the grid gpts up to the nearest value that is a power of n. Fourier transforms are faster for arrays of whose size can be factored into small primes (2, 3, 5 and 7).
- Parameters
power (int) – The gpts will be a power of this number.
-
property
sampling
¶ Grid sampling in each dimension [1 / Å].
- Return type
tuple
-
abtem.base_classes.
cache_clear_callback
(target_cache)[source]¶ Helper function for creating a callback that clears a target cache object.
- Parameters
target_cache (Cache object) – The target cache object.
-
abtem.base_classes.
cached_method
(target_cache_property)[source]¶ Decorator for cached methods. The method will store the output in the cache held by the target property.
- Parameters
target_cache_property (str) – The property holding the target cache.