Skip to content

Minor changes towards issue 3135 (IMAP-Lo goodtimes)#3170

Merged
tmplummer merged 6 commits into
IMAP-Science-Operations-Center:devfrom
vineetbansal:vb/issue3135a
May 12, 2026
Merged

Minor changes towards issue 3135 (IMAP-Lo goodtimes)#3170
tmplummer merged 6 commits into
IMAP-Science-Operations-Center:devfrom
vineetbansal:vb/issue3135a

Conversation

@vineetbansal
Copy link
Copy Markdown
Collaborator

@vineetbansal vineetbansal commented May 10, 2026

Change Summary

Overview

Minor changes in support for issue #3135

File changes

  • imap_processing/lo/l1b/lo_l1b.py - increased precision for MET data - was causing issues when cross-checking against IMAP-Lo team's offline pipeline algorithm. Also made the code tolerant if we end up adding new species (besides 'O') in the future. Using existing constants when we can (added one new one - N_SPIN_ANGLE_BINS.

Testing

@vineetbansal vineetbansal marked this pull request as ready for review May 11, 2026 14:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes small IMAP-Lo L1B “goodtimes”/background-rate processing updates to (1) increase MET precision for cross-checking against the IMAP-Lo team’s offline pipeline and (2) reduce brittleness when additional ion species are added in the future by replacing hard-coded dimensions and making some lookups more tolerant.

Changes:

  • Replace hard-coded ESA/spin-bin dimensions in selected arrays with shared LO constants (and introduce N_SPIN_ANGLE_BINS).
  • Make histogram species handling more tolerant when a species’ *_counts variable is absent (fallback to zeros).
  • Increase gt_start_met / gt_end_met precision to float64 and relax attribute schema checking for background-rate variables.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
imap_processing/lo/l1b/lo_l1b.py Updates array shapes to use constants, adds missing-species tolerance, increases MET precision, and changes how bgrates vars/attrs are collected.
imap_processing/lo/constants.py Adds N_SPIN_ANGLE_BINS constant (60) to centralize spin-angle bin sizing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread imap_processing/lo/l1b/lo_l1b.py Outdated
Comment thread imap_processing/lo/l1b/lo_l1b.py Outdated
Comment thread imap_processing/lo/l1b/lo_l1b.py
Comment thread imap_processing/lo/l1b/lo_l1b.py
Comment thread imap_processing/lo/l1b/lo_l1b.py Outdated
Comment on lines +2866 to +2874
background_rate_fields = sorted(
[
data_var
for data_var in l1b_backgrounds_and_goodtimes_ds.data_vars
if any(
data_var.endswith(suffix) for suffix in background_rate_field_suffixes
)
]
)
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.

I didn't catch this before, but no epoch variable in the bgrates dataset? I'm pretty sure that will not be tolerated by SPDF.

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.

fixed

Comment thread imap_processing/lo/l1b/lo_l1b.py Outdated
Comment on lines 2876 to 2879
lib_bgrates_ds = l1b_backgrounds_and_goodtimes_ds[background_rate_fields]
lib_bgrates_ds.attrs = attr_mgr_l1b.get_global_attributes("imap_lo_l1b_bgrates")

return lib_bgrates_ds, l1b_goodtimes_ds
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.

Suggested change
lib_bgrates_ds = l1b_backgrounds_and_goodtimes_ds[background_rate_fields]
lib_bgrates_ds.attrs = attr_mgr_l1b.get_global_attributes("imap_lo_l1b_bgrates")
return lib_bgrates_ds, l1b_goodtimes_ds
l1b_bgrates_ds = l1b_backgrounds_and_goodtimes_ds[background_rate_fields]
l1b_bgrates_ds.attrs = attr_mgr_l1b.get_global_attributes("imap_lo_l1b_bgrates")
return l1b_bgrates_ds, l1b_goodtimes_ds

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.

@tmplummer - not sure what I was smoking before, but fixed now.

@tmplummer
Copy link
Copy Markdown
Contributor

It looks like a few of the changes inside of if statements are not getting exercised in unit testing. Is there any way you can add coverage for those?

          if bg_rate == 0.0:
-             bg_rate = bg_rate_anti_ram_nominal / c.BG_RATE_FLOOR_DIVISOR[elem]
+             bg_rate = bg_rate_anti_ram_nominal / c.BG_RATE_FLOOR_DIVISOR.get(elem, 1)
              sigma_bg_rate = bg_rate
          if sigma_bg_rate == 0.0:
              sigma_bg_rate = bg_rate

Copy link
Copy Markdown
Contributor

@tmplummer tmplummer left a comment

Choose a reason for hiding this comment

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

Thanks for adding the test coverage

@tmplummer tmplummer merged commit 9c1c905 into IMAP-Science-Operations-Center:dev May 12, 2026
14 checks passed
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