Skip to content

Add NOAA flare catalogue ingestion and ΔΦ(t) precursor-window evaluation - #38

Merged
dfeen87 merged 2 commits into
mainfrom
copilot/add-noaa-flare-ingestion-function
Mar 14, 2026
Merged

dfeen87 merged 2 commits into
mainfrom
copilot/add-noaa-flare-ingestion-function

Conversation

Copilot AI commented Mar 14, 2026 •

Copy link
Copy Markdown
Contributor

Extends the GOES-18 analysis pipeline with a flare-prediction evaluation layer: ingests a NOAA flare catalogue (or auto-detects events from XRS peaks), evaluates the ΔΦ(t) instability operator in a 6–24 h precursor window, and computes ROC/AUC, lead-time distribution, and false-alarm/missed-event rates.

New functions

  • shared/data_loader.load_noaa_flare_catalogue(path, *, start, end) — CSV/JSON ingestion with UTC normalisation, onset_time → time_begin fallback, and interval filtering.
  • shared/event_evaluation.align_flare_onsets(flare_df, delta_phi_df) — nearest-sample alignment of flare onset times onto the ΔΦ(t) grid; returns aligned_time + delta_phi_at_onset.
  • analysis/precursor_evaluation.evaluate_precursor_window(...) — per-flare extraction of [onset − 24 h, onset − 6 h) window, boolean threshold indicators, window stats, and full ROC/AUC/lead-time output via existing helpers.

New experiment script

experiments/eval_flare_catalogue.py — self-contained pipeline:

  1. Reads noaa_goes18_xrs_1m.csv.zip; strips fill values (flux ≤ 0).
  2. Computes ΔΦ(t) from log₁₀-normalised XRS long-wave flux (backward diff, Δt = 1 h).
  3. Loads an external catalogue via --catalogue, or auto-detects C-class events from smoothed XRS local maxima with a 2 h minimum separation.
  4. Runs evaluate_precursor_window over θ ∈ [0.01, 0.90] (50 points).
  5. Saves results/flare_catalogue_eval.json, flare_catalogue_roc.png, flare_catalogue_lead_times.png, flare_catalogue_delta_phi.png.
# with auto-detected flares
python experiments/eval_flare_catalogue.py --months 1

# with a real NOAA catalogue
python experiments/eval_flare_catalogue.py --catalogue /path/to/goes_flares.csv --months 3

Results (January 2024, 67 auto-detected events)

Metric Value
AUC 0.7875
TPR at θ = 0.19 0.881
FPR at θ = 0.19 0.138
FAR at θ = 0.46 (mid) 0.009
MER at θ = 0.46 (mid) 0.836
Median lead time 11.34 h

Documentation

Section 12 of ANALYSIS_AND_VALIDATION.md (§12.1–12.5) populated with catalogue ingestion description, precursor-window definition, ΔΦ(t) signal statistics, ROC/AUC table, lead-time distribution, and known limitations (circular evaluation, single channel, short interval).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • services.swpc.noaa.gov
    • Triggering command: /usr/bin/python python -m pytest test/ --ignore=test/runtests.jl --ignore=test/test_math_utils.jl --ignore=test/test_spiral_time.jl --ignore=test/test_energy_transfer.jl --ignore=test/test_topology.jl --ignore=test/test_release_events.jl -x --tb=short -q (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…Section 12 results

Co-authored-by: dfeen87 <158860247+dfeen87@users.noreply.github.com>
Copilot AI changed the title [WIP] Add NOAA flare catalogue ingestion function to GOES-18 pipeline Add NOAA flare catalogue ingestion and ΔΦ(t) precursor-window evaluation Mar 14, 2026
Copilot AI requested a review from dfeen87 March 14, 2026 12:00
@dfeen87
dfeen87 marked this pull request as ready for review March 14, 2026 12:02
Copilot AI review requested due to automatic review settings March 14, 2026 12:02
@dfeen87
dfeen87 merged commit 859c01b into main Mar 14, 2026
6 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@dfeen87
dfeen87 deleted the copilot/add-noaa-flare-ingestion-function branch March 14, 2026 12:02

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 PR adds a flare-prediction evaluation layer to the GOES-18 analysis pipeline. It introduces NOAA flare catalogue ingestion, flare onset alignment onto the ΔΦ(t) grid, and a precursor-window evaluation function that computes ROC/AUC, lead-time distributions, and false-alarm/missed-event rates. A self-contained experiment script ties the pipeline together and produces JSON metrics and plots.

Changes:

  • New shared utilities: load_noaa_flare_catalogue (CSV/JSON ingestion with UTC normalization and fallback column resolution) and align_flare_onsets (nearest-sample alignment of flare onsets onto the ΔΦ(t) timeline).
  • New evaluate_precursor_window function in the analysis layer that extracts per-flare [onset−24h, onset−6h) windows, computes boolean threshold indicators, window stats, and delegates to existing ROC/AUC/lead-time helpers.
  • New experiment script eval_flare_catalogue.py and expanded documentation in §12 of ANALYSIS_AND_VALIDATION.md.

Reviewed changes

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

Show a summary per file
File Description
shared/data_loader.py Adds load_noaa_flare_catalogue for CSV/JSON ingestion with UTC normalization, column fallback, and interval filtering.
shared/event_evaluation.py Adds align_flare_onsets for nearest-sample alignment of flare onset times onto the ΔΦ(t) grid.
analysis/precursor_evaluation.py Adds evaluate_precursor_window for per-flare precursor-window extraction and evaluation with threshold sweep.
experiments/eval_flare_catalogue.py New self-contained pipeline script: loads XRS data, computes ΔΦ(t), detects/loads flares, evaluates precursor windows, and saves metrics/plots.
ANALYSIS_AND_VALIDATION.md Populates §12.1–12.5 with detailed methodology, results tables, and limitations.

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

You can also share your feedback on Copilot code review. Take the survey.

return None
try:
ts = pd.Timestamp(value)
if ts is pd.NaT:
Comment on lines +174 to +183
def evaluate_precursor_window(
*,
feature_df: pd.DataFrame,
flare_df: pd.DataFrame,
time_col: str = "time",
value_col: str = "delta_phi",
pre_window_start_hours: float = 24,
pre_window_end_hours: float = 6,
thresholds: "np.ndarray | list[float]",
) -> "dict[str, pd.DataFrame | np.ndarray | float]":
Comment on lines +295 to +300
def align_flare_onsets(
flare_df: pd.DataFrame,
delta_phi_df: pd.DataFrame,
*,
time_col: str = "time",
) -> pd.DataFrame:
Comment thread shared/data_loader.py
Comment on lines +769 to +774
def load_noaa_flare_catalogue(
path,
*,
start=None,
end=None,
) -> pd.DataFrame:
--months N
Number of months of GOES-18 data to analyse (default: 1).
--threshold-lo FLOAT
Lower bound of the threshold sweep (default: 0.1).
Comment on lines +305 to +313
# --- Standard event-based metrics (full pre_window_start_hours window) ---
threshold_metrics = compute_threshold_metrics(signal_df, flare_df, thresholds_arr)
fpr_sorted, tpr_sorted, thresholds_sorted = compute_roc(
signal_df, flare_df, thresholds_arr
)
auc_value = (
compute_auc(fpr_sorted, tpr_sorted) if fpr_sorted.size >= 2 else np.nan
)
lead_times = compute_lead_times(signal_df, flare_df)
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