Add HexagdlyMapper for hex-native grid mapping - #192
Open
YugnatD wants to merge 1 commit into
Open
Conversation
Every existing ImageMapper resamples the hexagonal pixel grid onto an axis-aligned square grid via interpolation. HexagdlyMapper instead places each pixel at its exact nearest cell on the offset-column grid that keras-hexagdly's hexagonal convolution layers expect, so a hex-native CNN (ctlearn-project/ctlearn#286) can consume camera images with no interpolation loss. The offset-column addressing needs a de-rotation step (camera geometries aren't generally axis-aligned) and a chirality search: camera pixel-index handedness isn't universal across geometries -- DigiCam is point-inverted relative to LSTCam/MAGICCam/NectarCam/FlashCam, found via real SST1M simtel data, which the added test suite now covers as a permanent regression case alongside a synthetic mirrored-camera test proving the search is generic, not tuned to any specific camera.
YugnatD
added a commit
to YugnatD/ctlearn
that referenced
this pull request
Aug 28, 2026
- HexGridTransform/HexagdlyMapper moved to dl1_data_handler (cta-observatory/dl1-data-handler#192) -- no longer ctlearn-local. - Replace the standalone HexCNN class with a conv_backend trait ("square"/"hexagdly") on SingleCNN and ResNet directly, so hex support works with a ResNet backbone too, not just SingleCNN. Both residual_block_type variants covered. - Add validate_conv_backend/model_conv_backend (ctlearn/utils.py): the missing image_mapper_type <-> model conv_backend consistency check, wired into train_model.py, predict_model.py, and predict_LST1.py. - keras-hexagdly moves from the optional `hexagdly` extra to a normal dependency, bumped to >=0.4.1 (fixes a real default-initializer scaling bug found while benchmarking this). - Benchmark reworked for the new SingleCNN(conv_backend=...) API. - New tests requiring HexagdlyMapper are skipped (not failed) until dl1-data-handler#192 merges/releases -- they run for real once it does, no further change needed here.
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
Adds
HexagdlyMapper, anImageMapperthat maps a hexagonal camera image onto the exact offset-column gridkeras-hexagdly's hexagonal convolution layers expect, instead of interpolating onto a square grid like the existing mappers do. Split out of ctlearn-project/ctlearn#286 per @tjarkmiener's review there.Test plan
TestHexagdlyMapperSpecificclass intest_image_mapper.py: zero-neighbour-mismatch check against LSTCam/MAGICCam/NectarCam/FlashCam/DigiCam, square-pixel-camera rejection, exact pixel placement, batch/multichannel support (existing generic mapper tests extended to cover it too), a synthetic-chirality-flip test, and a test confirming the origin search runs once at construction, not per imagetest_image_mapper.pysuite passes (58/58)