parse_psi_filename_schema

parse_psi_filename_schema#

parse_psi_filename_schema(ifile)[source]#

Parse a PSI HDF filename that follows the strict <quantity><sequence> schema.

The filename stem must consist of exactly one recognized MAS/POT3D quantity name followed immediately by a 3- or 6-digit sequence number, with no other characters. The match is case-insensitive.

Parameters:
ifilePath

File path to parse. The stem is matched against FILEPATH_SCHEMA.

Returns:
quantitystr

Lower-case quantity name (e.g. 'br').

sequenceint

Integer sequence number (e.g. 1001).

Raises:
ValueError

If the filename stem does not match the expected schema.

Examples

>>> from pathlib import Path
>>> from psi_io._models import parse_psi_filename_schema
>>> parse_psi_filename_schema(Path('br001001.h5'))
('br', 1001)
>>> parse_psi_filename_schema(Path('heat001.hdf'))
('heat', 1)
>>> parse_psi_filename_schema(Path('notvalid.h5'))
Traceback (most recent call last):
    ...
ValueError: Filename 'notvalid.h5' does not match expected MAS filename schema: ...