Configuration#

You can configure abTEM with a YAML configuration file (abtem.yaml), which controls a number of options and feature flags.

Configuration files#

The configuration is specified by any YAML file in ~/.config/abtem/ or /etc/abtem/. abTEM searches for all YAML files within each of these directories and merges them together.

Below is the full default configuration file. Anything you set in your own YAML will be merged into these defaults before they are used to configure the build.

device: cpu
fft: mkl
local_diagnostics:
  progress_bar: true
dask:
  lazy: true
  scheduler: threads
  chunk-size: 128 MB
  chunk-size-gpu: 512 MB
cupy:
  fft-cache-size: 0 MB
mkl:
  threads: 1
fftw:
  threads: 1
  planning_effort: FFTW_MEASURE
warnings:
  prism-interpolation-gpts: true
  dask-blockwise-performance: false

Access configuration#

abtem.config.get(key[, default, config, ...])

Get elements from global config

The abTEM configuration system is usually accessed using the abtem.config.get function. You can use . for nested access, for example:

import dask
dask.config.get("dask.chunk-size") # use "." for nested access

Specify configuration in Python#

abtem.config.set([arg, config, lock])

Temporarily set configuration values within a context manager

The configuration is stored within a normal Python dictionary in abtem.config.config and can be modified using normal Python operations.

Additionally, you can temporarily set a configuration value using the abtem.config.set function. This function accepts a dictionary as an input and interprets “.” as nested access:

abtem.config.set({"dask.chunk-size": "256 MB"})

This function can also be used as a context manager for consistent cleanup:

with abtem.config.set({"dask.chunk-size": "256 MB"}):
    exit_waves = probe.multislice(potential)