Adding patterntools to slsdet (#1142)

* added patterntools from mythen3tools
* refactored do use implementation from slsSupportLib
This commit is contained in:
Erik Fröjdh
2025-03-17 08:46:26 +01:00
committed by GitHub
parent 5a8213024e
commit 3c2f149c22
12 changed files with 545 additions and 60 deletions

31
python/slsdet/bits.py Normal file
View File

@ -0,0 +1,31 @@
import numpy as np
def setbit(bit, word):
if isinstance(word, np.generic):
mask = word.dtype.type(1)
mask = mask << bit
else:
mask = 1 << bit
return word | mask
def setbit_arr(bit, arr):
arr |= arr.dtype.type(1 << bit)
def clearbit(bit, word):
"""
Clear the bit at position bit in word.
Two paths to avoid converting the types.
"""
if isinstance(word, np.generic):
mask = word.dtype.type(1)
mask = ~(mask << bit)
else:
mask = ~(1 << bit)
return word & mask
def clearbit_arr(bit, arr):
arr &= arr.dtype.type(~(1 << bit))