SWAPI: Flag alpha fits with out-of-range proton-to-alpha peak ratios - #168
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a peak-energy ratio guard to reject implausible SWAPI alpha fits as BAD_FIT.
Changes:
- Computes modeled proton/alpha peaks across the coarse ESA grid.
- Rejects ratios outside 1.7–2.3.
- Adds regression coverage and documentation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
fit_solar_wind_alpha_model.py |
Implements peak-ratio validation. |
test_fit_solar_wind_alpha_model.py |
Tests upper-bound rejection. |
alpha-sw.md |
Documents the quality check. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
It is not necessary to calculate the model rates for this. Simply calculate the approximate location of the peak based on the magnitude of the bulk velocity vsctor in the same place the bad fit flag is currently computed. The energy per charge is (.5 mv^2 / q). Since you need only calculate the ratio the actual calculation is even simpler and can be derived quire straightforwardly. With this approach it should only be a few lines of code at most.
0fb6384 to
fe02cc2
Compare
…Hameed's comments
|
@hafarooki thank you for the comments! I have updated the code. The main modification is now much, much shorter, with the bulk of the added lines coming from testing. Please take another look when you have a chance. |
|
Regarding the axis=-1: may not be necessary because the function uses raw return statements suggesting that there is not a timeseries and it is just a vector of shape (3,). |
|
It is not wrong, though, and would prevent errors if that changes at some point. I'd be happy to remove it if preferred. |
|
Before merging I would suggest validation testing that with this change the time I pointed out in that ticket gets flagged. I would also request @bishwassth to comment on whether the limit should be 1.7 or some other number |
Change Summary
Closes #146.
Overview
Flag alpha solar-wind fits as
BAD_FITwhen the approximate fitted alpha-to-proton peak energy ratio is below 1.7. Calculate the ratio analytically from the fitted bulk velocity magnitudes, without evaluating additional model-rate curves.File changes
fit_solar_wind_alpha_model.py: Calculate the approximate peak-energy ratio asBAD_FIT.test_fit_solar_wind_alpha_model.py: Verify that ratios below 1.7 are rejected.alpha-sw.md: Document the explicit 1.7 lower threshold.Testing
The focused alpha-fit unit test suite passes:
uv run python -m unittest \ tests.swapi.l3a.science.solar_wind.alpha.test_fit_solar_wind_alpha_modelresults in: