Skip to content
Merged
Changes from all commits
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
6 changes: 4 additions & 2 deletions imap_processing/ena_maps/ena_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,11 @@ def downsample_counts(self) -> None:
# Get counts in nested ordering. In nested ordering, the
# pixels that need to be binned together to go from the counts nside to
# the pset nside are contiguous in the array.
# Use nest2ring to get the indices to convert from ring to nest ordering if
# necessary.
if not self.nested:
counts_n = counts[
:, hp.ring2nest(counts_nside, np.arange(counts_n_pix))
:, hp.nest2ring(counts_nside, np.arange(counts_n_pix))
]
Comment on lines 655 to 663
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing test_downsample_counts assertion only checks that the total counts sum is preserved after downsampling, but this bug fix specifically corrects pixel ordering (ring↔nested index mapping). A scrambling regression could still pass the current test; please add a regression assertion that validates per-pixel placement (e.g., construct a synthetic counts array with a unique per-pixel pattern, run downsample_counts, and verify the expected pixel-to-pixel mapping for both ring and nested cases).

Copilot uses AI. Check for mistakes.
else:
counts_n = counts
Expand All @@ -675,7 +677,7 @@ def downsample_counts(self) -> None:
# convert back to ring ordering if necessary and store in the
# downsampled counts array
binned_counts_n = binned_counts_n[
:, hp.nest2ring(self.nside, np.arange(pset_n_pix))
:, hp.ring2nest(self.nside, np.arange(pset_n_pix))
]

self.data["counts"] = xr.DataArray(
Expand Down
Loading