yadg.parsers.xpstrace package

List of supported file formats:

Submodules

yadg.parsers.xpstrace.main module

yadg.parsers.xpstrace.main.process(fn, encoding='utf-8', timezone='UTC', tracetype='phi.spe')

Unified x-ray photoelectron spectroscopy parser.

This parser processes XPS scans in signal(energy) format.

Parameters
  • fn (str) – The file containing the trace(s) to parse.

  • encoding (str) – Encoding of fn, by default “utf-8”.

  • timezone (str) – A string description of the timezone. Default is “UTC”.

  • tracetype (str) –

    Determines the output file format. Currently supported formats can be found here.

    The default is "phi.spe".

Returns

(data, metadata, fulldate) – Tuple containing the timesteps, metadata, and the full date tag. Multipak .spe files seemingly have no timestamp.

Return type

tuple[list, dict, bool]

yadg.parsers.xpstrace.phispe module

Processing of ULVAC PHI Multipak XPS traces.

The [IGOR .spe import script by jjweimer](https://www.wavemetrics.com/project/phispefileloader) was pretty helpful for writing this parser.

File Structure of .spe Files

These binary files actually contain an ASCII file header, delimited by “SOFH “ and “EOFH “.

The binding energies corresponding to the datapoints in the later part of the file can be found from the “SpectralRegDef” entries in this header. Each of these entries look something like:

2 2 F1s 9 161 -0.1250 695.0 675.0 695.0 680.0    0.160000 29.35 AREA

This maps as follows:

2           trace_number
2           trace_number (again?)
F1s         name
9           atomic_number
161         num_datapoints
-0.1250     step
695.0       start
675.0       stop
695.0       ?
680.0       ?
0.160000    dwell_time
29.35       e_pass
AREA        description (?)

After the file header, the binary part starts with a short data header (offsets given from start of data header):

0x0000 group                # Data group number.
0x0004 num_traces           # Number of traces in file
0x0008 trace_header_size    # Combined lengths of all trace headers.
0x000c data_header_size     # Length of this data header.

After this follow num_traces trace headers that are each structured something like this:

0x0000 trace_number          # Number of the trace.
0x0004 bool_01               # ???
0x0008 bool_02               # ???
0x000c trace_number_again    # Number of the trace. Again?
0x0010 bool_03               # ???
0x0014 num_datapoints        # Number of datapoints in trace.
0x0018 bool_04               # ???
0x001c bool_05               # ???
0x0020 string_01             # ???
0x0024 string_02             # ???
0x0028 string_03             # ???
0x002c int_02                # ???
0x0030 string_04             # ???
0x0034 string_05             # ???
0x0038 y_unit                # The unit of the datapoints.
0x003c int_05                # ???
0x0040 int_06                # ???
0x0044 int_07                # ???
0x0048 data_dtype            # Data type for datapoints (`f4`/`f8`).
0x004c num_data_bytes        # Unsure about this one.
0x0050 num_datapoints_tot    # This one as well.
0x0054 int_10                # ???
0x0058 int_11                # ???
0x005c end_of_data           # Byte offset of the end-of-data.

After the trace headers follow the datapoints. After the number of datapoints there is a single 32bit float with the trace’s dwelling time again.

Structure of Parsed Data

- fn   !!str
- uts  !!float
- raw:
    "{{ trace_number }}":
      {n: [!!float, ...], s: [!!float, ...], u: !!str}
yadg.parsers.xpstrace.phispe.camel_to_snake(s)

Converts CamelCase strings to snake_case.

# From https://stackoverflow.com/a/1176023

Parameters

s (str) – The CamelCase input string.

Returns

The snake_case equivalent of s.

Return type

str

yadg.parsers.xpstrace.phispe.process(fn, encoding='utf-8', timezone='UTC')

Processes ULVAC-PHI Multipak XPS data.

Parameters
  • fn (str) – The file containing the data to parse.

  • encoding (str) – Encoding of fn, by default “utf-8”.

  • timezone (str) – A string description of the timezone. Default is “UTC”.

Returns

(data, metadata, fulldate) – Tuple containing the timesteps, metadata, and the full date tag. Multipak .spe files seemingly have no timestamp.

Return type

tuple[list, dict, bool]