LiberTEM Context API

See Python API for introduction and complete examples.

Context

class libertem.api.Context(executor: libertem.executor.base.JobExecutor = None)[source]

Context is the main entry point of the LiberTEM API. It contains methods for loading datasets, creating analyses on them and running them.

__init__(executor: libertem.executor.base.JobExecutor = None)[source]

Create a new context. In the background, this creates a suitable executor and spins up a local Dask cluster.

Parameters

executor (JobExecutor or None) – If None, create a DaskJobExecutor that uses all cores on the local system.

Examples

>>> ctx = libertem.api.Context()
>>> # Create a Context using an inline executor for debugging
>>> from libertem.executor.inline import InlineJobExecutor
>>> debug_ctx = libertem.api.Context(executor=InlineJobExecutor())
create_com_analysis(dataset: libertem.io.dataset.base.dataset.DataSet, cx: int = None, cy: int = None, mask_radius: int = None, flip_y: bool = False, scan_rotation: float = 0.0) → libertem.analysis.com.COMAnalysis[source]

Create a center-of-mass (first moment) analysis, possibly masked.

Parameters
  • dataset – the dataset to work on

  • cx – reference center x value

  • cy – reference center y value

  • mask_radius – mask out intensity outside of mask_radius from (cy, cx)

  • flip_y (bool) – Flip the Y coordinate. Some detectors, namely Quantum Detectors Merlin, may have pixel (0, 0) at the lower left corner. This has to be corrected to get the sign of the y shift as well as curl and divergence right. Added in 0.6.0.dev0

  • scan_rotation (float) – Scan rotation in degrees. The optics of an electron microscope can rotate the image. Furthermore, scan generators may allow scanning in arbitrary directions. This means that the x and y coordinates of the detector image are usually not parallel to the x and y scan coordinates. For interpretation of center of mass sifts, however, the shift vector in detector coordinates has to be put in relation to the position on the sample. The scan_rotation parameter can be used to rotate the detector coordinates to match the scan coordinate system. A positive value rotates the displacement vector clock-wise. That means if the detector seems rotated to the right relative to the scan, this value should be negative to counteract this rotation. Added in 0.6.0.dev0

Returns

COMAnalysis – When run by the Context, this Analysis generates a libertem.analysis.com.COMResultSet.

Return type

libertem.analysis.base.Analysis

create_disk_analysis(dataset: libertem.io.dataset.base.dataset.DataSet, cx: int = None, cy: int = None, r: int = None) → libertem.analysis.disk.DiskMaskAnalysis[source]

Create an Analysis that integrates over a disk (i.e. filled circle).

Parameters
  • dataset – the dataset to work on

  • cx – center x value

  • cy – center y value

  • r – radius of the disk

Returns

DiskMaskAnalysis – When run by the Context, this Analysis generates a libertem.analysis.masks.SingleMaskResultSet.

Return type

libertem.analysis.base.Analysis

create_mask_analysis(factories: Union[Callable[], Union[numpy.ndarray, scipy.sparse.coo.coo_matrix, scipy.sparse.dok.dok_matrix]], Iterable[Callable[], Union[numpy.ndarray, scipy.sparse.coo.coo_matrix, scipy.sparse.dok.dok_matrix]]]], dataset: libertem.io.dataset.base.dataset.DataSet, use_sparse: bool = None, mask_count: int = None, mask_dtype: numpy.dtype = None, dtype: numpy.dtype = None) → libertem.analysis.masks.MasksAnalysis[source]

Create a mask application analysis. Each factory function should, when called, return a numpy array with the same shape as frames in the dataset (so dataset.shape.sig).

This is a more high-level interface than ApplyMasksUDF and differs in the way the result is returned. With ApplyMasksUDF, it is a single numpy array, here we split it up for each mask we apply, make some default visualization available etc.

