Skip to content

HIT L2: added data transformation into 10-minute chunks to L2 - #3377

Open
leowerneck wants to merge 4 commits into
IMAP-Science-Operations-Center:devfrom
leowerneck:lw/issue3327
Open

HIT L2: added data transformation into 10-minute chunks to L2#3377
leowerneck wants to merge 4 commits into
IMAP-Science-Operations-Center:devfrom
leowerneck:lw/issue3327

Conversation

@leowerneck

@leowerneck leowerneck commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Change Summary

Closes #3327.

Overview

This PR moves the HIT macropixel 10-minute chunk transformation from L3 to L2. It coordinates with PR 161 in
imap_L3_processing that closes issue 143 of that repository.

The L2 macropixel product now consolidates the ten one-minute packetized records into a single record for each 10-minute
integration period. It also assigns the integration midpoint as the epoch and provides five-minute DELTA_MINUS and
DELTA_PLUS values through epoch_delta.

File changes

The following changes were made:

  • imap_processing/hit/l2/hit_l2.py
    • Added transform_to_10_minute_chunks.
    • Consolidated each group of ten packetized records into one macropixel record containing all species and energy
      combinations.
    • Updated each consolidated record's epoch to the midpoint of its 10-minute integration period.
    • Added a five-minute epoch_delta for each record.
    • Updated process_macropixel_intensity to return the transformed dataset.
    • Configured the macropixel epoch attributes to use epoch_delta for both DELTA_MINUS_VAR and DELTA_PLUS_VAR.
  • imap_processing/cdf/config/imap_constant_attrs.yaml
    • Added the CDF variable declaration for epoch_delta.

Testing

Ran the focused HIT L2 test suite:

  uv run pytest -q imap_processing/tests/hit/test_hit_l2.py

All 17 tests passed.

@tmplummer tmplummer left a comment

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.

A few things to consider.

Comment on lines +147 to +148
dataset["epoch"].attrs["DELTA_MINUS_VAR"] = "epoch_delta"
dataset["epoch"].attrs["DELTA_PLUS_VAR"] = "epoch_delta"

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.

It would be nice if these were defined in the imap_hit_l2_variable_attrs.yaml file so that everything is in that single place, but that would still require custom code here to get those values and set them only to the macropixel product. Adding something like this to the above for dim in dataset.dims: loop:

if dim != "epoch":
    ...
elif "macropixel" in logical_source:
    dataset["epoch"].attrs.update(attr_mgr.get_variable_attributes("epoch_macropixel", check_schema=False))

Thoughts?

Comment thread imap_processing/hit/l2/hit_l2.py Outdated
Comment on lines +820 to +832
for species, num_energy_levels in species_energy:
energy_dim = f"{species}_energy_mean"
species_variables = [
var
for var in macropixel_dataset.data_vars
if macropixel_dataset[var].dims[:2] == ("epoch", energy_dim)
]

for energy_i in range(num_energy_levels):
for var in species_variables:
_data = macropixel_dataset[var].values[species_i::10, energy_i]
transformed_dataset[var].values[:, energy_i] = _data
species_i += 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.

Can you add comments in here? It looks like it is doing some sort of diagonal gather but it is a bit hard to follow.

@leowerneck leowerneck Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing that out. I added comments and changed variables name to hopefully make things a bit clearer. Let me know if it's still not so.

RECORD_VARYING: RV
SCALETYP: linear
UNITS: ns
VALIDMAX: 86000000000000

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.

Why such a specific value rather than double integer max?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I took these straight out of L3, but I'll admit I'm not completely sure why the values were chosen.

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.

It's roughly a day (86000 seconds) which strikes me as Grant throwing up his hands and saying "I don't know, a day?" Maybe 1e14 makes more sense. Anything between "about an hour" and "about a day" is probably reasonable (we all know it's going to be awfully close to 300 seconds the vast majority of the time).

FORMAT: I19
LABLAXIS: Epoch delta
NAME: epoch_delta
RECORD_VARYING: RV

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.

Where does this come from? It's the first time I have seen it and I can't find it in SPDF's list of variable attributes. https://spdf.gsfc.nasa.gov/istp_guide/vattributes.html

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.

L3 puts certain aspects of the variable definition in the SAMMI YAML; this is a difference between L2 and L3 that should be addressed in the move.

leowerneck and others added 2 commits August 13, 2026 14:01
Co-authored-by: Tim Plummer <timothy.plummer@lasp.colorado.edu>

@tmplummer tmplummer left a comment

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.

This looks good to me.

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.

HIT - Update handling of epochs with new L2 sectored input HIT Sector Data Epoch Update

3 participants