Skip to content

fix: address SPDF follow-up for CoDICE, MAG, and SWAPI metadata#3307

Draft
davidt0x wants to merge 4 commits into
IMAP-Science-Operations-Center:devfrom
davidt0x:fix/istp_insitu_spdf_followup
Draft

fix: address SPDF follow-up for CoDICE, MAG, and SWAPI metadata#3307
davidt0x wants to merge 4 commits into
IMAP-Science-Operations-Center:devfrom
davidt0x:fix/istp_insitu_spdf_followup

Conversation

@davidt0x

@davidt0x davidt0x commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

This draft bundles the current in-situ SPDF follow-up changes for CoDICE, MAG, and SWAPI.

Final branch state:

  • MAG updates the RTN direction labels and fixes quality_bitmask metadata so the fill value is out of range while preserving the 0..255 science range.
  • SWAPI updates the main science, uncertainty, rate, and flag variables to depend on the time-varying esa_energy axis.

What Changed

CoDICE

  • widened spin_sector FORMAT to I3 so FILLVAL=255 is representable
  • kept the focused test guard for spin_angle because the checked-in validation CDF still carries outdated spin_angle values

MAG

  • RTN products now write direction_label = ["B_R", "B_T", "B_N"]
  • other MAG frames keep the Cartesian Bx/By/Bz labels
  • quality_bitmask is written as CDF_UINT2 with VALIDMIN=0, VALIDMAX=255, and an out-of-range fill value

SWAPI

  • switched the primary L2 science, uncertainty, rate, and flag variables from DEPEND_1=esa_step to DEPEND_1=esa_energy
  • left esa_energy itself indexed by esa_step

Why

These changes address SPDF review comments on user-visible metadata and axis semantics while keeping the branch scoped to the specific issues raised in review.

Validation

  • pytest -q imap_processing/tests/codice/test_codice_hi_l2.py imap_processing/tests/mag/test_mag_l2.py imap_processing/tests/mag/test_mag_l1d.py imap_processing/tests/swapi/test_swapi_l2.py

davidt0x added 4 commits June 11, 2026 14:43
(A1.1) For "spin_sector" variable, could you change FORMAT to "I3" to cover FILLVAL=255

(A1.2) This is related to comment (3.2) below. Is it correct that "spin_angle" variable is defined as VAR_TYPE="support_data" and not VAR_TYPE="data". This seems to be the variable that shows what Spin Angle, and is not visible to users if VAR_TYPE="support_data".

Implementation notes:
- widened spin_sector FORMAT to I3 so FILLVAL=255 is representable.
- promoted hi-sectored spin_angle to VAR_TYPE=data with DISPLAY_TYPE=spectrogram so it is visible to users.
- broadcast the static spin-angle grid across epoch so the written CDF satisfies the ISTP DEPEND_0/1/2 requirements for a visible data variable.
(A2.1) "direction_label" variable values should be ["B_R", "B_T", "B_N"], or something like that, not ["Bx", "By", "Bz"], since RTN is a special case with named components. And same in imap_mag_l2_burst-rtn_20260422_v002.cdf

(A3) For all imap_mag datasets, for "quality_bitmask" variable, FILLVAL attribute value has to be outside of [VALIDMIN, VALIDMAX] range. Now FILLVAL is same as VALIDMAX.

Implementation notes:
- RTN now writes ["B_R", "B_T", "B_N"], while SRF/DSRF/GSE/GSM keep ["Bx", "By", "Bz"] because those remain Cartesian component labels.
- quality_bitmask now writes as CDF_UINT2 with VALIDMIN=0, VALIDMAX=255, and a non-science fill value outside that range.
- the final fill value is 65535 rather than 256 because SPDF validation on the written CDF preferred the standard unsigned-16 fill value.
- this change affects both MAG L2 and L1D because they share the same dataset-generation path.
(A4.1) Related to (12.2) below. I see that you now have "esa_energy" variable defined as VAR_TYPE="data", so visible to users. But that "esa_energy" variable (time varying 1-D, size 72) could also be used as DEPEND_1="esa_energy", instead of DEPEND_1="esa_step" (time non-varying 1-D, size 72). Depend variables in ISTP can be time-varying (1-D + time).

Implementation notes:
- swp_l1a_flags and the L2 rate/rate-uncertainty variables now use the time-varying esa_energy axis as DEPEND_1.
- esa_energy itself remains indexed by esa_step because it is still the per-sweep mapping from step id to energy.
- this was implemented in swapi_l2.py rather than by changing the shared SWAPI YAML defaults, because the shared defaults are also used by the L1 science writer and changing them there broke the L1 CDF path.
SPDF follow-up:

Thanks, Dave. For (A1.2) comment, I missed that "spin_angle" variable is time non-varying, and cannot be easily changed to VAR_TYPE="data", so no change is needed in this case.

Implementation notes:
- restore hi-sectored spin_angle as a static 2-D support_data variable
- remove the epoch broadcast and visible-data metadata that were added for the earlier interpretation of (A1.2)
- keep the separate spin_sector FORMAT=I3 fix from (A1.1)
- retain the focused test guard for spin_angle because the checked-in validation CDF still carries outdated spin_angle values
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.

1 participant