Parameters
  • factories (Union[Callable[[], array_like], Iterable[Callable[[], array_like]]]) – Function or list of functions that take no arguments and create masks. The returned masks can be numpy arrays, scipy.sparse or sparse https://sparse.pydata.org/ matrices. The mask factories should not reference large objects because they can create significant overheads when they are pickled and unpickled. If a single function is specified, the first dimension is interpreted as the mask index.

  • dataset (libertem.io.dataset.base.DataSet) – dataset to work on

  • use_sparse (bool or None) –

    • None (default): Use sparse matrix multiplication if all factory functions return a sparse mask, otherwise convert all masks to dense matrices and use dense matrix multiplication

    • True: Convert all masks to sparse matrices.

    • False: Convert all masks to dense matrices.

  • mask_count (int, optional) – Specify the number of masks if a single factory function is used so that the number of masks can be determined without calling the factory function.

  • mask_dtype (numpy.dtype, optional) – Specify the dtype of the masks so that mask dtype can be determined without calling the mask factory functions. This can be used to override the mask dtype in the result dtype determination. As an example, setting this to np.float32 means that returning masks of type float64 will not switch the calculation and result dtype to float64 or complex128.

  • dtype (numpy.dtype, optional) – Specify the dtype to do the calculation in. Integer dtypes are possible if the numpy casting rules allow this for source and mask data.

Returns

MasksAnalysis – When run by the Context, this Analysis generates a libertem.analysis.masks.MasksResultSet.

Return type

libertem.analysis.base.Analysis

Examples

>>> # Use intermediate variables instead of referencing
>>> # large complex objects like a dataset within the
>>> # factory function
>>> shape = dataset.shape.sig
>>> analysis = ctx.create_mask_analysis(
...     factories=[lambda: np.ones(shape)],
...     dataset=dataset
... )
>>> result = ctx.run(analysis)
>>> result.mask_0.raw_data.shape
(16, 16)
create_mask_job(factories: Union[Callable[], Union[numpy.ndarray, scipy.sparse.coo.coo_matrix, scipy.sparse.dok.dok_matrix]], Iterable[Callable[], Union[numpy.ndarray, scipy.sparse.coo.coo_matrix, scipy.sparse.dok.dok_matrix]]]], dataset: libertem.io.dataset.base.dataset.DataSet, use_sparse: bool = None, mask_count: int = None, mask_dtype: numpy.ndarray = None, dtype: numpy.ndarray = None) → libertem.job.masks.ApplyMasksJob[source]

Create a low-level mask application job. Each factory function should, when called, return a numpy array with the same shape as frames in the dataset (so dataset.shape.sig).

Deprecated since version 0.4.0: Use create_mask_analysis() or ApplyMasksUDF. See also Job API deprecation.

Parameters
  • factories (Union[Callable[[], array_like], Iterable[Callable[[], array_like]]]) – Function or list of functions that take no arguments and create masks. The returned masks can be numpy arrays, scipy.sparse or sparse https://sparse.pydata.org/ matrices. The mask factories should not reference large objects because they can create significant overheads when they are pickled and unpickled.

  • dataset (libertem.io.dataset.base.DataSet) – dataset to work on

  • use_sparse (bool or None) –

    • None (default): Use sparse matrix multiplication if all factory functions return a sparse mask, otherwise convert all masks to dense matrices and use dense matrix multiplication

    • True: Convert all masks to sparse matrices.

    • False: Convert all masks to dense matrices.

  • mask_count (int, optional) – Specify the number of masks if a single factory function is used so that the number of masks can be determined without calling the factory function.

  • mask_dtype (numpy.dtype, optional) – Specify the dtype of the masks so that mask dtype can be determined without calling the mask factory functions. This can be used to override the mask dtype in the result dtype determination. As an example, setting this to np.float32 means that masks of type float64 will not switch the calculation and result dtype to float64 or complex128.

  • dtype (numpy.dtype, optional) – Specify the dtype to do the calculation in. Integer dtypes are possible if the numpy casting rules allow this for source and mask data.

Returns

ApplyMasksJob – When run by the Context, this Job creates a numpy.ndarray of shape (n_masks, prod(ds.shape.nav))

