Fix numba dtypes to avoid unneeded conversions

This commit is contained in:
2025-10-06 09:57:21 +02:00
parent 8f2695f8a7
commit e9b860f7cd
2 changed files with 4 additions and 6 deletions

View File

@@ -16,9 +16,8 @@ from .header import Header
class ExtractWalltime(EventDataAction):
def perform_action(self, dataset: EventDatasetProtocol) ->None:
# TODO: fix numba type definition after refactor
wallTime = extract_walltime(dataset.data.events.tof,
dataset.data.packets.start_index.astype(np.uint64),
dataset.data.packets.start_index,
dataset.data.packets.Time)
logging.debug(f' expending event stream by wallTime')
new_events = append_fields(dataset.data.events, [('wallTime', wallTime.dtype)])
@@ -39,9 +38,8 @@ class AnalyzePixelIDs(EventDataAction):
def perform_action(self, dataset: EventDatasetProtocol) ->None:
d = dataset.data
# TODO: change numba implementation to use native pixelID type
(detZ, detXdist, delta, mask) = filter_project_x(
Detector.pixelLookUp, d.events.pixelID.astype(np.int64), self.yRange[0], self.yRange[1]
Detector.pixelLookUp, d.events.pixelID, self.yRange[0], self.yRange[1]
)
ana_events = append_fields(d.events, [
('detZ', detZ.dtype), ('detXdist', detXdist.dtype), ('delta', delta.dtype)])

View File

@@ -11,7 +11,7 @@ def merge_frames(tof_e, tofCut, tau, total_offset):
tof_e_out[ti] = ((tof_e[ti]-dt)%tau)+total_offset # tof shifted to 1 frame
return tof_e_out
@nb.jit(nb.int64[:](nb.float64[:], nb.uint64[:], nb.int64[:]),
@nb.jit(nb.int64[:](nb.float64[:], nb.uint32[:], nb.int64[:]),
nopython=True, parallel=True, cache=True)
def extract_walltime(tof_e, dataPacket_p, dataPacketTime_p):
# assigning every event the wall time of the event packet (absolute time of pulse ?start?)
@@ -25,7 +25,7 @@ def extract_walltime(tof_e, dataPacket_p, dataPacketTime_p):
return wallTime_e
@nb.jit(nb.types.Tuple((nb.int64[:], nb.float64[:], nb.float64[:], nb.boolean[:]))
(nb.float64[:, :], nb.int64[:], nb.int64, nb.int64),
(nb.float64[:, :], nb.uint32[:], nb.int64, nb.int64),
nopython=True, parallel=True, cache=True)
def filter_project_x(pixelLookUp, pixelID_e, ymin, ymax):
# project events on z-axis and create filter for events outside of y-range