Weight ctis.regrid by the voxel volume to conserve the integral - #22
Merged
Conversation
Multiply each input voxel by its volume (via `SpectralPositionalVectorArray.volume_cell`) before the two-stage conservative regridding and divide by the output voxel volume afterward, so `ctis.regrid` preserves the integral of the field and treats `values_input` as a density (such as a spectral radiance) rather than a per-voxel total. Update the test to check integral conservation and bump the named-arrays pin to ~=2.3. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CtdKmedevWkDab6BWupXqQ
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 23 23
Lines 697 704 +7
=========================================
+ Hits 697 704 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes
ctis.regridintegral-conserving (density-preserving) instead of sum-conserving.Each input voxel is weighted by its volume — the wavelength bin width times the field-pixel area, from the new
SpectralPositionalVectorArray.volume_cell(named-arrays 2.3) — before the two-stage conservative regridding, and the output is divided by the output voxel volume. Sovalues_inputis treated as a density (e.g. a spectral radiance), and a resampled uniform field stays uniform.Notes
named-arrays~=2.2→~=2.3forvolume_cell.Tests
ctis/_regrid_test.py: refine and coarsen cases, checking shape, finiteness, and integral conservation. Verified against a clean/releasedregridding(conservation is exact there).🤖 Generated with Claude Code
https://claude.ai/code/session_01CtdKmedevWkDab6BWupXqQ