Skip to content

Add HexagdlyMapper for hex-native grid mapping - #192

Open
YugnatD wants to merge 1 commit into
cta-observatory:mainfrom
YugnatD:add-hexagdly-mapper
Open

Add HexagdlyMapper for hex-native grid mapping#192
YugnatD wants to merge 1 commit into
cta-observatory:mainfrom
YugnatD:add-hexagdly-mapper

Conversation

@YugnatD

@YugnatD YugnatD commented Aug 28, 2026

Copy link
Copy Markdown

Summary

Adds HexagdlyMapper, an ImageMapper that maps a hexagonal camera image onto the exact offset-column grid keras-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

  • New TestHexagdlyMapperSpecific class in test_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 image
  • Full test_image_mapper.py suite passes (58/58)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant