Files
eos/eos/helpers_fallback.py
T
glavic_a 5e96a20f23
Unit Testing / test (3.10) (push) Successful in 54s
Unit Testing / test (3.11) (push) Successful in 49s
Unit Testing / test (3.8) (push) Successful in 50s
Unit Testing / test (3.12) (push) Successful in 55s
Unit Testing / test (3.9) (push) Successful in 54s
Evaluating ToF to extract sub-frames and assign to correct neutron pulse not chopper pulse (#4)
Interpolate neutorn times between chopper pulses and assign by ToF. If ToF too short (long wavelengths from previous pulse), assign them to the previous sub-pulse.

Reviewed with Jochen

Reviewed-on: #4
Co-authored-by: Artur Glavic <artur.glavic@psi.ch>
Co-committed-by: Artur Glavic <artur.glavic@psi.ch>
2026-03-10 15:00:10 +01:00

38 lines
1.5 KiB
Python

"""
Equivalent function as in helpers_numba.py but using just numpy functionality.
"""
import numpy as np
def merge_frames(tof_e, tofCut, tau, total_offset):
# tof shifted to 1 frame
return np.remainder(tof_e-(tofCut-tau), tau)+total_offset
def merge_frames_w_index(tof_e, tofCut, tau, total_offset):
"""
Version of merge frames that also returns a frame index for each pulse:
0 - belongs to the frame it was measured in
-1 - arrived in this frame but belongs to the previous neutron pulse
1 - belongs to the second neutron pulse of the original frame
"""
new_tof = merge_frames(tof_e, tofCut, tau, total_offset)
frame_idx = np.floor_divide(tof_e-tofCut, tau)
return new_tof, frame_idx
def extract_walltime(tof_e, dataPacket_p, dataPacketTime_p):
output = np.empty(np.shape(tof_e)[0], dtype=np.int64)
for i in range(len(dataPacket_p)-1):
output[dataPacket_p[i]:dataPacket_p[i+1]] = dataPacketTime_p[i]
output[dataPacket_p[-1]:] = dataPacketTime_p[-1]
return output
def filter_project_x(pixelLookUp, pixelID_e, ymin, ymax):
(detY_e, detZ_e, detXdist_e, delta_e) = pixelLookUp[np.int_(pixelID_e)-1, :].T
# define mask and filter y range
mask_e = (ymin<=detY_e) & (detY_e<=ymax)
return (detZ_e, detXdist_e, delta_e, mask_e)
def calculate_derived_properties_focussing(tof_e, detXdist_e, delta_e, mask_e,
lmin, lmax, nu, mu, chopperDetectorDistance, hdm):
raise NotImplementedError("Only exists in numba implementation so far.")