Add NOAA flare catalogue ingestion and ΔΦ(t) precursor-window evaluation - #38
Conversation
…Section 12 results Co-authored-by: dfeen87 <158860247+dfeen87@users.noreply.github.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
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) andalign_flare_onsets(nearest-sample alignment of flare onsets onto the ΔΦ(t) timeline). - New
evaluate_precursor_windowfunction 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.pyand expanded documentation in §12 ofANALYSIS_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: |
| 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]": |
| def align_flare_onsets( | ||
| flare_df: pd.DataFrame, | ||
| delta_phi_df: pd.DataFrame, | ||
| *, | ||
| time_col: str = "time", | ||
| ) -> pd.DataFrame: |
| 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). |
| # --- 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) |
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_beginfallback, 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; returnsaligned_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:noaa_goes18_xrs_1m.csv.zip; strips fill values (flux ≤ 0).--catalogue, or auto-detects C-class events from smoothed XRS local maxima with a 2 h minimum separation.evaluate_precursor_windowover θ ∈ [0.01, 0.90] (50 points).results/flare_catalogue_eval.json,flare_catalogue_roc.png,flare_catalogue_lead_times.png,flare_catalogue_delta_phi.png.Results (January 2024, 67 auto-detected events)
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/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.