Return type

libertem.job.base.Job

Examples

>>> # Use intermediate variables instead of referencing
>>> # large complex objects like a dataset within the
>>> # factory function
>>> shape = dataset.shape.sig
>>> job = ctx.create_mask_job(
...     factories=[lambda: np.ones(shape)],
...     dataset=dataset
... )
>>> result = ctx.run(job)
create_pick_analysis(dataset: libertem.io.dataset.base.dataset.DataSet, x: int, y: int = None, z: int = None) → libertem.analysis.raw.PickFrameAnalysis[source]

Create an Analysis that picks a single frame / signal element from (z, y, x). The number of parameters must match number of navigation dimensions in the dataset, for example if you have a 4D dataset with two signal dimensions and two navigation dimensions, you need to specify x and y.

Parameters
  • dataset – The dataset to work on

  • x – x coordinate

  • y – y coordinate

  • z – z coordinate

Returns

PickFrameAnalysis – When run by the Context, this Analysis generates a libertem.analysis.raw.PickResultSet.

Return type

libertem.analysis.base.Analysis

Examples

>>> dataset = ctx.load(
...     filetype="memory",
...     data=np.zeros([16, 16, 16, 16, 16], dtype=np.float32),
...     sig_dims=2
... )
>>> analysis = ctx.create_pick_analysis(dataset=dataset, x=9, y=8, z=7)
>>> result = ctx.run(analysis)
>>> assert result.intensity.raw_data.shape == tuple(dataset.shape.sig)
create_pick_job(dataset: libertem.io.dataset.base.dataset.DataSet, origin: Tuple[int], shape: Tuple[int] = None) → libertem.job.raw.PickFrameJob[source]

Create a job that picks raw data from origin with the size defined in shape.

Note

If you just want to read single frames, it is easier to use create_pick_analysis().

Note

It is not efficient to use this method on large parts of datasets, please consider implementing a UDF instead.

Deprecated since version 0.4.0: Use libertem.api.Context.create_pick_analysis(), libertem.udf.raw.PickUDF, libertem.udf.masks.ApplyMasksUDF with a subset of an identity matrix and a ROI, or a custom UDF (User-defined functions) as a replacement. See also Job API deprecation.

Parameters
  • dataset – The dataset to work on

  • origin – Where to start reading. You can either specify all dimensions, or only nav dimensions, in which case the signal is read starting from (0, …, 0).

  • shape – The shape of the data to read. If None, read a “frame” or single signal element

Returns

PickFrameJob – A job that returns the specified raw data as numpy.ndarray

Return type

libertem.job.base.Job

Examples

>>> dataset = ctx.load(
...     filetype="memory",
...     data=np.zeros([16, 16, 16, 16, 16], dtype=np.float32),
...     sig_dims=2
... )
>>> origin = (7, 8, 9)
>>> job = ctx.create_pick_job(dataset=dataset, origin=origin)
>>> result = ctx.run(job)
>>> assert result.shape == tuple(dataset.shape.sig)
create_point_analysis(dataset: libertem.io.dataset.base.dataset.DataSet, x: int = None, y: int = None) → libertem.analysis.point.PointMaskAnalysis[source]

Create an Analysis that selects the pixel with coords (y, x) from each frame

Returns

PointMaskAnalysis – When run by the Context, this Analysis generates a libertem.analysis.masks.SingleMaskResultSet.

Return type

libertem.analysis.base.Analysis

create_radial_fourier_analysis(dataset: libertem.io.dataset.base.dataset.DataSet, cx: float = None, cy: float = None, ri: float = None, ro: float = None, n_bins: int = None, max_order: int = None, use_sparse: bool = None) → libertem.analysis.radialfourier.RadialFourierAnalysis[source]

Create an Analysis that calculates the Fourier transform of rings around the center.

See Radial Fourier Series for details on the method!

Parameters
  • dataset – the dataset to work on

  • cx – center x value

  • cy – center y value

  • ri – inner radius

  • ro – outer radius

  • n_bins – number of bins

  • max_order – maximum order of calculated Fourier component

Returns

RadialFourierAnalysis – When run by the Context, this Analysis generates a libertem.analysis.radialfourier.RadialFourierResultSet.

Return type

libertem.analysis.base.Analysis

create_ring_analysis(dataset: libertem.io.dataset.base.dataset.DataSet, cx: int = None, cy: int = None, ri: int = None, ro: int = None) → libertem.analysis.ring.RingMaskAnalysis[source]

Create an Analysis that integrates over a ring.

Parameters
  • dataset – the dataset to work on

  • cx – center x value

  • cy – center y value

  • ri – inner radius

  • ro – outer radius

Returns

RingMaskAnalysis – When run by the Context, this Analysis generates a libertem.analysis.masks.SingleMaskResultSet.

Return type

libertem.analysis.base.Analysis

create_sum_analysis(dataset) → libertem.analysis.sum.SumAnalysis[source]

Create an Analysis that sums all signal elements along the navigation dimension, preserving the signal dimension.

Parameters

dataset – the dataset to work on

Returns

SumAnalysis – When run by the Context, this Analysis generates a libertem.analysis.sum.SumResultSet.

Return type

libertem.analysis.base.Analysis

load(filetype: str, *args, **kwargs) → libertem.io.dataset.base.dataset.DataSet[source]

Load a DataSet. As it doesn’t load the whole data into RAM at once, you can load and process datasets that are bigger than your available RAM. Using fast storage (i.e. SSD) is advisable.

Changed in version 0.5.0: Added support for filetype=”auto”

Parameters
  • filetype (str) – one of: hdf5, raw, mib, blo, k2is, ser, frms6, empad, memory, dm, seq, mrc; or use “auto” to automatically determine filetype and parameters

  • args – passed on to the DataSet implementation

  • kwargs – passed on to the DataSet implementation

Returns

DataSet – The loaded dataset

Return type

libertem.io.dataset.base.DataSet

Note

Additional parameters are passed to the concrete DataSet implementation.

Note

See Data Set API for format-specific documentation.

map(dataset: libertem.io.dataset.base.dataset.DataSet, f, roi: numpy.ndarray = None, progress: bool = False)libertem.common.buffers.BufferWrapper[source]

Create an AutoUDF with function f() and run it on dataset

Changed in version 0.5.0: Added the progress parameter

Parameters
  • dataset – The dataset to work on

  • f – Function that accepts a frame as the only parameter. It should return a strongly reduced output compared to the size of a frame.

  • roi (numpy.ndarray) – region of interest as bool mask over the navigation axes of the dataset

  • progress (bool) – Show progress bar

Returns

BufferWrapper – The result of the UDF. Access the underlying numpy array using the data property. Shape and dtype is inferred automatically from f.

Return type

libertem.common.buffers.BufferWrapper

run(job: Union[libertem.job.base.Job, libertem.analysis.base.Analysis], roi: numpy.ndarray = None, progress: bool = False, corrections: libertem.corrections.corrset.CorrectionSet = None) → Union[numpy.ndarray, libertem.analysis.base.AnalysisResultSet][source]

Run the given Job or Analysis and return the result data.

Changed in version 0.5.0: Added the progress parameter

Changed in version 0.6.0: Added the corrections parameter

Parameters
  • job – the job or analysis to run

  • roi (numpy.ndarray, optional) – Boolean mask of the navigation dimension.

  • progress (bool) – Show progress bar

  • corrections – Corrections to apply, i.e. dark frame substraction, applying a gain map, … These are ignored for old job-style analyses.

Returns

result – Running a Job returns a numpy.ndarray, running an Analysis returns a libertem.analysis.base.AnalysisResultSet. See the matching create_*_analysis function for documentation of the specific AnalysisResultSet subclass or numpy.ndarray that is being returned.

Return type

numpy.ndarray or libertem.analysis.base.AnalysisResultSet

run_udf(dataset: libertem.io.dataset.base.dataset.DataSet, udf: libertem.udf.base.UDF, roi: numpy.ndarray = None, corrections: libertem.corrections.corrset.CorrectionSet = None, progress: bool = False, backends=None) → Dict[str, libertem.common.buffers.BufferWrapper][source]

Run udf on dataset, restricted to the region of interest roi.

Changed in version 0.5.0: Added the progress parameter

Changed in version 0.6.0: Added the corrections and backends parameter

Parameters
  • dataset – The dataset to work on

  • udf – UDF instance you want to run

  • roi (numpy.ndarray) – Region of interest as bool mask over the navigation axes of the dataset

  • progress (bool) – Show progress bar

  • corrections – Corrections to apply while running the UDF. If none are given, the corrections that are part of the DataSet are used, if there are any.

  • backends (None or iterable containing 'numpy', 'cupy' and/or 'cuda') – Restrict the back-end to a subset of the capabilities of the UDF. This can be useful for testing hybrid UDFs.

Returns

Return value of the UDF containing the result buffers of type libertem.common.buffers.BufferWrapper. Note that a BufferWrapper can be used like a numpy.ndarray in many cases because it implements __array__(). You can access the underlying numpy array using the data property.

Return type

dict

Job API

Deprecated since version 0.4.0: Use User-defined functions instead. See also Job API deprecation.

class libertem.job.base.Job[source]

Abstract base class for Job classes.

Passing an instance of an Job sub-class to libertem.api.Context.run() will generate a numpy.ndarray. The shape, type and content of this array is governed by the specific implementation of the Job sub-class.

Changed in version 0.3.0: Job is now an abstract base job for documentation purposes to hide any implementation details from the user. The previous Job base class is now called BaseJob.

Deprecated since version 0.4.0: Use User-defined functions instead. See also Job API deprecation

Analysis API

class libertem.analysis.base.Analysis[source]

Abstract base class for Analysis classes.

An Analysis is the interface between a UDF and the Web API, and handles visualization of partial and full results.

Passing an instance of an Analysis sub-class to libertem.api.Context.run() will generate an AnalysisResultSet. The content of this result set is governed by the specific implementation of the Analysis sub-class.

New in version 0.3.0.

get_job()[source]

Deprecated since version 0.4.0: Use TYPE = ‘UDF’ and get_udf(). See Job API deprecation.

Returns

a Job instance

Return type

Job

get_parameters(parameters)[source]

Get analysis parameters. Override to set defaults

get_results(job_results)[source]

Deprecated since version 0.4.0: Use TYPE = ‘UDF’ and get_udf_results(). See Job API deprecation.

Parameters

job_results (list of ndarray) – raw results from the job

Returns

one or more annotated results

Return type

list of AnalysisResult

get_roi()[source]

Get the region of interest the UDF should be run on. For example, the parameters could describe some geometry, which this method should convert to a boolean array. See also: libertem.analysis.getroi.get_roi()

Returns

region of interest for which we want to run our analysis

Return type

numpy.ndarray or None

get_udf()[source]

Set TYPE=’UDF’ on the class and implement this method to run a UDF from this analysis

get_udf_results(udf_results, roi)[source]

Convert UDF results to a list of AnalysisResults, including visualizations.

Parameters
  • udf_results (dics) – raw results from the UDF

  • roi (numpy.ndarray or None) – Boolean array of the navigation dimension

Returns

one or more annotated results

Return type

list of AnalysisResult

class libertem.analysis.base.AnalysisResult(raw_data, visualized, title, desc, key, include_in_download=True)[source]

This class represents a single 2D image result from an Analysis.

Instances of this class are contained in an AnalysisResultSet.

raw_data

The raw numerical data of this result

Type

numpy.ndarray

visualized

Visualized result as numpy.ndarray with RGB or RGBA values

Type

numpy.ndarray

title

Title for the GUI

Type

str

desc

Short description in the GUI

Type

str

key

Key to identify the result in an AnalysisResultSet

Type

str

__init__(raw_data, visualized, title, desc, key, include_in_download=True)[source]

Initialize self. See help(type(self)) for accurate signature.

class libertem.analysis.base.AnalysisResultSet(results: List[libertem.analysis.base.AnalysisResult], raw_results=None)[source]

Base class for Analysis result sets. libertem.api.Context.run() returns an instance of this class or a subclass. Many of the subclasses are just introduced to document the Analysis-specific results (keys) of the result set and don’t introduce new functionality.

The contents of an AnalysisResultSet can be addressed in four different ways:

  1. As a container class with the AnalysisResult.key properties as attributes of type AnalysisResult.

  2. As a list of AnalysisResult objects.

  3. As an iterator of AnalysisResult objects (since 0.3).

  4. As a dictionary of AnalysisResult objects with the AnalysisResult.key properties as keys.

This allows to implement generic result handling code for an Analysis, for example GUI display, as well as specific code for particular Analysis subclasses.

raw_results

Raw results from the underlying numerical processing, if available, otherwise None.

Examples

>>> mask_shape = tuple(dataset.shape.sig)
>>> def m0():
...    return np.ones(shape=mask_shape)
>>> def m1():
...     result = np.zeros(shape=mask_shape)
...     result[0,0] = 1
...     return result
>>> analysis = ctx.create_mask_analysis(
...     dataset=dataset, factories=[m0, m1]
... )
>>> result = ctx.run(analysis)
>>> # As an object with attributes
>>> print(result.mask_0.title)
mask 0
>>> print(result.mask_1.title)
mask 1
>>> # As a list
>>> print(result[0].title)
mask 0
>>> # As an iterator
>>> # New since 0.3.0
>>> for m in result:
...     print(m.title)
mask 0
mask 1
>>> # As a dictionary
>>> print(result['mask_1'].title)
mask 1
__init__(results: List[libertem.analysis.base.AnalysisResult], raw_results=None)[source]

Initialize self. See help(type(self)) for accurate signature.

class libertem.analysis.masks.MasksResultSet(results: List[libertem.analysis.base.AnalysisResult], raw_results=None)[source]

Running a MasksAnalysis via libertem.api.Context.run() on a dataset returns an instance of this class.

If any of the masks or the dataset contain complex numbers, the regular mask results attributes carry the absolute value of the results, and additional attributes with real part, imaginary part, phase and full complex result are available.

New in version 0.3.0.

mask_0, mask_1, ..., mask_<n>

For dataset and masks containing only real numbers: Results of the element-wise multiplication and sum of each individual mask with each detector frame. Each mask result has the shape of the navigation dimension. These keys contain the absolute value of the result if dataset or masks contain complex numbers.

Type

libertem.analysis.base.AnalysisResult

mask_0, mask_0_real, mask_0_imag, mask_0_angle, mask_0_complex, mask_1, mask_1_real, ..., mask_<n>, ..., mask_<n>_complex

If masks or dataset contain complex numbers: Absolute, real part, imaginary part, phase angle, complex result of the element-wise multiplication and sum of each individual mask with each detector frame. Each mask result has the shape of the navigation dimension.

Type

libertem.analysis.base.AnalysisResult

class libertem.analysis.masks.SingleMaskResultSet(results: List[libertem.analysis.base.AnalysisResult], raw_results=None)[source]

A number of Analyses that are based on applying a single mask create an instance of this class as a result when executed via libertem.api.Context.run().

If the dataset contains complex numbers, the regular result attribute carries the absolute value of the result, and additional attributes with real part, imaginary part, phase and full complex result are available.

New in version 0.3.0.

intensity

Sum of the selected region for each detector frame, with shape of the navigation dimension. Absolute of the result if the dataset or mask contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

intensity_real

Real part of the sum of the selected region. This is only available if the dataset or mask contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

intensity_imag

Imaginary part of the sum of the selected region. This is only available if the dataset contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

intensity_angle

Phase angle of the sum of the selected region. This is only available if the dataset or mask contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

intensity_complex

