helper module

Define some common helpers for loading data.

read_header(filepath, sep='\\t', comment='#')

Get the line describing columns content.

It is the first line of the files that does not start with a comment character. Header of first column can be anything. Header of following columns must hold incidence angle and be convertable to a float.

Parameters:
  • filepath (str | Path) – Path to file holding data under study.

  • sep (str, default: '\\t') – Column delimiter.

  • comment (str, default: '#') – Comment character.

Return type:

tuple[list[str], int]

Returns:

  • list[str] – Columns descriptors. First column is Energy [eV]. Following is/are theta [deg], where theta is the value of the incidence angle.

  • int – Number of comment lines before the header.

_format_header(header)

Generate default header.

Return type:

list[str]

read_comments(filepath, comment='#')

Read the comments in the file.

Parameters:
  • filepath (str | Path) – Path to file holding data under study.

  • comment (str, default: '#') – Comment character.

Returns:

Comments, line by line. Without the comment character.

Return type:

list[str]