Skip to content
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

Define spatial bins for pset #819

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion 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,7 @@

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 @@ -17,3 +17,16 @@ def test_build_energy_bins():
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
Loading