Skip to content

Conversation

@mhairifin
Copy link
Contributor

Change Summary

Overview

  • Update MAGO and MAGI spice frames to use IMAP_MAG_BASE instead of the mechanical spice frames. The MAG team have agreed to use an ideal frame for the spice transformation as our in flight calibration already includes rotation into the idealised frame.
  • Update MAG L2 and L1D variable names for the vectors

Updated Files

  • ialirt/l0/parse_mag
    • Change MAGO and MAGI frame to IMAP_MAG_BASE for I-ALiRT
  • mag/l2/mag_l2_data
    • Introduce additional fields to ValidFrames enum to distinguish MAGI and MAGO despite sharing a spice frame, and add in the variable name and variable attributes identifier
    • Use these new fields to generate an L2 dataset
  • mag/l1d/mag_l1d_data
    • Use new spice_frame formulation

Testing

  • Tests updated where needed to use spice_frame
  • Frame rotation test updated to reflect that MAGI and MAGO share a spice frame
  • L2 dataset generation tests updated to test for correct variable name

Copy link
Contributor

@alastairtree alastairtree left a comment

Choose a reason for hiding this comment

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

Looks very tidy to me!

GSM = SpiceFrame.IMAP_GSM
RTN = SpiceFrame.IMAP_RTN
MAGO = ("MAGO", SpiceFrame.IMAP_MAG_BASE, "vector_attrs", "vectors")
MAGI = ("MAGi", SpiceFrame.IMAP_MAG_BASE, "vector_attrs", "vectors")
Copy link
Contributor

Choose a reason for hiding this comment

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

If both sensors are in the same spice frame IMAP_MAG_BASE what are the consequences? I had assumed we needed both to be different to be able to handle the the slightly different positions of them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do need to transform them differently - but we already do so by providing separate calibration matrices which are used for L2 and L1D. We create those calibration matrices by using the magnetic field data to work out how non-aligned with the spacecraft reference frame the sensors are. So either we use an idealised transform here, or we would have to create a calibration matrix to align it, and then un-twist it by this spice transform before we provide it as ancillary data.

Copy link
Contributor

Choose a reason for hiding this comment

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

Based on our chat we have agreed

  • Fix the lowercase MAGi=>MAGI
  • Add comment explain why BASE frame is used for L2/L1D only
  • Add frames for the unused, but still valid, SPICE magi/o frames and call them "ground calibration"

@mhairifin mhairifin marked this pull request as ready for review December 10, 2025 14:58
@maxinelasp maxinelasp self-requested a review December 11, 2025 16:39
@maxinelasp maxinelasp assigned maxinelasp and mhairifin and unassigned maxinelasp Dec 11, 2025
Copy link
Contributor

@maxinelasp maxinelasp left a comment

Choose a reason for hiding this comment

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

Looks good! Nice improvement. I think we should hold back on merging this until I'm able to investigate L3 MAG usage, but I can deploy this to dev now for further testing. I poked around more and it doesn't look like anywhere in the MAG codebase assumes that the main variable is named "vectors".

time_data["secondary_epoch"],
magi_out,
SpiceFrame.IMAP_MAG_I,
SpiceFrame.IMAP_MAG_BASE,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would make sense to point this to ValidFrames.IMAP_MAGI so it can benefit from that abstraction layer if ValidFrames gets updated again.

DSRF = ("DSRF", SpiceFrame.IMAP_DPS, "vector_attrs_dsrf", "b_dsrf")
SRF = ("SRF", SpiceFrame.IMAP_SPACECRAFT, "vector_attrs_srf", "b_srf")
GSE = ("GSE", SpiceFrame.IMAP_GSE, "vector_attrs_gse", "b_gse")
GSM = ("GSM", SpiceFrame.IMAP_GSM, "vector_attrs_gsm", "b_gsm")
Copy link
Contributor

Choose a reason for hiding this comment

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

There are a few people who are using MAG data as inputs - we will need to reach out to them if we change variable names here to make sure they can access the correct variable. (Or open a PR against L3 code, I can take a look at this.)

The current users of MAG are:
CoDICE L3b
HIT L3
SWE L3

That's not too many, so I think it's fine to change the names - just something we should consider and check.

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.

3 participants