Skip to content

Commit 9bea275

Browse files
authored
MNT: Allow for repoint or repoint.csv filenames (#269)
The MOC has removed the .csv suffix from the spin and repoint files to align with other items. Add handling for the new non-csv suffix, but leave the old handling in-tact still so we can use either version.
1 parent f1d7917 commit 9bea275

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

imap_data_access/file_validation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,9 @@ def is_valid_cr(input_cr: str) -> bool:
459459
"ah.bc": "attitude_history",
460460
"ap.bc": "attitude_predict",
461461
"spin.csv": "spin",
462+
"spin": "spin",
462463
"repoint.csv": "repoint",
464+
"repoint": "repoint",
463465
"recon": "ephemeris_reconstructed",
464466
"nom": "ephemeris_nominal",
465467
"pred": "ephemeris_predicted",
@@ -534,7 +536,7 @@ class SPICEFilePath(ImapFilePath):
534536
r"(?P<start_year_doy>[\d]{4}_[\d]{3})_"
535537
r"(?P<end_year_doy>[\d]{4}_[\d]{3})_"
536538
r"(?P<version>[\d]+)\."
537-
r"(?P<type>ah.bc|ap.bc|spin.csv)"
539+
r"(?P<type>ah.bc|ap.bc|spin.csv|spin)"
538540
)
539541
# Covers:
540542
# DPS kernel (type: ah.bc)
@@ -546,12 +548,12 @@ class SPICEFilePath(ImapFilePath):
546548
r"(?P<extension>ah\.bc)"
547549
)
548550
# Covers:
549-
# Repoint Files (type: repoint.csv)
551+
# Repoint Files (type: repoint.csv, or repoint)
550552
repoint_file_pattern = (
551553
r"(imap)_"
552554
r"(?P<end_year_doy>[\d]{4}_[\d]{3})_"
553555
r"(?P<version>[\d]+)\."
554-
r"(?P<type>repoint.csv)"
556+
r"(?P<type>repoint.csv|repoint)"
555557
)
556558
# Covers:
557559
# Reconstructed (type: recon)

tests/test_file_validation.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ def test_spice_file_path():
219219
"DATA_DIR"
220220
] / Path("imap/spice/repoint/imap_2025_122_01.repoint.csv")
221221

222+
repoint_file_path = SPICEFilePath("imap_2025_122_01.repoint")
223+
assert repoint_file_path.construct_path() == imap_data_access.config[
224+
"DATA_DIR"
225+
] / Path("imap/spice/repoint/imap_2025_122_01.repoint")
226+
222227
metakernel_file = SPICEFilePath("imap_sdc_metakernel_1000_v000.tm")
223228
assert metakernel_file.construct_path() == imap_data_access.config[
224229
"DATA_DIR"
@@ -279,9 +284,10 @@ def test_spice_extract_dps_pointing_parts():
279284
print(file_path.spice_metadata)
280285

281286

282-
def test_spice_extract_spin_parts():
287+
@pytest.mark.parametrize("suffix", ["spin", "spin.csv"])
288+
def test_spice_extract_spin_parts(suffix):
283289
# Test spin
284-
file_path = SPICEFilePath("imap_2025_122_2025_122_01.spin.csv")
290+
file_path = SPICEFilePath(f"imap_2025_122_2025_122_01.{suffix}")
285291
assert file_path.spice_metadata["version"] == "01"
286292
assert file_path.spice_metadata["type"] == "spin"
287293
assert file_path.spice_metadata["start_date"] == datetime.strptime(

0 commit comments

Comments
 (0)