Skip to content

SWAPI: Add velocity, covariance, and uncertainty in GSE coordinates - #221

Merged
jtniehof merged 28 commits into
IMAP-Science-Operations-Center:mainfrom
leowerneck:lw/issue21-gse-sun
Oct 23, 2026
Merged

jtniehof merged 28 commits into
IMAP-Science-Operations-Center:mainfrom
leowerneck:lw/issue21-gse-sun

Conversation

@leowerneck

@leowerneck leowerneck commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Change Summary

Related to #21.

Overview

This PR is a simplified version of #165 intended to add the transformation to GSE coordinates in the Earth frame. It does not introduce GSM or HAE-J2000, which will be left for a future PR (if still desired).

Testing

All newly added tests pass locally.

Note

The vast majority of the diff in this commit is due to reformatting with ruff format, which mostly affect the test files.

@leowerneck
leowerneck requested a review from jtniehof October 2, 2026 20:28
@leowerneck leowerneck self-assigned this Oct 2, 2026
@leowerneck leowerneck added enhancement New feature or request Ins: SWAPI Related to the SWAPI instrument labels Oct 2, 2026
@leowerneck leowerneck added this to IMAP Oct 2, 2026
@leowerneck leowerneck moved this to PR Open in IMAP Oct 2, 2026
@leowerneck

Copy link
Copy Markdown
Collaborator Author

@hafarooki Your review would also be appreciated.

@leowerneck leowerneck changed the title Lw/issue21 gse sun SWAPI: Add *_gse_earth and *_gse_sun quantities Oct 2, 2026
Comment thread docs/swapi/alpha-sw.md Resolved
Comment thread docs/swapi/proton-sw.md Resolved
Comment thread docs/swapi/alpha-sw.md Resolved
Comment thread docs/swapi/proton-sw.md Resolved
Comment thread imap_l3_processing/swapi/l3a/utils.py Resolved
Comment thread imap_l3_processing/swapi/l3a/utils.py Resolved
Comment thread imap_l3_processing/swapi/l3a/utils.py Resolved
@leowerneck leowerneck changed the title SWAPI: Add *_gse_earth and *_gse_sun quantities SWAPI: Add velocity, covariance, and uncertainty in GSE coordinates Oct 7, 2026
@jtniehof

jtniehof commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

My big question before looking at details: have we confirmed exactly what WIND is reporting as GSE? Is it GSE relative to Sun, GSE less a fixed 30km/s in Y, or a "proper" aGSE rotated into SW (nominal or actual)? Since matching WIND (and other L1) is a key driver, we should be as precise as we can. Has someone looped in with Savvas?

(Slow on the uptake here because I've been focusing on the release 2 issues).

@leowerneck

leowerneck commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

After discussions with @mmshaw and @mecuesta, combined with the result of the long email thread, my understanding is that IMAP will report GSE in the Earth's frame, and that it should be called "_gse" (not "_gse_earth"). We won't try to match other missions if they use something else.

My goal for this PR was to introduce GSE (not aGSE) coordinates in the Earth's frame. The steps I took were:

  • Rotate the Sun-frame RTN velocity into ECLIPJ2000.
  • Use SPICE to subtract Earth's velocity.
  • Use SPICE to apply a full 6x6 state transform from ECLIPJ2000 to GSE.

Hameed can correct me if I'm wrong, but I believe he found that WIND/OMNI use GSE coordinates in the Sun's frame. I haven't looped in with Savvas.

@leowerneck

Copy link
Copy Markdown
Collaborator Author

Pinging @mmshaw and @mecuesta for comments.

@jtniehof jtniehof left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Couple of small metadata change requests and a query on the approach...I don't think anything major needs to be changed.

Comment thread imap_l3_processing/swapi/l3a/utils.py Resolved
@leowerneck

leowerneck commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator Author

@jtniehof Should be ready for your review. Opened companion PR IMAP-Science-Operations-Center/sds-data-manager#1747.

@jtniehof jtniehof left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One further little nitpick on the transform...


# Rotate the velocity relative to IMAP, then add IMAP's velocity relative to Earth.
velocity_rtn_imap = velocity_rtn_sun - get_spacecraft_velocity_rtn(epoch_tt2000_ns)
velocity_gse = gse_from_rtn @ velocity_rtn_imap + imap_velocity_gse

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I do think this should still be the six-component state transform for velocity from RTN to GSE

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.

Doesn't:

    imap_state_gse = imap_state(et, SpiceFrame.IMAP_GSE, observer=SpiceBody.EARTH)
    imap_velocity_gse = imap_state_gse[3:]

already include the dR/dt term? I thought the point was to let SPICE handle the sxform calls under the hood instead of calling them explicitly in the code.

The test test_convert_sun_velocity_rtn_to_gse_matches_full_state_transform was intended to ensure that the current RTN -> GSE approach matches the previous RTN -> J2000 -> GSE, so I thought I was doing the right thing.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oh! Right! The dR/dt term is going to be lumped in with the spacecraft velocity transform. I was thinking in terms of doing it with the plasma velocity transform. Nice catch.

@jtniehof jtniehof left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

all good!

@jtniehof
jtniehof merged commit 1d4d46e into IMAP-Science-Operations-Center:main Oct 23, 2026
16 of 17 checks passed
@github-project-automation github-project-automation Bot moved this from PR Open to Done in IMAP Oct 23, 2026
@jtniehof jtniehof moved this from Done to Validating in IMAP Oct 27, 2026
@jtniehof

jtniehof commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

I'm marking as Validating status until we deploy and reprocess and check.

EDIT: As Leo noted, after release 2 is done.

@leowerneck
leowerneck deleted the lw/issue21-gse-sun branch October 27, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Ins: SWAPI Related to the SWAPI instrument

Projects

Status: Validating

Development

Successfully merging this pull request may close these issues.

3 participants