-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Ultra pset energy bins (#811)
* pset energy bins
- Loading branch information
1 parent
0a9830d
commit 7b9395b
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
imap_processing/tests/ultra/unit/test_ultra_l1c_pset_bins.py
This file contains 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,19 @@ | ||
"Tests bins for pointing sets" | ||
|
||
import numpy as np | ||
|
||
from imap_processing.ultra.l1c.ultra_l1c_pset_bins import build_energy_bins | ||
|
||
|
||
def test_build_energy_bins(): | ||
"""Tests build_energy_bins function.""" | ||
energy_bin_start, energy_bin_end = build_energy_bins() | ||
|
||
assert energy_bin_start[0] == 3.5 | ||
assert len(energy_bin_start) == 90 | ||
assert len(energy_bin_end) == 90 | ||
|
||
# Comparison to expected values | ||
np.testing.assert_allclose(energy_bin_end[0], 3.6795, atol=1e-4) | ||
np.testing.assert_allclose(energy_bin_start[-1], 299.9724, atol=1e-4) | ||
np.testing.assert_allclose(energy_bin_end[-1], 315.3556, atol=1e-4) |
This file contains 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,29 @@ | ||
"""Module to create energy bins for pointing sets.""" | ||
|
||
import numpy as np | ||
|
||
|
||
def build_energy_bins() -> tuple[np.ndarray, np.ndarray]: | ||
""" | ||
Build energy bin boundaries. | ||
Returns | ||
------- | ||
energy_bin_start : np.ndarray | ||
Array of energy bin start values. | ||
energy_bin_end : np.ndarray | ||
Array of energy bin end values. | ||
""" | ||
alpha = 0.05 # deltaE/E | ||
energy_start = 3.5 # energy start for the Ultra grids | ||
n_bins = 90 # number of energy bins | ||
|
||
# Calculate energy step | ||
energy_step = (1 + alpha / 2) / (1 - alpha / 2) | ||
|
||
# Create energy bins. | ||
bin_edges = energy_start * energy_step ** np.arange(n_bins + 1) | ||
energy_bin_start = bin_edges[:-1] | ||
energy_bin_end = bin_edges[1:] | ||
|
||
return energy_bin_start, energy_bin_end |