Skip to content

IDEX l1b handle empty event msg datasets#2908

Merged
lacoak21 merged 2 commits intoIMAP-Science-Operations-Center:devfrom
lacoak21:idex_l1b_skip_empty_dataset
Apr 2, 2026
Merged

IDEX l1b handle empty event msg datasets#2908
lacoak21 merged 2 commits intoIMAP-Science-Operations-Center:devfrom
lacoak21:idex_l1b_skip_empty_dataset

Conversation

@lacoak21
Copy link
Copy Markdown
Contributor

@lacoak21 lacoak21 commented Apr 2, 2026

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

  • return None if there are no events of interest.

Testing

Tested this locally.

@lacoak21 lacoak21 added this to the April 2026 milestone Apr 2, 2026
@lacoak21 lacoak21 requested review from Copilot and laspsandoval April 2, 2026 19:29
@lacoak21 lacoak21 self-assigned this Apr 2, 2026
@lacoak21 lacoak21 added this to IMAP Apr 2, 2026
@lacoak21 lacoak21 marked this pull request as ready for review April 2, 2026 19:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() and idex_l1b_msg() return types to allow None when no MSG events of interest exist.
  • Added a post-filter check in idex_l1b_msg() to log a warning and return None if the filtered dataset has zero epoch entries.
Comments suppressed due to low confidence (1)

imap_processing/idex/idex_l1b.py:159

  • The idex_l1b_msg docstring still states it returns an xarray.Dataset, but the function can now return None when 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.

Comment on lines 120 to 142
@@ -142,7 +142,7 @@ def idex_l1b(l1a_dataset: xr.Dataset, descriptor: str) -> xr.Dataset:
raise ValueError(f"Unsupported descriptor: {descriptor}")
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +208 to +212
if len(l1b_dataset["epoch"]) == 0:
logger.warning(
"No science or pulser events found. No l1b dataset will be created."
)
return None
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
@lacoak21 lacoak21 merged commit 36b3859 into IMAP-Science-Operations-Center:dev Apr 2, 2026
14 checks passed
@github-project-automation github-project-automation bot moved this to Done in IMAP Apr 2, 2026
@lacoak21 lacoak21 deleted the idex_l1b_skip_empty_dataset branch April 2, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants