Skip to content

HIT L0 - Fix angle dimension order error#1837

Merged
vmartinez-cu merged 2 commits intoIMAP-Science-Operations-Center:devfrom
vmartinez-cu:fix-angle-dims
Jun 23, 2025
Merged

HIT L0 - Fix angle dimension order error#1837
vmartinez-cu merged 2 commits intoIMAP-Science-Operations-Center:devfrom
vmartinez-cu:fix-angle-dims

Conversation

@vmartinez-cu
Copy link
Copy Markdown
Collaborator

This PR updates how the raw binary sectorates data is processed. It needs to be processed with a shape of 8x15 and then transposed to 15x8 to ensure that the data ends up in the correct spots in the data array. I was shaping the data as 15x8 from the start, but since the data comes out of flight software and it has the opposite order defined, this was not producing expected results during validation.

Closes #1836

Updated Files

  • imap_processing/hit/l0/constants.py
    • Changed shape definition back to 8x15 for sectorates
  • imap_processing/hit/l0/decom_hit.py
    • Transposed decommutated sectorates data to 15x8
  • imap_processing/hit/l1a/hit_l1a.py
    • Replaced hard coded values for dimension sizes with length of constants for those dimensions

…(zenith x azimuth) while decommutating the binary data since that is how the data is specified in the flight software, and then transposed for the data products. This ensures that the correct values end up where expected in the new shape (azimuth x zenith).
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 corrects the dimension ordering for raw binary sectorates by reshaping to 8×15 and then transposing to 15×8, and centralizes dimension lengths.

  • Updated the sectorates shape in constants to (8, 15) to match flight software output
  • Added a transpose in decom_hit to reorder data from (8, 15) → (15, 8)
  • Replaced hard-coded 15×8 array sizes in hit_l1a with len(AZIMUTH_ANGLES) and len(ZENITH_ANGLES)

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
imap_processing/hit/l1a/hit_l1a.py Use dynamic dimension lengths for counts array instead of fixed 15×8
imap_processing/hit/l0/decom_hit.py Reshape sectorates to (8, 15) then transpose to (15, 8) before assigning azimuth/zenith dims
imap_processing/hit/l0/constants.py Changed sectorates shape tuple from (15, 8) to (8, 15)
Comments suppressed due to low confidence (3)

imap_processing/hit/l0/decom_hit.py:95

  • [nitpick] Consider clarifying this comment to explain that data is first reshaped to (num_frames, 8, 15) and then transposed to (num_frames, 15, 8), making the axes mapping explicit.
                # Transpose data to 15x8 for azimuth and zenith look directions

imap_processing/hit/l0/constants.py:103

  • [nitpick] The inline comment could be expanded to indicate that the tuple represents (azimuth, zenith) dimensions—8 azimuth angles and 15 zenith angles—for greater clarity.
    "sectorates": HITPacking(16, 1920, (8, 15)),  # sectored rates

imap_processing/hit/l0/decom_hit.py:97

  • Add a unit test to verify that reshape and transpose for 'sectorates' produce the expected (num_frames, 15, 8) shape and correct ordering of azimuth and zenith axes, preventing future regressions.
                parsed_data = np.transpose(parsed_data, axes=(0, 2, 1))

# look directions
parsed_data = np.array(parsed_data).reshape((-1, *field_meta.shape))
# Transpose data to (num_frames, 15, 8) for flipped look directions
parsed_data = np.transpose(parsed_data, axes=(0, 2, 1))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What would happen if you left L0 as (15, 8) and didn't transpose it here? Would that cause any issues?

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.

The values end up in a different arrangement in the data array which then fails HIT's validation tests. I guess transposing data is different from reshaping data and I didn't realize that before

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I just realized you added the transpose here as part as part of this change, so that was a dumb question

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 work!

# look directions
parsed_data = np.array(parsed_data).reshape((-1, *field_meta.shape))
# Transpose data to (num_frames, 15, 8) for flipped look directions
parsed_data = np.transpose(parsed_data, axes=(0, 2, 1))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I just realized you added the transpose here as part as part of this change, so that was a dumb question

@vmartinez-cu vmartinez-cu merged commit f9687bb into IMAP-Science-Operations-Center:dev Jun 23, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transpose angle dimensions

3 participants