Skip to content

HIT L0 - change epoch to center collection time#1839

Merged
vmartinez-cu merged 6 commits intoIMAP-Science-Operations-Center:devfrom
vmartinez-cu:center-epoch
Jun 23, 2025
Merged

HIT L0 - change epoch to center collection time#1839
vmartinez-cu merged 6 commits intoIMAP-Science-Operations-Center:devfrom
vmartinez-cu:center-epoch

Conversation

@vmartinez-cu
Copy link
Copy Markdown
Collaborator

This PR changes the epoch values used for science data to be the center collection time for that data. Previously, the starting time was being used.

Closes #1838

Updated Files

  • imap_processing/hit/l0/decom_hit.py
    • Created an array of mean epoch values in science frames as the new epoch coordinate in the dataset

…e. frame) by taking the mean of the epoch start and end values from the packets in the frame. This replaces using the epoch of the starting packet for the frame
@vmartinez-cu vmartinez-cu self-assigned this Jun 23, 2025
@vmartinez-cu vmartinez-cu added Ins: HIT Related to the HIT instrument Level: L0 Level 0 processing labels Jun 23, 2025
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

The PR updates the science data epoch values to use the center of each collection frame rather than the starting time.

  • Compute mean of first and last packet times for each science frame
  • Replace NumPy array accumulation with a Python list
  • Assign new epoch coordinate as an xarray DataArray
Comments suppressed due to low confidence (2)

imap_processing/hit/l0/decom_hit.py:314

  • [nitpick] Using "epoch" as the dimension name may conflate the index with its values; consider using a more descriptive dimension like "frame" and assign "epoch" solely as the coordinate name for clarity.
    sci_dataset.coords["epoch"] = xr.DataArray(epoch_per_science_frame, dims=["epoch"])

imap_processing/hit/l0/decom_hit.py:309

  • Building the coordinate array by appending to a Python list may be less efficient; consider accumulating values in a NumPy array or converting the final list to np.array(epoch_per_science_frame) before creating the DataArray for better performance.
        epoch_per_science_frame.append(

# Add new data variables to the dataset
sci_dataset = sci_dataset.drop_vars("epoch")
sci_dataset.coords["epoch"] = epoch_per_science_frame
# Add new data variables to the dataset and update epoch coordinate
Copy link

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

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

The original epoch variable is not dropped before assigning a new coordinate. Consider calling sci_dataset = sci_dataset.drop_vars("epoch") to avoid conflicts or duplicate variables.

Suggested change
# Add new data variables to the dataset and update epoch coordinate
# Add new data variables to the dataset and update epoch coordinate
sci_dataset = sci_dataset.drop_vars("epoch", errors="ignore") # Drop existing epoch variable if it exists

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

sci_dataset.coords["epoch"] = xr.DataArray(epoch_per_science_frame, dims=["epoch"]) replaces the epoch coordinate with the new values and doesn't need to be dropped first

Copy link
Copy Markdown
Contributor

@sdhoyt sdhoyt left a comment

Choose a reason for hiding this comment

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

Nice!

@sdhoyt
Copy link
Copy Markdown
Contributor

sdhoyt commented Jun 23, 2025

Is it possible to check the center epoch in one of your existing unit tests?

@vmartinez-cu vmartinez-cu merged commit a1fdbb7 into IMAP-Science-Operations-Center:dev Jun 23, 2025
14 checks passed
@github-project-automation github-project-automation bot moved this to Done in IMAP Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ins: HIT Related to the HIT instrument Level: L0 Level 0 processing

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

HIT L0 - change epoch to center collection time

3 participants