extract_quantity_from_filepath#
- extract_quantity_from_filepath(ifile, default=None)[source]#
Extract the MAS/POT3D quantity name from a filename stem.
Matches the longest recognized quantity prefix at the start of the stem (before any digit or end-of-string). The match is case-insensitive.
- Parameters:
- Returns:
Examples
>>> from pathlib import Path >>> from psi_io.mhd_io import extract_quantity_from_filepath >>> extract_quantity_from_filepath(Path('br001001.h5')) 'br' >>> extract_quantity_from_filepath(Path('heat001.h5')) 'heat' >>> extract_quantity_from_filepath(Path('unknown.h5')) is None True >>> extract_quantity_from_filepath(Path('unknown.h5'), default='br') 'br'