Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/nectarchain/makers/component/spe/spe_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ class SPEalgorithm(Component):
help="The order of the polynome used in the savgol filter algorithm",
).tag(config=True)

display_toggle = Bool(
False,
read_only=False,
help="Enable/disable display of SPE fit results",
)

def __init__(
self, pixels_id: np.ndarray, config=None, parent=None, **kwargs
) -> None:
Expand Down Expand Up @@ -207,7 +213,10 @@ def read_param_from_yaml(self, parameters_file, only_update=False) -> None:

@staticmethod
def _update_parameters(
parameters: Parameters, charge: np.ndarray, counts: np.ndarray, **kwargs
parameters: Parameters,
charge: np.ndarray,
counts: np.ndarray,
**kwargs,
) -> Parameters:
"""Update the parameters of the FlatFieldSPEMaker class based on the input
charge and counts data.
Expand Down Expand Up @@ -765,7 +774,6 @@ def run_fit(i: int, tol: float) -> dict:
def run(
self,
pixels_id: np.ndarray = None,
display: bool = True,
**kwargs,
) -> np.ndarray:
self.log.info("running maker")
Expand All @@ -790,7 +798,7 @@ def run(
else:
self.log.info("creation of the minuit parameters array")
minuitParameters_array = self._make_minuitParameters_array_from_parameters(
pixels_id=pixels_id, display=display, **kwargs
pixels_id=pixels_id, **kwargs
)

self.log.info("running fits")
Expand Down Expand Up @@ -855,7 +863,7 @@ def run(
res, pixels_id, return_fit_array=True
)

if display:
if self.display_toggle:
self.log.info("plotting")
t = time.time()
self.display(pixels_id, **kwargs)
Expand Down Expand Up @@ -1343,7 +1351,6 @@ def _update_parameters(
def run(
self,
pixels_id: np.ndarray = None,
display: bool = True,
**kwargs,
) -> np.ndarray:
if pixels_id is None:
Expand All @@ -1359,4 +1366,4 @@ def run(
],
)
]
return super().run(pixels_id=pixels_id, display=display, **kwargs)
return super().run(pixels_id=pixels_id, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def main(
):
run_number = kwargs.pop("run_number")
max_events = kwargs.pop("max_events", [None for i in range(len(run_number))])
display = kwargs.pop("display")
if max_events is None:
max_events = [None for i in range(len(run_number))]

Expand Down Expand Up @@ -173,6 +174,7 @@ def main(
run_number=_run_number,
max_events=_max_events,
SPE_result=path[0],
display_toggle=display,
**kwargs,
)
tool.setup()
Expand All @@ -181,7 +183,7 @@ def main(
_figpath = f"{figpath}/{tool.name}_run{tool.run_number}_maxevents{_max_events}_{tool.method}_{str_extractor_kwargs}"
else:
_figpath = f"{figpath}/{tool.name}_run{tool.run_number}_{tool.method}_{str_extractor_kwargs}"
tool.finish(figpath=_figpath, display=args.display)
tool.finish(figpath=_figpath)
except Exception as e:
log.warning(e, exc_info=True)

Expand Down Expand Up @@ -220,7 +222,6 @@ def main(

kwargs.pop("verbosity")
kwargs.pop("figpath")
kwargs.pop("display")
kwargs.pop("HHV_run_number")
# args.HHV_run_number = 3942
# kwargs['run_number'] = [3936]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def main(
):
run_number = kwargs.pop("run_number")
max_events = kwargs.pop("max_events", [None for i in range(len(run_number))])
display = kwargs.pop("display")
if max_events is None:
max_events = [None for i in range(len(run_number))]

Expand All @@ -162,15 +163,16 @@ def main(
progress_bar=True,
run_number=_run_number,
max_events=_max_events,
display_toggle=display,
**kwargs,
)
tool.setup()
if args.reload_events and not (_max_events is None):
_figpath = f"{figpath}/{tool.name}_run{tool.run_number}_maxevents{_max_events}_{tool.method}_{CtapipeExtractor.get_extractor_kwargs_str(tool.method,tool.extractor_kwargs)}"
else:
_figpath = f"{figpath}/{tool.name}_run{tool.run_number}_{tool.method}_{CtapipeExtractor.get_extractor_kwargs_str(tool.method,tool.extractor_kwargs)}"
tool.start(figpath=_figpath, display=args.display)
tool.finish(figpath=_figpath, display=args.display)
tool.start(figpath=_figpath)
tool.finish(figpath=_figpath)
except Exception as e:
log.warning(e, exc_info=True)

Expand Down Expand Up @@ -221,7 +223,6 @@ def main(

kwargs.pop("verbosity")
kwargs.pop("figpath")
kwargs.pop("display")
kwargs.pop("HHV")
kwargs.pop("free_pp_n")

Expand Down