Skip to content

Commit 6e68d2c

Browse files
authored
2640 bug lo prostar not processing correctly (IMAP-Science-Operations-Center#2642)
* Fix testing for incorrect descriptor l1b star * Hacky fix for L1A coordinate issue
1 parent 1da47b5 commit 6e68d2c

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

imap_processing/lo/l1b/lo_l1b.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,27 +213,30 @@ def lo_l1b(
213213
datasets_to_return.append(badtimes_ds)
214214

215215
# if the dependencies are used to create Annotated Direct Events
216-
if descriptor == "de":
216+
elif descriptor == "de":
217217
logger.info("\nProcessing IMAP-Lo L1B Direct Events...")
218218
ds = l1b_de(sci_dependencies, anc_dependencies, attr_mgr_l1b, attr_mgr_l1a)
219219
datasets_to_return.append(ds)
220220

221221
# If dependencies are used to create Histogram Rates
222-
if descriptor == "all-rates":
222+
elif descriptor == "all-rates":
223223
logger.info("\nProcessing IMAP-Lo L1B Hist and Monitor Rates...")
224224
ds = l1b_allrates(sci_dependencies, anc_dependencies, attr_mgr_l1b)
225225
datasets_to_return.extend(ds)
226226

227-
if descriptor == "derates":
227+
elif descriptor == "derates":
228228
logger.info("\nProcessing IMAP-Lo L1B DE Rates...")
229229
ds = calculate_de_rates(sci_dependencies, anc_dependencies, attr_mgr_l1b)
230230
datasets_to_return.append(ds)
231231

232-
if descriptor == "star":
232+
elif descriptor == "prostar":
233233
logger.info("\nProcessing IMAP-Lo L1B Star Sensor Profile...")
234234
ds = l1b_star(sci_dependencies, attr_mgr_l1b)
235235
datasets_to_return.append(ds)
236236

237+
else:
238+
logger.warning(f"Unexpected descriptor: {descriptor!r}")
239+
237240
return datasets_to_return
238241

239242

@@ -2354,6 +2357,14 @@ def l1b_star(
23542357
l1b_nhk = sci_dependencies["imap_lo_l1b_nhk"]
23552358
spin_data = sci_dependencies["imap_lo_l1a_spin"]
23562359

2360+
# L1A files have a coordinate of shcoarse due to DEPEND_0 issue.
2361+
# This is a temporary fix for that.
2362+
# TODO: Fix L1A shcoarse DEPEND_0 and then remove this
2363+
if "shcoarse" in l1a_star.dims:
2364+
var_shcoarse = xr.DataArray(l1a_star["shcoarse"].values, dims=("epoch",))
2365+
l1a_star = l1a_star.drop_vars("shcoarse")
2366+
l1a_star["shcoarse"] = var_shcoarse
2367+
23572368
# Get sampling cadence from NHK
23582369
sampling_cadence = get_sampling_cadence_from_nhk(l1b_nhk)
23592370

imap_processing/tests/lo/test_lo_l1b.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,13 @@ def test_l1b_badtimes_skipped_if_empty():
927927
assert len(datasets) == 0
928928

929929

930+
def test_lo_l1b_unexpected_descriptor(caplog):
931+
"""Test that an unexpected descriptor logs a warning and returns empty list."""
932+
datasets = lo_l1b({}, [], descriptor="unknown")
933+
assert len(datasets) == 0
934+
assert "Unexpected descriptor: 'unknown'" in caplog.text
935+
936+
930937
def test_resweep_histogram_success(l1b_histrates, anc_dependencies):
931938
# Arrange
932939
epoch_date = et_to_ttj2000ns(

0 commit comments

Comments
 (0)