IDEX l1b handle empty event msg datasets#2908
IDEX l1b handle empty event msg datasets#2908lacoak21 merged 2 commits intoIMAP-Science-Operations-Center:devfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates IDEX L1B MSG processing to avoid producing an output dataset when the input contains no science or pulser events, preventing creation of an empty MSG product.
Changes:
- Updated
idex_l1b()andidex_l1b_msg()return types to allowNonewhen no MSG events of interest exist. - Added a post-filter check in
idex_l1b_msg()to log a warning and returnNoneif the filtered dataset has zeroepochentries.
Comments suppressed due to low confidence (1)
imap_processing/idex/idex_l1b.py:159
- The
idex_l1b_msgdocstring still states it returns anxarray.Dataset, but the function can now returnNonewhen no events are found. Please update the Returns section to reflect the optional return so callers know they must handle the no-product case.
def idex_l1b_msg(l1a_dataset: xr.Dataset) -> xr.Dataset | None:
"""
Will process IDEX l1a msg data.
Parameters
----------
l1a_dataset : xarray.Dataset
IDEX L1a dataset to process.
Returns
-------
l1b_dataset : xarray.Dataset
The``xarray`` dataset containing the msg housekeeping data and
supporting metadata.
"""
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -142,7 +142,7 @@ def idex_l1b(l1a_dataset: xr.Dataset, descriptor: str) -> xr.Dataset: | |||
| raise ValueError(f"Unsupported descriptor: {descriptor}") | |||
There was a problem hiding this comment.
idex_l1b now advertises xr.Dataset | None, but downstream call sites (e.g., CLI workflow) expect a concrete xr.Dataset and will attempt to write/upload it. Returning None will propagate into post_processing and be treated as a Path (since it’s not an xr.Dataset), causing failures later. Either keep idex_l1b returning an xr.Dataset (and handle the empty-epoch case differently), or update the processing pipeline to filter out None (e.g., return [] from the instrument processing step when idex_l1b returns None). Also update the Returns section of this docstring to document the None case if it remains optional.
| if len(l1b_dataset["epoch"]) == 0: | ||
| logger.warning( | ||
| "No science or pulser events found. No l1b dataset will be created." | ||
| ) | ||
| return None |
There was a problem hiding this comment.
Returning None here will break the standard processing pipeline: ProcessInstrument.post_processing() iterates over returned items and treats non-xr.Dataset values as already-written Paths, so None will be appended and later passed to upload logic. Prefer having the caller return an empty product list when there’s nothing to write (or ensure all callers explicitly filter out None before post-processing).
Change Summary
Overview
If there are no events for l1b msg products, skip writing out a dataset.
File changes
imap_processing/idex/idex_l1b.py
Testing
Tested this locally.