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,