From 256b9b3203146930a856d4591d56394a073c2c8d Mon Sep 17 00:00:00 2001 From: Nathan <95725385+treefern@users.noreply.github.com> Date: Mon, 29 Jun 2026 10:05:41 +0000 Subject: [PATCH] NPI-4711 add simple extractor function for general properties of IGS long filenames --- gnssanalysis/filenames.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/gnssanalysis/filenames.py b/gnssanalysis/filenames.py index 148f791..fe30f4b 100644 --- a/gnssanalysis/filenames.py +++ b/gnssanalysis/filenames.py @@ -26,8 +26,8 @@ # https://files.igs.org/pub/resource/guidelines/Guidelines_for_Long_Product_Filenames_in_the_IGS_v2.1.pdf _RE_IGS_LONG_FILENAME = re.compile( r"""\A # Assert beginning of string - (?P\w{3}) - (?P\w) + (?P\w{3}) # E.g. 'IGS' + (?P\w) # Version / 'solution identifier'. Typically '0' (?P\w{3}) # Campaign / project (?P\w{3}) # Solution type identifier _ @@ -798,6 +798,25 @@ def determine_sp3_name_props( return name_props +def simple_props_from_long_filename(filename: str) -> dict[str, Any]: + # Simpler version of determine_properties_from_filename(), which does less parsing / conversion / assumption + # making. Just extracts key fields from IGS long filename and presents them verbatim. + + match_long = _RE_IGS_LONG_FILENAME.fullmatch(filename) + if match_long is None: + raise ValueError(f"Filename failed to parse as IGS long format: '{filename}'") + return { + "analysis_center": match_long["analysis_center"].upper(), + "content_type": match_long["content_type"].upper(), + "format_type": match_long["file_format"].upper(), + "solution_type": match_long["solution_type"], + "sampling_rate": match_long["sampling"], + "version": match_long["version"], + "project": match_long["project"], # Aka 'campaign' + # Extra fields will be added depending on standard vs Long Term Product + } + + def determine_properties_from_filename( filename: str, expect_long_filenames: bool = False,