Skip to content

Conversation

@greglucas
Copy link
Collaborator

This turns the DE rates into a histogram product, summing the annotated direct events into histogram bins for comparison with the hist-rates and monitor-rates products.

Opening in draft mode for now because I haven't added any tests and have quite a few TODOs in here. This is to get a product out and have the code associated with it up.

@greglucas greglucas added this to the January 2026 milestone Jan 8, 2026
@greglucas greglucas self-assigned this Jan 8, 2026
@greglucas greglucas added Ins: Lo Related to the IMAP-Lo instrument Level: L1 Level 1 processing labels Jan 8, 2026
@greglucas greglucas marked this pull request as ready for review January 22, 2026 22:10
@greglucas
Copy link
Collaborator Author

Test added, pivot platform added. This is now ready for review. It includes #2601 for the refactor so I don't have to do it twice.

Copy link
Contributor

@subagonsouth subagonsouth 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 to me

double_mask = np.isin(coincidence_type, double_types)

# Vectorized histogramming using np.add.at with full index arrays
np.add.at(h_counts, (asc_idx[h_mask], esa_step_idx[h_mask], spin_bin[h_mask]), 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

pivot_angle : float
The nearest pivot angle for the given epoch.
"""
return ds_nhk["pcc_cumulative_cnt_pri"].sel(epoch=epoch, method="nearest").item()
Copy link
Contributor

Choose a reason for hiding this comment

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

Great use of xarray functionality.

l1b_nhk = sci_dependencies["imap_lo_l1b_nhk"]
# Set the asc_start for each DE by removing the average spin cycle
# which is a function of esa_step
asc_start = l1b_de["spin_cycle"] - (7 + (l1b_de["esa_step"] - 1) * 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be helpful to have a comment explaining this equation.

This turns the DE rates into a histogram product, summing the
annotated direct events into histogram bins for comparison with
the hist-rates and monitor-rates products.
@greglucas greglucas merged commit 0b89a2b into IMAP-Science-Operations-Center:dev Jan 23, 2026
14 checks passed
@greglucas greglucas deleted the lo-de-rates branch January 23, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ins: Lo Related to the IMAP-Lo instrument Level: L1 Level 1 processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants