Skip to content

Glows L2 - Apply calibration#2918

Merged
vmartinez-cu merged 9 commits intoIMAP-Science-Operations-Center:devfrom
vmartinez-cu:glows-l2-calibration
Apr 7, 2026
Merged

Glows L2 - Apply calibration#2918
vmartinez-cu merged 9 commits intoIMAP-Science-Operations-Center:devfrom
vmartinez-cu:glows-l2-calibration

Conversation

@vmartinez-cu
Copy link
Copy Markdown
Collaborator

@vmartinez-cu vmartinez-cu commented Apr 3, 2026

This pull request implements the use of a time-dependent calibration factor for GLOWS L2 data processing, ensuring that photon flux and uncertainties are correctly converted to physical units (Rayleighs) using ancillary calibration data. The changes include updating data structures, processing logic, and tests to support calibration lookup and application.

Key changes:

GLOWS L2 Data Processing and Calibration

  • The HistogramL2 and DailyLightcurve classes were updated to accept and use a calibration factor (counts per second per Rayleigh), which is required for correct photon flux and uncertainty calculations. The calibration factor is selected based on the mid-epoch of the observational day using a new static method, get_calibration_factor.

  • The main glows_l2 processing function passes a calibration dataset through to the HistogramL2 data class.

Ancillary Calibration Data Handling

  • The ancillary calibration file reader (convert_file_to_dataset) was refactored to store calibration times as coordinates and ensure the dataset is sorted by time, improving reliability when selecting calibration factors.

Testing Enhancements

  • Test fixtures and test cases were updated to mock calibration datasets and verify that calibration factors are correctly selected and applied in flux and uncertainty calculations.

Closes #2886

@vmartinez-cu vmartinez-cu added enhancement New feature or request Ins: GLOWS Related to the GLOWS instrument Level: L2 Level 2 processing labels Apr 3, 2026
@vmartinez-cu vmartinez-cu added this to IMAP Apr 3, 2026
@vmartinez-cu vmartinez-cu added this to the April 2026 milestone Apr 3, 2026
@vmartinez-cu vmartinez-cu moved this to PR Open in IMAP Apr 3, 2026
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 adds support for applying a time-dependent GLOWS L2 calibration factor (counts/s per Rayleigh) when converting daily lightcurve histogram rates and uncertainties into physical units (Rayleighs), using an ancillary “l2-calibration” dataset.

Changes:

  • Plumbs a calibration dataset through glows_l2()HistogramL2DailyLightcurve and applies it in flux/uncertainty calculations.
  • Adds HistogramL2.get_calibration_factor() to select an appropriate factor based on the mid-epoch of the observation day.
  • Refactors the GLOWS ancillary calibration .dat reader to store calibration times as coordinates and sort by time; updates/extends tests and fixtures accordingly.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
imap_processing/glows/l2/glows_l2.py Passes calibration dataset into HistogramL2 during L2 generation.
imap_processing/glows/l2/glows_l2_data.py Adds calibration-factor selection and applies calibration in DailyLightcurve flux math.
imap_processing/ancillary/ancillary_dataset_combiner.py Refactors l2-calibration .dat ingestion to use start_time_utc as a coordinate and sorts by it.
imap_processing/tests/glows/conftest.py Adds a mock calibration dataset fixture.
imap_processing/tests/glows/test_glows_l2.py Updates tests to provide calibration dataset to glows_l2()/HistogramL2.
imap_processing/tests/glows/test_glows_l2_data.py Adds coverage for calibration-factor selection; updates flux/uncertainty expectations with calibration.
imap_processing/tests/ancillary/test_ancillary_dataset_combiner.py Extends calibration combiner test and asserts coordinate usage/sorting.

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

@vmartinez-cu vmartinez-cu removed this from the April 2026 milestone Apr 6, 2026
@tech3371 tech3371 requested review from subagonsouth April 6, 2026 22:29
Copy link
Copy Markdown
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.

The code changes looks good! Thank you for getting this in so quick!

good_data["epoch"].data, calibration_dataset
)
else:
calibration_factor = None
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 comment about why we can continue if data is empty and calibration can be None? I am guessing, you carry bad data?

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.

Bad data is carried through and processing returns an empty dataset rather than raising an error

Comment on lines +97 to +98
# The mid-epoch is after calibration timestamps,
# so the most recent (1.020) is selected.
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.

(1.020), Is that the calibration data for the mid-time?

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.

Correct! I updated the comments to make this clearer

between_epoch = np.array([369808281184000000])
assert HistogramL2.get_calibration_factor(
between_epoch, mock_calibration_dataset
) == pytest.approx(0.849)
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.

helpful comments

@ahotasu ahotasu added the Phase E: Parent Issue Phase E major task indicator label Apr 7, 2026
@vmartinez-cu vmartinez-cu force-pushed the glows-l2-calibration branch from 3dd30fb to 020c7fe Compare April 7, 2026 16:17
@vmartinez-cu vmartinez-cu merged commit d5f3d78 into IMAP-Science-Operations-Center:dev Apr 7, 2026
14 checks passed
@vmartinez-cu vmartinez-cu deleted the glows-l2-calibration branch April 7, 2026 16:56
@github-project-automation github-project-automation bot moved this from PR Open to Done in IMAP Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Ins: GLOWS Related to the GLOWS instrument Level: L2 Level 2 processing Phase E: Parent Issue Phase E major task indicator

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

GLOWS L2: Apply cps-to-Rayleigh calibration factor using ancillary calibration file

4 participants