Interactive (erlab.interactive)¶
Interactive tools based on Qt and pyqtgraph.
This module provides interactive tools for plotting and analyzing ARPES data. See the sidebar on the right for a list of available tools.
Commonly used tools are available directly in the erlab.interactive namespace, so
regular users should not need to import the submodules directly.
Documentation of classes and functions in submodules mostly contain implementation
details for advanced users who want to create new interactive tools. See
Authoring interactive tools for a contributor-oriented walkthrough, and use the
source code of erlab.interactive.utils and erlab.interactive.colors as the
main reference implementations.
Modules
Interactive visualization tool for multidimensional image-like data. |
|
Functions for manipulating colors in Qt. |
|
Interactive tool for visualizing dispersive data. |
|
Quickly browse and load ARPES data files with a file manager-like interface. |
|
Interactive momentum conversion tool. |
|
Various helper functions and extensions to Qt and pyqtgraph. |
- erlab.interactive.data_explorer(directory=None, loader_name=None, *, execute=None)[source]¶
Start the data explorer.
Data explorer is a tool to browse and load ARPES data files with a file manager-like interface. Data attributes of supported files can be quickly inspected, and can be loaded into ImageTool manager for further analysis.
The data explorer can be started from the command line as a standalone application with the following command:
python -m erlab.interactive.explorer
Also, it can be opened from the GUI by selecting “File” -> “Data Explorer” or by pressing Ctrl+E in ImageTool manager.
- erlab.interactive.dtool(data, data_name=None, *, execute=None)[source]¶
Interactive tool for visualizing dispersive data.
This tool can also be accessed from the right-click context menu of an image plot in an ImageTool window.
- erlab.interactive.ftool(data, model=None, params=None, *, data_name=None, model_name=None, execute=None)[source]¶
Launch an interactive fitting tool.
The tool provides an interactive GUI for fitting 1D models to 1D or 2D data.
See the user guide for more information on using the tool.
- Parameters:
data (
DataArray|Dataset) – The 1D or 2D data to fit. Also accepted is a fit resultxarray.Dataset, from which the data to fit will be extracted. In this case, the tool will attempt to restore the fit state from the dataset.model (
Model|None, default:None) – The model to fit to the data. IfNone,MultiPeakModelwill be used.params (
Parameters|dict[str,Any] |None, default:None) – Initial parameters for the fit. IfNone, parameters will be initialized from the model. Ifdatais 2D,paramscan be a dictionary that is interpreted like theparamsargument ofxarray.DataArray.xlm.modelfit().data_name (
str, optional) – The name of the data variable, used in code generation. IfNone, an attempt will be made to infer the name from the calling context.model_name (
str, optional) – The name of the model variable, used in code generation. IfNone, an attempt will be made to infer the name from the calling context.
- erlab.interactive.goldtool(data, data_corr=None, *, data_name=None, execute=None, **kwargs)[source]¶
Interactive tool for correcting curved Fermi edges.
This tool can also be accessed from the right-click context menu of an image plot in an ImageTool window.
- Parameters:
data (
DataArray) – The data to perform Fermi edge fitting on. Must be a 2D DataArray with an ‘eV’ dimension.data_corr (
DataArray|None, default:None) – The data to correct with the edge. Defaults todata.data_name (
str|None, default:None) – Name of the data used in generating the code snipped copied to the clipboard. Overrides automatic detection.**kwargs – Arguments passed onto
erlab.interactive.utils.AnalysisWindow.
- erlab.interactive.itool(data, *, link=False, link_colors=True, manager=None, replace=None, execute=None, **kwargs)[source]¶
Create and display ImageTool windows.
This tool can also conveniently accessed with
xarray.DataArray.qshow()andxarray.Dataset.qshow().- Parameters:
data (
DataArray,Dataset,DataTree,numpy.ndarray,listofDataArrayorlistofnumpy.ndarray) –The data to be displayed. Data can be provided as:
A
xarray.DataArraywith 2 to 4 dimensionsThe DataArray will be displayed in an ImageTool window.
A numpy array with 2 to 4 dimensions
The array will be converted to a DataArray and displayed in an ImageTool.
A list of the above objects
Multiple ImageTool windows will be created and displayed.
-
If the Dataset contains multiple displayable DataArrays, ImageTool asks which variables to open. Data variables that have less than 2 dimensions or more than 4 dimensions are ignored. Dimensions with length 1 are automatically squeezed.
-
Every leaf node will be parsed as a
xarray.Dataset. If the DataTree contains multiple displayable DataArrays, ImageTool asks which variables to open, grouped by DataTree node path.
link (
bool, default:False) – Whether to enable linking between multiple ImageTool windows whendatais a sequence or axarray.Dataset, by defaultFalse.link_colors (
bool, default:True) – Whether to link the color maps between multiple linked ImageTool windows, by defaultTrue. This argument has no effect iflinkis set toFalse.manager (
bool|int|None, default:None) –Whether to open the ImageTool window(s) using the
ImageToolManagerif it is running. An integer targets a specific 0-based manager index. IfTrue, the current process default manager is used, or the only live manager if no default is set. If multiple managers are live and no default has been selected, an error is raised. If not provided, the manager will only be used if it is in the same process as the caller.Changed in version 3.4.0: Argument renamed from
use_managertomanager.Changed in version 3.22.0: Integer manager indexes select a specific ImageTool Manager instance.
replace (
Collection[int] |int|None, default:None) –When using the manager, this argument specifies which existing ImageTool windows should be replaced with the new data. If the manager is not used, this argument is ignored.
replacecan be set to:None(default): no existing windows are replaced. New windows are created for the new data.A single integer: this can be a valid existing index (replace that window), one greater than the current largest index (create a new window), or a negative index from the end (for example,
-1means the largest existing index).A list of integers: each integer is interpreted as described above. The list length must match the number of windows
datais expected to create.
If this argument is used, the
link,link_colors, andkwargsarguments are ignored, since no new windows are created.execute (
bool|None, default:None) –Whether to execute the Qt event loop and display the window, by default
None. For more information, seeerlab.interactive.utils.setup_qapp().This argument has no effect when the ImageTool window(s) are opened in the manager.
**kwargs – Additional keyword arguments to be passed onto the underlying slicer area. For a full list of supported arguments, see the
erlab.interactive.imagetool.viewer.ImageSlicerAreadocumentation.
- Returns:
ImageToolorlistofImageToolorNone– The created ImageTool window(s).If the window(s) are executed, the function will return
None, since the event loop will prevent the function from returning until the window(s) are closed.If the window(s) are not executed, for example while running in an IPython shell with
%gui qt, the function will not block and return the ImageTool window(s) or a list of ImageTool windows depending on the input data.The function will also return
Noneif the windows are opened in theImageToolManager.- Return type:
Examples
>>> itool(data, cmap="gray", gamma=0.5) >>> itool([data1, data2], link=True)
- erlab.interactive.ktool(data, avec=None, rotate_bz=None, centering=None, *, cmap=None, gamma=None, data_name=None, initial_normal_emission=None, initial_delta=None, execute=None)[source]¶
Interactive momentum conversion tool.
This tool can also be accessed with
DataArray.kspace.interactive(), or from theViewmenu of an ImageTool window.- Parameters:
data (
DataArray) – Data to convert. Currently supports constant energy slices (2D data with alpha and beta dimensions), 2D angle-energy cuts with alpha and eV dimensions and a fixed beta coordinate, and all 3D data that has eV and alpha dimensions, including maps and photon energy dependent data.avec (
array-like, optional) – Real-space lattice vectors as a 2x2 or 3x3 numpy array. If provided, the Brillouin zone boundary overlay will be calculated based on these vectors. If given as a 2x2 array, the third row and column will be assumed to be all 0. You can use utilities fromerlab.latticeto construct these vectors.rotate_bz (
float|None, default:None) – Rotation angle for the Brillouin zone boundary overlay.centering (
Literal['P','A','B','C','F','I','R'] |None, default:None) – Optional centering type to convert the conventional unit cell into a primitive one. Must be one of"P"(primitive),"A","B","C","I"(body-centered),"F"(face-centered), and"R"(rhombohedral).cmap (
str, optional) – Name of the colormap to use.gamma (
float|None, default:None) – Initial gamma value for the colormap.data_name (
str|None, default:None) – Name of the data variable in the generated code. If not provided, the name is automatically determined.initial_normal_emission (
tuple[float,float] |None, default:None) – Optional pair of(alpha, beta)values used once during initialization to seed the normal emission controls and derived angle offsets.initial_delta (
float|None, default:None) – Optional delta value to apply alongsideinitial_normal_emission.
- erlab.interactive.meshtool(data, data_name=None, *, execute=None)[source]¶
Interactive tool for mesh removal.
This tool can also be accessed from the menu in ImageTool.
- Parameters:
data (
DataArray) – Data to extract the mesh from. The data dimensions must include ‘alpha’ and ‘eV’. All other dimensions are averaged over to extract the mesh pattern.data_name (
str|None, default:None) – Name of the data variable in the generated code. If not provided, the name is automatically determined.
- erlab.interactive.ptable(*, hv=None, workfunction=None, max_harmonic=1, notation=None, execute=None)[source]¶
Open the periodic table window.
The periodic table provides an interactive reference for XPS-relevant elemental properties, including x-ray absorption edges, ground-state electron configurations, and photoionization cross sections.
See Periodic table for an overview of the features and user interface.
- Parameters:
hv (
float|None, default:None) – Optional photon energy in eV. When given, the inspector also shows kinetic energies and marks the photon energy on the cross-section plot.workfunction (
float|None, default:None) – Optional work function in eV used for converting an absorption edge to kinetic energy.max_harmonic (
int, default:1) – Highest harmonic order to include when kinetic energies are shown. Harmonics are integer multiples ofhvfrom1throughmax_harmonic.notation (
str|None, default:None) – Initial energy-level notation. When omitted, the most recently used notation is restored. Explicit values should be either"orbital"or"iupac".execute (
bool|None, default:None) – Passed through toerlab.interactive.utils.setup_qapp().
Notes
The periodic table combines several reference datasets.
Element symbols, names, atomic masses, and the absorption-edge values are loaded from
xraydb[Newville et al., 2023], which is based on the compilation described by Elam et al. [2002].Photoionization cross sections shown by
erlab.analysis.xps.get_cross_section()use the bundledyeh_lindau_1985_pics.npzarchive, obtained from the Elettra WebCrossSections service based on of the original Yeh-Lindau subshell tables [Yeh and Lindau, 1985].Ground-state shell configurations for elements \(Z=1\ldots108\) are taken from the NIST Atomic Spectra Database [Kramida et al., 2024].