Skip to content

Attempt to add GOES flare detection algo - #210

Draft
samaloney wants to merge 5 commits into
sunpy:mainfrom
samaloney:add-goes-flare-detection
Draft

Attempt to add GOES flare detection algo#210
samaloney wants to merge 5 commits into
sunpy:mainfrom
samaloney:add-goes-flare-detection

Conversation

@samaloney

Copy link
Copy Markdown
Member

PR Description

Attempt to add the "GOES X-ray detection algorithm" defined as

  1. A GOES X-ray flare event starts when 4 consecutive 1-min X-ray flux are above the B1 threshold, i.e. above flux threshold of 10^7 W/m^{-2}` (HEK SWPC list goes down to A1.1 at lest)
  2. all 4 flux values monotonically increase
  3. the fourth flux value is greater than 1.4 times the first value in the sequence of 4 data points.
  4. The event ends when the flux, during the decaying phase, drops below half of the peak flux.

Initially implemented basic version based on based on the above rules but found poor match to events reported in the HEK. These rules are not sufficient to implement a full algotrytm e.g. temporary bump/dips so tired to add some more condition to improve agreement with the HEK SWPC

Open questions:

  • Is the "GOES X-ray flare" list available anywhere else (the modern GOES-R have a list product but that's different as far as I can see)?
  • Is the HEC SWPC list the "GOES X-ray flare list" or altered improved/different?
  • Look more into extra and missed events to see if can work how can improve from visual inspection both groups include non-flares and flares 😞

AI Assistance Disclosure

AI tools were used for:

  • [x ] Code generation (e.g., when writing an implementation or fixing a bug)
  • [x ] Test/benchmark generation
  • [x ] Documentation (including examples)
  • Research and understanding
  • No AI tools were used

Regardless of AI use, the human contributor remains fully responsible for correctness, design choices, licensing compatibility, and long-term maintainability.

@samaloney

Copy link
Copy Markdown
Member Author

Think the test fail is unrelated but due to update to the workflow need to export the coverage file var

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces a GOES XRS flare-detection implementation (with both a “naive” 3-rule interpretation and a refined algorithm intended to better match NOAA/HEK conventions), exposes it through the goes_xrs package API, and adds tests plus a gallery example to compare detections across cadences against HEK.

Changes:

  • Add flare detection algorithms (find_flares, find_flares_naive) and a GOES-specific wrapper (find_goes_flares) with cadence rebinning and quality-flag handling.
  • Fix/guard GOES flux → class conversion for float32 inputs and add regression coverage.
  • Add comprehensive unit tests and an example script comparing detections vs HEK, plus a changelog entry.

Reviewed changes

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

Show a summary per file
File Description
sunkit_instruments/goes_xrs/goes_xrs.py Adjusts flux_to_flareclass() decade computation to avoid float32 lookup issues.
sunkit_instruments/goes_xrs/flare_detection.py New flare detection implementation (naive + refined) and GOES wrapper.
sunkit_instruments/goes_xrs/init.py Re-exports new flare detection API at package level.
sunkit_instruments/goes_xrs/tests/test_goes_xrs.py Adds float32 regression tests for flux_to_flareclass().
sunkit_instruments/goes_xrs/tests/test_flare_detection.py New test suite covering flare detection behavior and parameters.
examples/compare_goes_flare_detection_cadence.py New example comparing flare detections across cadences vs HEK.
changelog/210.feature.rst Documents the newly added flare detection functionality and example.
Comments suppressed due to low confidence (4)

examples/compare_goes_flare_detection_cadence.py:13

  • Typos in the example description (e.g. "periodn", "inxlucig", "windowis").
We will look at an active periodn in May 2024 with many large flare inxlucig
an X-class and also a quiet period during solar minimum, in May 2020, where
the largest flare in the windowis only A-class.

examples/compare_goes_flare_detection_cadence.py:168

  • Typo in the miss-diagnosis label: "too shollow" -> "too shallow".
        return "too shollow"

examples/compare_goes_flare_detection_cadence.py:327

  • Typo in comment: "moth" -> "month".
# if offline run for entire moth or longer

examples/compare_goes_flare_detection_cadence.py:348

  • Typos in comment: "dispear" -> "disappear" and grammar tweak for readability.
# (some of the extra events will dispear if use the extended info in the 1min avg files)

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

Comment thread sunkit_instruments/goes_xrs/tests/test_goes_xrs.py Outdated
Comment thread changelog/210.feature.rst Outdated
Comment thread sunkit_instruments/goes_xrs/goes_xrs.py
Comment thread sunkit_instruments/goes_xrs/flare_detection.py
Comment thread examples/compare_goes_flare_detection_cadence.py Outdated
samaloney and others added 4 commits July 31, 2026 00:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

2 participants