Skip to content

Commit 256b9b3

Browse files
committed
NPI-4711 add simple extractor function for general properties of IGS long filenames
1 parent d0c3642 commit 256b9b3

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

gnssanalysis/filenames.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
# https://files.igs.org/pub/resource/guidelines/Guidelines_for_Long_Product_Filenames_in_the_IGS_v2.1.pdf
2727
_RE_IGS_LONG_FILENAME = re.compile(
2828
r"""\A # Assert beginning of string
29-
(?P<analysis_center>\w{3})
30-
(?P<version>\w)
29+
(?P<analysis_center>\w{3}) # E.g. 'IGS'
30+
(?P<version>\w) # Version / 'solution identifier'. Typically '0'
3131
(?P<project>\w{3}) # Campaign / project
3232
(?P<solution_type>\w{3}) # Solution type identifier
3333
_
@@ -798,6 +798,25 @@ def determine_sp3_name_props(
798798
return name_props
799799

800800

801+
def simple_props_from_long_filename(filename: str) -> dict[str, Any]:
802+
# Simpler version of determine_properties_from_filename(), which does less parsing / conversion / assumption
803+
# making. Just extracts key fields from IGS long filename and presents them verbatim.
804+
805+
match_long = _RE_IGS_LONG_FILENAME.fullmatch(filename)
806+
if match_long is None:
807+
raise ValueError(f"Filename failed to parse as IGS long format: '{filename}'")
808+
return {
809+
"analysis_center": match_long["analysis_center"].upper(),
810+
"content_type": match_long["content_type"].upper(),
811+
"format_type": match_long["file_format"].upper(),
812+
"solution_type": match_long["solution_type"],
813+
"sampling_rate": match_long["sampling"],
814+
"version": match_long["version"],
815+
"project": match_long["project"], # Aka 'campaign'
816+
# Extra fields will be added depending on standard vs Long Term Product
817+
}
818+
819+
801820
def determine_properties_from_filename(
802821
filename: str,
803822
expect_long_filenames: bool = False,

0 commit comments

Comments
 (0)