Skip to content

isimip_utils.files

Functions to find files for specific datasets.

find_files(file_iter, pattern='_(?P<start_year>\\d{4})_(?P<end_year>\\d{4})?\\.nc\\d*$')

Find files for a given (dataset) path, matching a regex pattern for start and end year.

Parameters:

Name Type Description Default
file_iter Iterable[Path]

Iterator over file paths to search through.

required
pattern str

Regular expression for start and end year matching.

'_(?P<start_year>\\d{4})_(?P<end_year>\\d{4})?\\.nc\\d*$'

Returns:

Type Description
list[tuple]

Tuple containing (a) the List of tuples containing the path and the start and end years for each file,

int

(b) the lowest start year, and (c) the highest end year.