panalytical: For Panalytical XRD data

Extractors for various exports of Panalytical X-ray diffractograms.

yadg.extractors.panalytical.common module

yadg.extractors.panalytical.common.panalytical_comment(line: str) dict

Processes a comments from the file header into a dictionary.

Parameters:

line – A line containing the comment.

Returns:

A dictionary containing the processed comment.

Return type:

dict

yadg.extractors.panalytical.common.snake_case(s: str) str

Converts Sentence case. and camelCase strings to snake_case.

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

Parameters:

s – The input string to be converted.

Returns:

The corresponding snake_case string.

Return type:

str

yadg.extractors.panalytical.csv module

Handles processing of csv exports of Panalytical XRD files.

Usage

Available since yadg-4.2.

pydantic model dgbowl_schemas.yadg.dataschema_6_0.filetype.Panalytical_csv
Config:
  • extra: str = forbid

Validators:

field filetype: Literal['panalytical.csv'] [Required]

Schema

xarray.DataTree:
  coords:
    uts:            !!float               # Unix timestamp
    angle:          !!float               # 2θ angle
  data_vars:
    intensity:      (uts, angle)          # Measured intensity

Uncertainties

  • angle: string to float conversion.

  • intensity: string to float conversion.

Metadata

With the exception of the comment, the metadata present in the csv file is extracted from the file header without post-processing.

Notes on file structure

These files are split into a [Measurement conditions] and a [Scan points] section. The former stores the metadata and the latter all the datapoints.

Code author: Nicolas Vetsch, Peter Kraus

yadg.extractors.panalytical.csv.process_comments(comments: list[str]) dict
yadg.extractors.panalytical.csv.process_header(header: str) dict

Processes the header section, staring with the [Measurement conditions] line.

Parameters:

header – The header portion as a string.

Returns:

header – A dictionary containing the processed metadata.

Return type:

dict

yadg.extractors.panalytical.csv.process_data(data: str) tuple[list, list]

Processes the data section, starting with the [Scan points] line.

Parameters:

data – The data portion as a string.

Returns:

The values and uncertainties in angle and intensity.

Return type:

avals, adevs, ivals, idevs

yadg.extractors.panalytical.csv.extract_from_path(source: Path, *, encoding: str, timezone: str, **kwargs: dict) DataTree

yadg.extractors.panalytical.xrdml module

Handles processing of Panalytical XRDML files.

Usage

Available since yadg-4.2.

pydantic model dgbowl_schemas.yadg.dataschema_6_0.filetype.Panalytical_xrdml
Config:
  • extra: str = forbid

Validators:

field filetype: Literal['panalytical.xrdml'] [Required]

Schema

xarray.DataTree:
  coords:
    uts:            !!float               # Unix timestamp
    angle:          !!float               # 2θ angle
  data_vars:
    intensity:      (uts, angle)          # Measured intensity

Uncertainties

  • angle: are taken as the step-width of the linearly spaced \(2\theta\) values.

  • intensity: are from count values which seem to be integers.

Metadata

The following metadata is extracted:

  • sample: Metadata information about the sample.

  • wavelength: Measurement wavelength.

  • comment: A free-form description of the experiment.

  • incident_beam_path

  • diffracted_beam_path

  • counting_time

Note

The returned metadata contain only a subset of the available metadata in the XML file. If something important is missing, please contact us!

Notes on file structure

These are xml-formatted files, which we here parse using the xml.etree library into a Python dict.

The angle returned from this parser is based on a linear interpolation of the start and end point of the scan, and is the \(2\theta\). The values of \(\omega\) are discarded.

Code author: Nicolas Vetsch, Peter Kraus

yadg.extractors.panalytical.xrdml.etree_to_dict(e: Element) dict

Recursively converts an ElementTree.Element into a dictionary.

Element attributes are stored into “@”-prefixed attribute keys. Element text is stored into “#text” for all nodes.

From https://stackoverflow.com/a/10076823.

yadg.extractors.panalytical.xrdml.process_values(d: dict | str) dict | str

Recursively parses dicts in the following format:

{"key": {"#text": ..., "@unit": ...}, ...}

into a single string:

{"key": f"{#text} {@unit}", ...}
yadg.extractors.panalytical.xrdml.process_scan(scan: dict) dict

Parses the scan section of the file. Creates the explicit positions based on the number of measured intensities and the start & end position.

yadg.extractors.panalytical.xrdml.process_comment(comment: dict) dict
yadg.extractors.panalytical.xrdml.process_measurement(measurement: dict, timezone: str)

A function that processes each section of the XRD XML file.

yadg.extractors.panalytical.xrdml.extract_from_path(source: Path, *, timezone: str, **kwargs: dict) DataTree

yadg.extractors.panalytical.xy module

Handles processing of xy exports of Panalytical XRD files. When possible, the xrdml or csv files should be used instead.

Usage

Available since yadg-4.2.

pydantic model dgbowl_schemas.yadg.dataschema_6_0.filetype.Panalytical_xy
Config:
  • extra: str = forbid

Validators:

field filetype: Literal['panalytical.xy'] [Required]

Schema

xarray.DataTree:
  coords:
    angle:          !!float               # 2θ angle
  data_vars:
    intensity:      (angle)          # Measured intensity

Uncertainties

  • all values: string to float conversion.

Metadata

No metadata is present in files.

Notes on file structure

These files basically just contain the [Scan points] part of Panalytical csv files. As a consequence, no metadata is recorded, and the format does not have an associated timestamp.

Code author: Nicolas Vetsch, Peter Kraus

yadg.extractors.panalytical.xy.extract_from_path(source: Path, *, encoding: str, **kwargs: dict) DataTree