1. Core functions (specsscan.core)

Core class functions for the specsscan package

This is the SpecsScan core class

class specsscan.core.SpecsScan(metadata={}, config={}, **kwds)

Bases: object

SpecsAnalyzer class for loading scans and data from SPECS Phoibos electron analyzers, generated with the ARPESControl software at Fritz Haber Institute, Berlin, and EPFL, Lausanne.

Parameters:
  • metadata (dict, optional) – Metadata dictionary. Defaults to {}.

  • config (Union[dict, str], optional) – Metadata dictionary or file path. Defaults to {}.

  • **kwds – Keyword arguments passed to parse_config.

property config

Get config

property result

Get result xarray

load_scan(scan, path='', iterations=None, metadata={}, collect_metadata=False, **kwds)

Load scan with given scan number. When iterations is given, average is performed over the iterations over all delays.

Parameters:
  • scan (int) – The scan number of interest

  • path (str | Path, optional) – Either a string of the path to the folder containing the scan or a Path object. Defaults to “”.

  • iterations (np.ndarray | slice | Sequence[int] | Sequence[slice], optional) – A 1-D array of the number of iterations over which the images are to be averaged. The array can be a list, numpy array or a Tuple consisting of slice objects and integers. For ex., np.s_[1:10, 15, -1] would be a valid input for iterations. Defaults to None.

  • metadata (dict, optional) – Metadata dictionary with additional metadata for the scan. Defaults to empty dictionary.

  • collect_metadata (bool, optional) – Option to collect further metadata e.g. from EPICS archiver needed for NeXus conversion. Defaults to False.

  • **kwds – Additional arguments passed to SpecsAnalyzer.convert().

Returns:

xarray DataArray object with kinetic energy, angle/position and optionally a third scanned axis (for ex., delay, temperature) as coordinates.

Return type:

xr.DataArray

crop_tool(scan=None, path='', **kwds)

Cropping tool interface to crop_tool method of the SpecsAnalyzer class.

Parameters:
  • scan (int, optional) – Scan number to load data from. Defaults to None.

  • path (Path | str, optional) – Path in which to search the scan. Defaults to config[‘data_path’].

Raises:

ValueError – Raised if no image loaded, and scan not provided

fft_tool(scan=None, path='', **kwds)

FFT tool to play around with the peak parameters in the Fourier plane. Built to filter out the meshgrid appearing in the raw data images. The optimized parameters are stored in the class config dict under fft_filter_peaks.

Parameters:
  • scan (int, optional) – Scan number to load. Defaults to the previously loaded scan.

  • path (Path | str) – Path from where to load the data. Defaults to config value.

  • **kwds

    Keyword arguments passed to SpecsAnalyzer.fft_tool():

    • apply: Option to directly apply the settings.

    • amplitude: Normalized amplitude of subtraction

    • pos_x: horizontal spatial frequency of th mesh

    • pos_y: vertical spatial frequency of the mesh

    • sigma_x: horizontal frequency width

    • sigma_y: vertical frequency width

check_scan(scan, delays, path='', metadata={}, collect_metadata=False, **kwds)

Function to explore a given 3-D scan as a function of iterations for a given range of delays.

Parameters:
  • scan (int) – The scan number of interest

  • delays (Sequence[int] | int) – A single delay index or a sequence of delay indices to be averaged over.

  • path (str | Path, optional) – Either a string of the path to the folder containing the scan or a Path object. Defaults to config[‘data_path].

  • metadata (dict, optional) – Metadata dictionary with additional metadata for the scan. Defaults to empty dictionary.

  • collect_metadata (bool, optional) – Option to collect further metadata e.g. from EPICS archiver needed for NeXus conversion. Defaults to False.

  • **kwds – Keyword arguments passed to SpecsAnalyzer.convert().

Raises:

ValueError – Raised if a single image scan was selected

Returns:

3-D xarray of dimensions (Ekin, Angle, Iterations)

Return type:

xr.DataArray

save(faddr, **kwds)

Saves the loaded data to the provided path and filename.

Parameters:
  • faddr (str) –

    Path and name of the file to write. Its extension determines the file type to write. Valid file types are:

    • .tiff”, “.tif”: Saves a TIFF stack.

    • .h5”, “.hdf5”: Saves an HDF5 file.

    • .nxs”, “.nexus”: Saves a NeXus file.

  • **kwds

    Keyword arguments, which are passed to the writer functions: For TIFF writing:

    • alias_dict: Dictionary of dimension aliases to use.

    For HDF5 writing:

    • mode: hdf5 read/write mode. Defaults to “w”.

    For NeXus:

    • reader: Name of the pynxtools reader to use. Defaults to config[“nexus”][“reader”]

    • definition: NeXus application definition to use for saving. Must be supported by the used reader. Defaults to config[“nexus”][“definition”]

    • input_files: A list of input files to pass to the reader. Defaults to config[“nexus”][“input_files”]

    • eln_data: Path to a json file with data from an electronic lab notebook. Its is appended to the input_files.

process_sweep_scan(raw_data, kinetic_energy, pass_energy, lens_mode, work_function, **kwds)

Process sweep scan by interpolating each frame onto a common grid given by the voltage step, and summing over all frames.

Parameters:
  • raw_data (list[np.ndarray]) – List of raw data images

  • kinetic_energy (np.ndarray) – Array of analyzer set kinetic energy values

  • pass_energy (float) – set analyzer pass energy

  • lens_mode (str) – analyzer lens mode, check calib2d for a list of modes CamelCase naming convention e.g. “WideAngleMode”

  • work_function (float) – set analyzer work function

Returns:

Converted sweep scan

Return type:

xr.DataArray