Complex result of the sum of the selected region. This is only available if the dataset or mask contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

class libertem.analysis.com.COMResultSet(results: List[libertem.analysis.base.AnalysisResult], raw_results=None)[source]

Running a COMAnalysis via libertem.api.Context.run() on a dataset returns an instance of this class.

This analysis is usually applied to datasets with real values. If the dataset contains complex numbers, this result contains the keys x_real, y_real, x_imag, y_imag instead of the vector field.

By default, the shift is given in pixel coordinates, i.e. positive x shift goes to the right and positive y shift goes to the bottom. See also Concepts.

Changed in version 0.6.0.dev0: The COM analysis now supports flipping the y axis and rotating the vectors.

New in version 0.3.0.

field

Center of mass shift relative to the center given to the analysis within the given radius as a vector field with components (x, y). The visualized result uses a cubehelix color wheel.

Type

libertem.analysis.base.AnalysisResult

magnitude

Magnitude of the center of mass shift.

Type

libertem.analysis.base.AnalysisResult

divergence

Divergence of the center of mass vector field at a given point

Type

libertem.analysis.base.AnalysisResult

curl

Curl of the center of mass 2D vector field at a given point. Added in 0.6.0.dev0

Type

libertem.analysis.base.AnalysisResult

x

X component of the center of mass shift

Type

libertem.analysis.base.AnalysisResult

y

Y component of the center of mass shift

Type

libertem.analysis.base.AnalysisResult

x_real

Real part of the x component of the center of mass shift (complex dataset only)

Type

libertem.analysis.base.AnalysisResult

y_real

Real part of y component of the center of mass shift (complex dataset only)

Type

libertem.analysis.base.AnalysisResult

x_imag

Imaginary part of the x component of the center of mass shift (complex dataset only)

Type

libertem.analysis.base.AnalysisResult

y_imag

Imaginary part of y component of the center of mass shift (complex dataset only)

Type

libertem.analysis.base.AnalysisResult

class libertem.analysis.sum.SumResultSet(results: List[libertem.analysis.base.AnalysisResult], raw_results=None)[source]

Running a SumAnalysis via libertem.api.Context.run() returns an instance of this class.

If the dataset contains complex numbers, the regular result attribute carries the absolute value of the result and additional attributes with real part, imaginary part, phase and full complex result are available.

New in version 0.3.0.

intensity

Sum of all detector frames along the navigation dimension, preserving the signal dimension. Absolute value of the sum if the dataset contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

intensity_real

Real part of the sum of all detector frames along the navigation dimension, preserving the signal dimension. This is only available if the dataset contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

intensity_imag

Imaginary part of the sum of all detector frames along the navigation dimension, preserving the signal dimension. This is only available if the dataset contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

intensity_angle

Phase angle of the sum of all detector frames along the navigation dimension, preserving the signal dimension. This is only available if the dataset contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

intensity_complex

Complex result of the sum of all detector frames along the navigation dimension, preserving the signal dimension. This is only available if the dataset contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

class libertem.analysis.raw.PickResultSet(results: List[libertem.analysis.base.AnalysisResult], raw_results=None)[source]

Running a PickFrameAnalysis via libertem.api.Context.run() returns an instance of this class.

If the dataset contains complex numbers, the regular result attribute carries the absolute value of the result and additional attributes with real part, imaginary part, phase and full complex result are available.

New in version 0.3.0.

Changed in version 0.4.0: Picking now returns data in the native dtype of the dataset with the new UDF back-end.

intensity

The specified detector frame. Absolute value if the dataset contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

intensity_real

Real part of the specified detector frame. This is only available if the dataset contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

intensity_imag

Imaginary part of the specified detector frame. This is only available if the dataset contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

intensity_angle

Phase angle of the specified detector frame. This is only available if the dataset contains complex numbers.

Type

libertem.analysis.base.AnalysisResult

intensity_complex

Complex result of the specified detector frame. This is only available if the dataset contains complex numbers.

Type

libertem.analysis.base.AnalysisResult