Skip to content

Commit

Permalink
Define spatial bins for pset (#819)
Browse files Browse the repository at this point in the history
* Define spatial bins for pset
  • Loading branch information
laspsandoval committed Sep 9, 2024
1 parent b541737 commit 98674c9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
20 changes: 18 additions & 2 deletions imap_processing/tests/ultra/unit/test_ultra_l1c_pset_bins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import numpy as np

from imap_processing.ultra.l1c.ultra_l1c_pset_bins import build_energy_bins
from imap_processing.ultra.l1c.ultra_l1c_pset_bins import (
build_energy_bins,
build_spatial_bins,
)


def test_build_energy_bins():
Expand All @@ -13,7 +16,20 @@ def test_build_energy_bins():
assert len(energy_bin_start) == 90
assert len(energy_bin_end) == 90

# Comparison to expected values
# 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)


def test_build_spatial_bins():
"""Tests build_spatial_bins function."""
az_bin_edges, el_bin_edges = build_spatial_bins()

assert az_bin_edges[0] == 0
assert az_bin_edges[-1] == 360
assert len(az_bin_edges) == 721

assert el_bin_edges[0] == -90
assert el_bin_edges[-1] == 90
assert len(el_bin_edges) == 361
27 changes: 26 additions & 1 deletion imap_processing/ultra/l1c/ultra_l1c_pset_bins.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Module to create energy bins for pointing sets."""
"""Module to create bins for pointing sets."""

import numpy as np

Expand Down Expand Up @@ -27,3 +27,28 @@ def build_energy_bins() -> tuple[np.ndarray, np.ndarray]:
energy_bin_end = bin_edges[1:]

return energy_bin_start, energy_bin_end


def build_spatial_bins(spacing: float = 0.5) -> tuple[np.ndarray, np.ndarray]:
"""
Build spatial bin boundaries for azimuth and elevation.
Parameters
----------
spacing : float, optional
The bin spacing in degrees (default is 0.5 degrees).
Returns
-------
az_bin_edges : np.ndarray
Array of azimuth bin boundary values.
el_bin_edges : np.ndarray
Array of elevation bin boundary values.
"""
# Azimuth bins from 0 to 360 degrees.
az_bin_edges = np.arange(0, 360 + spacing, spacing)

# Elevation bins from -90 to 90 degrees.
el_bin_edges = np.arange(-90, 90 + spacing, spacing)

return az_bin_edges, el_bin_edges

0 comments on commit 98674c9

Please sign in to comment.