Skip to content
Snippets Groups Projects
Commit 40f1c740 authored by David Hammer's avatar David Hammer
Browse files

Use reconfigure instead of __init__, update main call signature

parent e0dd02d8
No related branches found
No related tags found
1 merge request!1Update the hitfinder for new calng
......@@ -2,7 +2,6 @@ import numpy as np
from karabo.bound import (
Hash,
NODE_ELEMENT,
DOUBLE_ELEMENT,
INT32_ELEMENT,
STRING_ELEMENT,
......@@ -15,31 +14,34 @@ from calng.arbiter_kernels.base_kernel import BaseArbiterKernel
class HitFinderSPI(BaseArbiterKernel):
_node_name = "hitFinderSPI"
def __init__(self, config):
super().__init__(config)
self._use_spi = config.get("SPI")
self._modules = set(eval("np.r_[{}]".format(config.get("modules"))))
self._absolute_threshold = config.get("absoluteThreshold")
self._use_adaptive_threshold = config.get("useAdaptiveThreshold")
self._sigma_level = config.get("sigmaLevel")
self._max_history_length = config.get("maxHistoryLength")
self._cur_history_length = 0
self._history = np.zeros(self._max_history_length, dtype=int)
self._use_sfx = config.get("SFX")
self._min_peaks = config.get("minPeaks")
self._min_r = config.get("minRadius")
self._max_r = config.get("maxRadius")
def reconfigure(self, config):
# note: automatically called in super().__init__
if config.has("SPI"):
self._use_spi = config.get("SPI")
if config.has("modules"):
self._modules = set(eval("np.r_[{}]".format(config.get("modules"))))
if config.has("absoluteThreshold"):
self._absolute_threshold = config.get("absoluteThreshold")
if config.has("useAdaptiveThreshold"):
self._use_adaptive_threshold = config.get("useAdaptiveThreshold")
if config.has("sigmaLevel"):
self._sigma_level = config.get("sigmaLevel")
if config.has("maxHistoryLength"):
self._max_history_length = config.get("maxHistoryLength")
self._cur_history_length = 0
self._history = np.zeros(self._max_history_length, dtype=int)
if config.has("SFX"):
self._use_sfx = config.get("SFX")
if config.has("minPeaks"):
self._min_peaks = config.get("minPeaks")
if config.has("minRadius"):
self._min_r = config.get("minRadius")
if config.has("maxRadius"):
self._max_r = config.get("maxRadius")
@staticmethod
def extend_device_schema(schema, prefix):
(
NODE_ELEMENT(schema)
.key(prefix)
.commit(),
BOOL_ELEMENT(schema)
.key(f"{prefix}.SPI")
.assignmentOptional()
......@@ -118,7 +120,7 @@ class HitFinderSPI(BaseArbiterKernel):
self.geometry.get_pixel_positions() / self.geometry.pixel_size
).astype(int)
def consider(self, train_id, sources, num_frames):
def consider(self, train_id, sources, num_frames, mask, out_hash):
has_xray = self.get_litframe_pattern(train_id, sources, num_frames)
result = Hash()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment