-
Notifications
You must be signed in to change notification settings - Fork 33
I-ALiRT: Create SWAPI count rate optimization function #1705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
torimarbois
merged 12 commits into
IMAP-Science-Operations-Center:dev
from
torimarbois:swapi_count_rate
Jun 18, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4c1f4fc
Create count rate optimization function
torimarbois e3bce8a
Add test data file
torimarbois 97e2202
Address PR comments
torimarbois 234baa5
Address PR comments, update optimization point selection
torimarbois 73c9a2d
Add spacecraft packet processing capability
torimarbois 55a1309
Fix external data call
torimarbois b4bb7e5
Address failing GH tests
torimarbois 7a7e377
Address failing GH tests part 2
torimarbois e1ec51d
Adjust rtol for parameter test
torimarbois 20b6f01
Adjust rtol for parameter test more
torimarbois 34ce34f
Skip failing test caused by mismatched scipy versions
torimarbois faf7121
Fix skip flag
torimarbois File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| """Module for constants and useful shared classes used in I-ALiRT processing.""" | ||
|
|
||
| from dataclasses import dataclass | ||
|
|
||
| import numpy as np | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class IalirtSwapiConstants: | ||
| """ | ||
| Constants for I-ALiRT SWAPI which can be used across different levels or classes. | ||
|
|
||
| Attributes | ||
| ---------- | ||
| BOLTZ: float | ||
| Boltzmann constant [J/K] | ||
| AT_MASS: float | ||
| Atomic mass [kg] | ||
| PROT_MASS: float | ||
| Mass of proton [kg] | ||
| EFF_AREA: float | ||
| Instrument effective area [m^2] | ||
| AZ_FOV: float | ||
| Azimuthal width of the field of view for solar wind [radians] | ||
| FWHM_WIDTH: float | ||
| Full Width at Half Maximum of energy width [unitless] | ||
| SPEED_EW: float | ||
| Speed width of energy passband [unitless] | ||
| """ | ||
|
|
||
| # Scientific constants used in optimization model | ||
| boltz = 1.380649e-23 # Boltzmann constant, J/K | ||
| at_mass = 1.6605390666e-27 # atomic mass, kg | ||
| prot_mass = 1.007276466621 * at_mass # mass of proton, kg | ||
| eff_area = 3.3e-5 * 1e-4 # effective area, meters squared | ||
| az_fov = np.deg2rad(30) # azimuthal width of the field of view, radians | ||
| fwhm_width = 0.085 # FWHM of energy width | ||
| speed_ew = 0.5 * fwhm_width # speed width of energy passband |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
imap_processing/tests/ialirt/test_data/ialirt_test_data.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| Energy [eV/q],Count Rates [Hz],Count Rates Error [Hz] | ||
| 19098.3579,0.00E+00,0 | ||
| 19098.3579,0.00E+00,0 | ||
| 17541.17689,0.00E+00,0 | ||
| 16113.17733,0.00E+00,0 | ||
| 14798.37998,0.00E+00,0 | ||
| 13591.36578,0.00E+00,0 | ||
| 12485.77704,0.00E+00,0 | ||
| 11467.61829,0.00E+00,0 | ||
| 10532.60822,0.00E+00,0 | ||
| 9675.514168,0.00E+00,0 | ||
| 8885.04638,0.00E+00,0 | ||
| 8165.393845,0.00E+00,0 | ||
| 7501.760233,0.00E+00,0 | ||
| 6888.477149,0.00E+00,0 | ||
| 6327.926581,0.00E+00,0 | ||
| 5811.486083,0.00E+00,0 | ||
| 5338.867546,0.00E+00,0 | ||
| 4901.30318,0.00E+00,0 | ||
| 4504.29887,6.00E+00,5.988024 | ||
| 4138.38252,0.00E+00,0 | ||
| 3800.760624,0.00E+00,0 | ||
| 3490.866227,6.00E+00,5.988024 | ||
| 3205.462334,2.40E+01,11.976048 | ||
| 2944.699516,3.00E+01,13.389629 | ||
| 2705.519228,1.20E+01,8.468345 | ||
| 2485.023495,6.00E+00,5.988024 | ||
| 2281.728846,6.00E+00,5.988024 | ||
| 2094.335628,1.80E+01,10.371562 | ||
| 1921.410538,2.58E+02,39.266099 | ||
| 1764.61444,8.70E+02,72.105357 | ||
| 1621.075258,1.37E+03,90.615245 | ||
| 1489.379616,1.25E+03,86.567858 | ||
| 1369.25523,6.72E+02,63.371289 | ||
| 1257.562068,2.46E+02,38.342061 | ||
| 1155.04315,3.00E+01,13.389629 | ||
| 1061.325411,6.00E+00,5.988024 | ||
| 974.875126,0.00E+00,0 | ||
| 895.314188,0.00E+00,0 | ||
| 822.018852,0.00E+00,0 | ||
| 754.982368,0.00E+00,0 | ||
| 693.547324,0.00E+00,0 | ||
| 636.793361,0.00E+00,0 | ||
| 584.81978,0.00E+00,0 | ||
| 537.016673,0.00E+00,0 | ||
| 493.208286,0.00E+00,0 | ||
| 453.103315,0.00E+00,0 | ||
| 416.133867,0.00E+00,0 | ||
| 382.037059,0.00E+00,0 | ||
| 350.921008,0.00E+00,0 | ||
| 322.396008,0.00E+00,0 | ||
| 296.176976,0.00E+00,0 | ||
| 271.952917,0.00E+00,0 | ||
| 249.936708,0.00E+00,0 | ||
| 229.494886,0.00E+00,0 | ||
| 210.757138,0.00E+00,0 | ||
| 193.581931,0.00E+00,0 | ||
| 177.766309,0.00E+00,0 | ||
| 163.295895,0.00E+00,0 | ||
| 150.015166,0.00E+00,0 | ||
| 137.803904,0.00E+00,0 | ||
| 126.579577,0.00E+00,0 | ||
| 116.253172,0.00E+00,0 | ||
| 106.797953,0.00E+00,0 | ||
| 1764.61444,8.70E+02,72.105357 | ||
| 1727.604298,9.18E+02,73.913169 | ||
| 1691.370389,9.66E+02,75.720982 | ||
| 1655.896431,1.01E+03,77.528795 | ||
| 1621.166486,1.06E+03,79.336607 | ||
| 1587.16495,1.11E+03,81.14442 | ||
| 1553.876545,1.16E+03,82.952233 | ||
| 1521.286315,1.21E+03,84.760045 | ||
| 1489.379616,1.25E+03,86.567858 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this the guess here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it should go before the function call. Do you think it should be elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Laura suggested adding a comment explaining where this guess was pulled from in the algorithm document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial guess for the pseudo-speed can be obtained from the energy corresponding to the maximum/peak count rate (energy_peak_rate), i.e.,
speed_guess = sqrt(2 * energy_peak_rate * 1.60218e-19 / proton_mass)/1000 km/s.
It is not straightforward to come up with a good initial guess for the pseudo-density and temperature. Some nominal values, like the following, should be okay.
dens_guess = 5 cm^-3, and
T_guess = 1e5 K.