This module provides a backward compatibility layer with the legacy specfile wrapper.
If you are starting a new project, please consider using silx.io.specfile instead of this module.
If you want to use this module for an existing project that used the old wrapper through PyMca, you can try replacing:
from PyMca5.PyMcaIO import specfilewrapper
with:
from silx.io import specfilewrapper
There might still be differences between this module and the old wrapper, due to differences in the underlying implementation. Any of these differences that break your code should be reported on https://github.com/silx-kit/silx/issues
The documentation mentions only the methods and attributes that are different from the ones in silx.io.specfile.SpecFile and silx.io.specfile.Scan. You should refer to the documentation of these base classes for more information.
Bases: specfile.SpecFile
This class is a subclass of silx.io.specfile.SpecFile.
It redefines following methods:
- __getitem__(): returns a scandata object instead of a silx.io.specfile.Scan object
- list(): returns a string representation of a list instead of a list of integers
Following methods are added:
Get scan by 0-based index
Parameters: | key (int) – 0-based scan index |
---|---|
Returns: | Scan |
Return type: | scandata |
Return a string representation of a list of scan numbers.
The scans numbers are listed in the order in which they appear in the file. Continuous ranges of scan numbers are represented as first:last.
For instance, let’s assume our specfile contains following scans: 1, 2, 3, 4, 5, 684, 685, 687, 688, 689, 700, 688, 688. This method will then return:
"1:5,684:685,687:689,700,688,688"
Get scan by n.m key
Parameters: | key (str) – "s.o" (scan number, scan order) |
---|---|
Returns: | Scan |
Return type: | scandata |
Return the number of scans in the SpecFile
This is an alias for __len__(), for compatibility with the old specfile wrapper API.
This is an alias for motor_names(), for compatibility with the old specfile wrapper API.
Bases: specfile.Scan
This class is a subclass of silx.io.specfile.Scan.
It redefines following methods/attributes:
- data() becomes a method returning an array, instead of just an array
- mca(): becomes a method returning an array, instead of a silx.io.specfile.Scan object
- header(): becomes a method returning a list of scan header lines (or a list of a single header line, if a key is specified), instead of just a list of all header lines
Following methods are added:
Return the data in this scan as a 2D numpy array.
The first index corresponds to the columns/detectors in the original file, and the second index is the row index from the original file. Indices are 0-based.
For instance, this is how you access the 18th data sample for the 3rd detector (assuming sc is your scan object):
>>> scdata = sc.data()
>>> data_sample = scdata[2, 17]
Return a data column (all data for one detector)
Parameters: | col – column number (1-based index) |
---|
Return a data line (one sample for all detectors)
Parameters: | line – line number (1-based index) |
---|
Return a list of scan header lines if no key is specified. If a valid key is specified, return a list of a single header line.
Parameters: | key – Header key (e.g. S, N, L, @CALIB…) If key is an empty string, return complete list of scan header lines. If key does not match any header line, return empty list. |
---|---|
Returns: | List of scan header lines |
Return type: | list[str] |