diff --git a/slic/core/acquisition/broker/brokerclient.py b/slic/core/acquisition/broker/brokerclient.py index 26486eb1..d9e6276b 100644 --- a/slic/core/acquisition/broker/brokerclient.py +++ b/slic/core/acquisition/broker/brokerclient.py @@ -10,6 +10,7 @@ from slic.utils import xrange, tqdm_mod, tqdm_sleep from slic.utils import json_validate from .brokerconfig import BrokerConfig, flatten_detectors +from .pids import aligned_pid_and_n, align_pid_left, align_pid_right from .tools import get_current_pulseid, get_endstation @@ -296,35 +297,6 @@ class BrokerError(Exception): -def aligned_pid_and_n(start, n, rm): - start, stop = aligned_pids(start, n, rm) - return start, stop - start - -def aligned_pids(start, n, rm): - """ - return start/stop pids aligned to rep rate - """ -# start -= 1 #TODO: count from zero? - block_start = (start // rm) + 1 # calc block where start is in, then take following block - block_stop = block_start + n - start = block_start * rm # adjust to actual rep rate (example: recording is at 100 Hz; for a 50 Hz device, 2*n pulses need to be recorded to get n pulses with that device) - stop = block_stop * rm #TODO: check whether upper boundary is excluded (otherwise -1 here) - return int(start), int(stop) - - -def align_pid_left(pid, rm): - return align_pid(pid, rm, 0) - -def align_pid_right(pid, rm): - return align_pid(pid, rm, 1) - -def align_pid(pid, rm, block_offset=0): - block = pid // rm - block += block_offset - return block * rm - - - def wait_for_files(label, fnames): with yaspin(Spinners.clock, text=f"elapsed time: {label}", timer=True) as sp: while True: diff --git a/slic/core/acquisition/broker/pids.py b/slic/core/acquisition/broker/pids.py new file mode 100644 index 00000000..43341106 --- /dev/null +++ b/slic/core/acquisition/broker/pids.py @@ -0,0 +1,30 @@ + +def aligned_pid_and_n(start, n, rm): + start, stop = aligned_pids(start, n, rm) + return start, stop - start + +def aligned_pids(start, n, rm): + """ + return start/stop pids aligned to rep rate + """ +# start -= 1 #TODO: count from zero? + block_start = (start // rm) + 1 # calc block where start is in, then take following block + block_stop = block_start + n + start = block_start * rm # adjust to actual rep rate (example: recording is at 100 Hz; for a 50 Hz device, 2*n pulses need to be recorded to get n pulses with that device) + stop = block_stop * rm #TODO: check whether upper boundary is excluded (otherwise -1 here) + return int(start), int(stop) + + +def align_pid_left(pid, rm): + return align_pid(pid, rm, 0) + +def align_pid_right(pid, rm): + return align_pid(pid, rm, 1) + +def align_pid(pid, rm, block_offset=0): + block = pid // rm + block += block_offset + return block * rm + + +