Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1148 hi l1c populate despun z #1253

Conversation

subagonsouth
Copy link
Contributor

Change Summary

Overview

Adds computation of despun_z (Pointing frame z-axis) in the HAE Ecliptic frame and the pointing set spin bin locations in the HAE Ecliptic frame.

Updated Files

  • imap_processing/hi/l1c/hi_l1c.py
    • Compute despun_z vector
    • Compute elevation and azimuth (lat/lon) of the centers of the PSET "pixels"
  • imap_processing/spice/geometry.py
    • Fix docstrings in Cartesian<-->Spherical coordinate conversion functions
    • imap_processing/tests/hi/test_hi_l1c.py
  • Add test coverage for updated pset_geometry() function

Closes: #1148 #1149

Add test coverage for pset_geometry function
…cartesian functions

Calculate despun_z vector and hae lat/lon of spin bins in L1C pset
Add test coverage for hae lat/lon values
@subagonsouth subagonsouth added the Ins: Hi Related to the IMAP-Hi instrument label Jan 8, 2025
@subagonsouth subagonsouth self-assigned this Jan 8, 2025
Copy link
Contributor

@nkerman nkerman left a comment

Choose a reason for hiding this comment

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

LGTM! If you think it's important, we could extract out a function to transform from AZ/EL in frame A to AZ/EL in frame B.

@@ -72,8 +79,9 @@ def generate_pset_dataset(de_dataset: xr.Dataset) -> xr.Dataset:
pset_dataset.epoch.data[0] = np.mean(de_dataset.epoch.data[[0, -1]]).astype(
np.int64
)
pset_et = j2000ns_to_j2000s(pset_dataset.epoch.data[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah good to know! I'll need to add this to the Ultra L2 code as well.


pset_dataset.update(pset_geometry())
pset_dataset.update(pset_geometry(pset_et, logical_source_parts["sensor"]))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment to explain what this update does?

(As I understand it: pset_geometry calculates the hae frame projection of the DPS bins lat/lon and the despun Z vector, then this adds those to the xr.Dataset.)

np.full(3600, np.deg2rad(el)),
]
).T
dps_cartesian = spherical_to_cartesian(dps_az_el)
Copy link
Contributor

Choose a reason for hiding this comment

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

The transformation all looks good! I wonder, since we've been talking so much about shared functionality, if we should make a function like:

AZ_b, EL_b = frame_transform_az_el(input_frame=A, projection_frame=B, input_az=AZ_a, input_el=EL_a)

which combines these 3 often repeated steps:

  1. Make unit vectors from AZ_a, EL_a angles in frame A
  2. Transform these vectors to unit vectors in frame B
  3. Convert to projected AZ_b, EL_b angles in frame B

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I'll write a SPICE ticket for this function.

Comment on lines 55 to 57
@mock.patch(
"imap_processing.hi.l1c.hi_l1c.frame_transform", side_effect=lambda a, b, c, d: b
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking, this is mocking the frame transform to simply return the input position? Maybe add a comment or replace argument b with position.

@subagonsouth subagonsouth merged commit 4cb7084 into IMAP-Science-Operations-Center:dev Jan 10, 2025
15 of 17 checks passed
@subagonsouth subagonsouth deleted the 1148-hi-l1c-populate-despun_z branch January 10, 2025 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ins: Hi Related to the IMAP-Hi instrument
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Hi L1C - populate despun_z
2 participants