Skip to content

Add tests, rearrange GLOWS L2, fix exposure times#2726

Open
maxinelasp wants to merge 2 commits intoIMAP-Science-Operations-Center:devfrom
maxinelasp:glows-l2-tests
Open

Add tests, rearrange GLOWS L2, fix exposure times#2726
maxinelasp wants to merge 2 commits intoIMAP-Science-Operations-Center:devfrom
maxinelasp:glows-l2-tests

Conversation

@maxinelasp
Copy link
Contributor

Change Summary

Overview

Moves GLOWS L2 Histogram calculation into the dataclass to match other levels, fixes the L2 exposure time calculation, and adds additional unit tests.

A lot of these changes are just for moving calculations from glows_l2.py to glows_l2_data.py. Look at the specific updates in the file changes section for actual changes. The main ones are around exposure_times.

File changes

  • glows_l2_data.py: Fixes exposure time calculation in DailyLightcurve
    — divides by number of bins (not hardcoded 3600) and accumulates uniformly across good-time epochs rather than per-bin. Removes the now-incorrect calculate_exposure_times static method. Fixes an in-place mutation bug in calculate_histogram_sums. Completes HistogramL2.__init__ with all L2 averages and std devs computed over good-time blocks only, with correct shapes for scalar (keepdims=True) and vector ([np.newaxis, :]) fields. Converts return_good_times to a @staticmethod.

  • glows_l2.py: Removes logic that was moved into HistogramL2.__init__.

  • test_glows_l2_data.py: New test file covering DailyLightcurve (photon flux, flux uncertainty, zero-exposure bins, number of bins) and HistogramL2.return_good_times.

  • test_glows_l2.py: Updates test_generate_l2 assertions to match corrected output values; removes test_exposure_times which tested the removed calculate_exposure_times method.

Testing

  • 6 new unit tests added in test_glows_l2_data.py
  • Existing integration tests in test_glows_l2.py updated to reflect corrected calculation behavior

Tests were generated with Claude but checked by hand. The averaging steps in init were also done with AI. Nothing else was completed with AI, although it was checked against the validation scripts with Claude.

Completes tickets: #2367

Also fixes an un-ticketed bug with exposure time calculation

@maxinelasp maxinelasp added this to the February 2026 milestone Feb 18, 2026
@maxinelasp maxinelasp self-assigned this Feb 18, 2026
@maxinelasp maxinelasp added this to IMAP Feb 18, 2026
Copy link
Contributor

@tech3371 tech3371 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

# A good time is where all the active flags are equal to one.
# Here, we mask the active indices using active_flags, and then return the times
# where all the active indices == 1.
good_times = np.where(np.all(flags[:, active_flags == 1] == 1, axis=1))[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know enough details here but feel like it could be improved. But I don't have suggestions yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants

Comments