HIT L0 - change epoch to center collection time#1839
Merged
vmartinez-cu merged 6 commits intoIMAP-Science-Operations-Center:devfrom Jun 23, 2025
Merged
HIT L0 - change epoch to center collection time#1839vmartinez-cu merged 6 commits intoIMAP-Science-Operations-Center:devfrom
vmartinez-cu merged 6 commits intoIMAP-Science-Operations-Center:devfrom
Conversation
…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
Contributor
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
Collaborator
Author
There was a problem hiding this comment.
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
Contributor
|
Is it possible to check the center epoch in one of your existing unit tests? |
…ure epoch is added as a dimension to the dataset and that it's shape matches the count rates data
a1fdbb7
into
IMAP-Science-Operations-Center:dev
14 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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