Skip to content

Commit

Permalink
Create Ultra pset energy bins (#811)
Browse files Browse the repository at this point in the history
* pset energy bins
  • Loading branch information
laspsandoval authored Sep 9, 2024
1 parent 0a9830d commit 7b9395b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
19 changes: 19 additions & 0 deletions imap_processing/tests/ultra/unit/test_ultra_l1c_pset_bins.py
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)
29 changes: 29 additions & 0 deletions imap_processing/ultra/l1c/ultra_l1c_pset_bins.py
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

0 comments on commit 7b9395b

Please sign in to comment.