Files
aare/python/benchmarks/remap_benchmark.py
138945f5b8
Run tests using data on local RHEL8 / build (push) Successful in 3m53s
Build on RHEL8 / build (push) Successful in 4m19s
Build on RHEL9 / build (push) Successful in 4m45s
Build on local RHEL8 / build (push) Successful in 3m37s
Dev/strixels/remap_simple (#286)
Refactor of PR #275, branching off dev/strixels/remap
The structure has been simplified.

Basic structure:
- defs -> pure data structures (geometry, config structs, placement,
remapping result)
- config -> hardcoded sensor definitions (e.g. Jungfrau iLGAD
multipitch, 25um pitch group, ...)
- algo -> generic remapping algorithms
- generate -> user-facing convenience functions (i.e. generate a map for
Jungfrau iLGAD multipitch sensor 25um pitch group)

So far, only a few basic sensor configurations are implemented. But in
principle, it should be straight forward to implement a new one by
1. Adding geometry definitions in config
2. Adding generate function

We could also discuss a further simplification making the sensor
definitions types, i.e. instead of
```
auto map = jungfrau_ilgad_singlechip_25um_strixel_map(roi, sensor_placement);
```
we template on the sensor type
```
auto map = generate_maps<Jungfrau_iLGAD_MP25>(roi, sensor_placement);
```
Then adding a new sensor just requires a new type definition.

---------

Co-authored-by: AliceMazzoleni99 <alice.mazzoleni@psi.ch>
Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
2026-11-13 18:56:39 +01:00

37 lines
1.0 KiB
Python

import numpy as np
import pyperf
from aare import strixelremap
def numpy_take(input, order_map, output):
"""Remap input array to output array using order_map with numpy.take"""
not_mapped = order_map == -1
np.take(input, order_map, out=output)
output[not_mapped] = 0
def benchmark_remap():
strixelpixelmap = strixelremap.jungfrau_ilgad_singlechip_25um_strixel_map(user_roi = strixelremap.Chip1.placement_on_module, placement = strixelremap.Chip1)
order_map = strixelpixelmap.map
user_roi_height = strixelremap.Chip1.placement_on_module.height
user_roi_width = strixelremap.Chip1.placement_on_module.width
data = np.random.randint(0, 2**16, size=(user_roi_height, user_roi_width)).astype(np.uint16)
output = np.empty(order_map.shape, dtype=data.dtype)
runner = pyperf.Runner()
runner.bench_func("apply_remap", strixelremap.apply_remap, data, order_map, output)
runner.bench_func("numpy_take", numpy_take, data, order_map, output)
if __name__ == "__main__":
benchmark_remap()