erlab.io.plugins.merlin¶
Data loader for beamline 4.0.3 at ALS.
Functions
|
Load a beamline control system scan. |
Classes
- class erlab.io.plugins.merlin.MERLINLoader[source]¶
Bases:
LoaderBase- name: str = 'merlin'¶
Name of the loader. Using a unique and descriptive name is recommended. For easy access, it is recommended to use a name that passes
str.isidentifier().Notes
Changing the name of a loader is not recommended as it may break existing code. Pick a simple, descriptive name that is unlikely to change.
Loaders with the name prefixed with an underscore are not registered.
- description: str = 'ALS Beamline 4.0.3 MERLIN'¶
A short description of the loader shown to users.
Added in version 3.3.0.
-
extensions:
ClassVar[set[str]] = {'.ibw', '.pxt'}¶ File extensions supported by the loader in lowercase with the leading dot.
An
UnsupportedFileErroris raised if a file with an unsupported extension is passed to the loader. IfNone, the loader will attempt to load any file passed to it.If the loader supports directories, the extension should be an empty string.
Added in version 3.5.1.
- aliases: Iterable[str] | None = ('ALS_BL4', 'als_bl4', 'BL403', 'bl403')¶
Alternative names for the loader.
Deprecated since version 3.3.0: Accessing loaders with aliases is deprecated and will be removed in a future version. Use the loader name instead.
-
name_map:
ClassVar[dict] = {'alpha': 'deg', 'beta': ['Polar', 'Polar Compens'], 'delta': 'Azimuth', 'hv': 'BL Energy', 'mesh_current': 'Mesh Current', 'polarization': 'EPU POL', 'sample_temp': 'Temperature Sensor B', 'x': 'Sample X', 'xi': 'Tilt', 'y': 'Sample Y (Vert)', 'z': 'Sample Z'}¶ Dictionary that maps new coordinate or attribute names to original coordinate or attribute names. If there are multiple possible names for a single attribute, the value can be passed as an iterable.
Note
Non-dimension coordinates in the resulting data will try to follow the order of the keys in this mapping.
Original coordinate names included in this mapping will be replaced by the new names. However, original attribute names will be duplicated with the new names so that both the original and new names are present in the data after loading. This is to keep track of the original names for reference.
- coordinate_attrs: tuple[str, ...] = ('beta', 'delta', 'xi', 'hv', 'x', 'y', 'z', 'polarization', 'mesh_current', 'sample_temp')¶
Attribute names (after renaming) that should be treated as coordinates.
Put any attributes that should be propagated when concatenating data here.
Notes
If a listed attribute is not found, it is silently skipped.
The attributes given here, both before and after renaming, are removed from the attributes to avoid conflicting values.
If an existing coordinate with the same name is already present, the existing coordinate takes precedence and the attribute is silently dropped.
See also
-
additional_attrs:
ClassVar[dict] = {'configuration': 1}¶ Additional attributes to be added to the data after loading.
If a callable is provided, it will be called with the data as the only argument.
Notes
The attributes are added after renaming with
process_keys, so keys will appear in the data as provided.If an attribute with the same name is already present in the data, it is skipped unless the key is listed in
overridden_attrs.
-
formatters:
ClassVar[dict[str,Callable]] = {'Entrance Slit': <built-in function round>, 'Exit Slit': <built-in function round>, 'Lens Mode': <function MERLINLoader.<lambda>>, 'Slit Plate': <built-in function round>, 'polarization': <function _format_polarization>}¶ Optional mapping from attr or coord names (after renaming) to custom formatters.
The formatters are callables that takes the attribute value and returns a value that can be converted to a string via
value_to_string. The resulting string representations are used for human readable display in the summary table and the information accessor.The values returned by the formatters will be further formatted by
value_to_stringbefore being displayed.If the key is a coordinate, the function will automatically be vectorized over every value.
Note
The formatters are only used for display purposes and do not affect the stored data.
See also
get_formatted_attr_or_coord()The method that uses this mapping to provide human-readable values.
-
summary_attrs:
ClassVar[dict[str,str|Callable[[DataArray],Any]]] = {'analyzer slit': 'Slit Plate', 'azi': 'delta', 'entrance slit': 'Entrance Slit', 'exit slit': 'Exit Slit', 'hv': 'hv', 'lens mode': 'Lens Mode', 'mode': 'Acquisition Mode', 'pass energy': 'Pass Energy', 'pol': 'polarization', 'polar': 'beta', 'temperature': 'sample_temp', 'tilt': 'xi', 'time': <function _parse_time>, 'type': <function _determine_kind>, 'x': 'x', 'y': 'y', 'z': 'z'}¶
- summary_sort: str | None = 'time'¶
Optional default column to sort the summary table by.
If
None, the summary table is sorted in the order of the files returned byfiles_for_summary.
- always_single: bool = False¶
Setting this to
Truedisables implicit loading of multiple files for a single scan. This is useful for setups where each scan is always stored in a single file.
- property file_dialog_methods¶
- erlab.io.plugins.merlin.load_bcs(path)[source]¶
Load a beamline control system scan.
- Parameters:
path (
str|PathLike) – Path to the BCS text file. Payload files referenced by the data table are resolved relative to the text file and, for image payloads, when needed from a sibling directory named"<text file stem> Images".- Returns:
xarray.DataArray,xarray.Dataset, orxarray.DataTree– A data array containing the compiled payload stack for BCS files with one payload column. If a file contains multiple payload columns, each payload stream is loaded into a separate child node of a data tree. Legacy tabular BCS scans without payload columns are returned as a dataset with one data variable per measured channel.- Return type: