Skip to content

Commit 496caec

Browse files
authored
MNT: Add optional odNNN in SPICE ephemeris file names (#282)
The MOC has been delivering od123 in the filename to better track their OD solutions with the ephemeris provided. We can handle this by adding in an optional group to match against that.
1 parent 2d42ce3 commit 496caec

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

imap_data_access/file_validation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ class SPICEFilePath(ImapFilePath):
565565
spacecraft_ephemeris_file_pattern = (
566566
r"(imap)_"
567567
r"(?P<type>[a-zA-Z0-9\-]+)_"
568+
r"(?:od\d{3}_)?" # Optionally match and ignore odNNN
568569
r"(?P<start_date>[\d]{8})_"
569570
r"(?P<end_date>[\d]{8})"
570571
r"(?:|_v(?P<version>[\d]*))\."

tests/test_file_validation.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,20 @@ def test_spice_file_path():
267267
] / Path("imap/spice/spk/L1_de431.bsp")
268268
assert lagrange_point_file.spice_metadata["type"] == "lagrange_point"
269269

270+
# Ephemeris with "od" in the filename
271+
ephem_file = SPICEFilePath("imap_pred_od004_20251002_20251113_v01.bsp")
272+
assert ephem_file.construct_path() == imap_data_access.config["DATA_DIR"] / Path(
273+
"imap/spice/spk/imap_pred_od004_20251002_20251113_v01.bsp"
274+
)
275+
assert ephem_file.spice_metadata["type"] == "ephemeris_predicted"
276+
277+
# Ephemeris without "od" in the filename
278+
ephem_file = SPICEFilePath("imap_pred_20251002_20251113_v01.bsp")
279+
assert ephem_file.construct_path() == imap_data_access.config["DATA_DIR"] / Path(
280+
"imap/spice/spk/imap_pred_20251002_20251113_v01.bsp"
281+
)
282+
assert ephem_file.spice_metadata["type"] == "ephemeris_predicted"
283+
270284

271285
def test_spice_extract_dps_pointing_parts():
272286
"""Test the new DPS pointing kernel filename parsing."""

0 commit comments

Comments
 (0)