mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-11-30 14:57:48 +01:00
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>
37 lines
1.0 KiB
Python
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()
|