Skip to content

Commit 3579686

Browse files
guillaumegrolleronguillaume.grolleron
andauthored
New implementation of the nectarchain module (#82)
* clean commit history : -update SPE fit parameters initialization following updates of the ctapipe extractors -improve the limits of generated charge histogram plots * test script * add method to sort WaveformsContainer and ChargesContainer following events_id * -waveformContainer contructor from event list * user script for test ggroller * change values of pp and n in fit parameters file by median * improve test * repare test * reduce pvalue digit in label * -add time counter to SPE fit * add possibility to freez parameters into minuit * begin : redesign of the SPE fit class to speed up * new skeleton for the calibration pipeline : -container module for the data structure (to be extend) -makers module to make the computation of calibration quantities on the data structure * mothers class for the maker module * mother class for the gain makers * unchanged modeuls for the new structure * FlatFieldSPEMaker implementation * photostatistic maker (not re-implemented yet) * implementation of the FFSPE fit for single run with n and p' fixed * implementation of FF SPE gain maker at nominal voltage + update of user script * bugfix user script updated : FF SPE at VVH voltage (ie for single run) * update for nominal voltage data FF SPE fit from HHV pre-computed one * -bugfix update for nominal FF SPE fit * put I/O method in mother class * add low gain in contructor (only high gain before) * typo bugfiox * move gain utils in one single folder * bugfix nominal voltage fit the fitting process continues although the initial parameters computation failed * Photostatistic implementation done * cleaning : import, type, etc * remove old SPE fit implementation * makers : core module enhancement (docstrings, unit test) * cleaning * moving container and makers in top of calibration directory * folder restructuring * cleaning after the restructuration * unit test for chargecontainer * test extractor utlis * unit test CalibrationMaker and GainMakers * unit test flatfieldSPEMakers * unit test implementation follow up * mv wavefomrs in makers * code into WavefomContainers split into 2 parts : one for the data format, the other for the computation * move charge container into makers module * creation of mother class to charge and waveform container * follow up : factorisation waveforms and chargs Makers * display module * finalisation of the refactorisation of the waveformsMaker chargesMaker implementation * ChargesContainers I/O cleaning unit test for WaveformsMaker and ChargesMaker * update calibration class following COntainers changes * bugfix according to unit tests * docstrings container + unit test * make container module visible * small bugfix + fix unit test for makers * docstrings makers module * follow pre-commit hook * set Dirac import into methods which need it * first step to reimplement following ctapipe Tool and Components framework * -removed the I/O method for containers -> now we will use ctapipe HDF5TableWriter and Reader -creation of recursive containers * -adapt charges extraction makers and waveform extraction makers with the ctapipe.Tool framework * -creation of the component module, which inherits from ctapipe.component -implementation of the NectarCAMComponent, the base class for nectrachain components, - implementation of the ChargesComponent and WaveformsComponent * -preliminary tuto script to extract charges or waveforms using Tool and Component classes * renaming code name for gain computation (makers->Component) * move SPE code in component module * move SPE algo in utlis * renaming spe module * changement yaml parameters spe location * mv spe algo in component main folder * move utils outside of the sub-modules * charge and waveforms extraction with ctapip Tool * container for charges and waveforms * fast eventsource reader (30% faster) * gain container to store interesting values computed from gain calibration * for spe algorithm Component * calibration module * calibration module : SPE fit implementation * add useful method * utils for nectarchain * script to load waveforms and extract charge updated * renaming code name for gain computation (makers->Component) * move SPE code in component module * move SPE algo in utlis * renaming spe module * changement yaml parameters spe location * mv spe algo in component main folder * move utils outside of the sub-modules * charge and waveforms extraction with ctapip Tool * container for charges and waveforms * fast eventsource reader (30% faster) * gain container to store interesting values computed from gain calibration * for spe algorithm Component * calibration module * calibration module : SPE fit implementation * add useful method * utils for nectarchain * script to load waveforms and extract charge updated * cleaning * container namesape + other * waveforms from hdf5 method * SPE fit for flatfirld runs implementation * start of reimplementatuion of phtotstat method * follow up photostat implementation * clean way to manage the work done on reduced part of the raw data (with max_events parameter) * forgotten in last commit.. * photostatistic re-implemented * same * typo changes * circular import bugfix * imprve log * bugfix output filename * bugfix I/O + maxevents read written now in output file + data management with max_events parameter * some bugfix * cleaning and improvement of the data management * updates of scripts * remove old unit test * update runs of interest * bugfix : -find SPE data -containers data with maxevents * load Containers : now if it is splited in slices, will return a generator to only load the slices one by one during execution -> reduce the RAM needed * bugfix computation of convergence rate * -add classes to perform SPE fit directly at nominal voltage (config files) -change SPE fit plotting matplotlib -> pyqtgraph to speed up the plots generation * -ignore png files -bugfix : check valididty of container before to write when finishing component * update scripts * tuto for : -creation of your own component and tool -SPE tools use -exctraction of waveforms and chgares with tools and components. * -fix issue to access component defined outside of the nectarchain module -typo fix -overwrite argument of tool better defined * bugfix : issue mentioned by @jlenain in #82. Now the read of a container will always return a generator, which can be ciomposed by only one item. * update with pre-commit hooks * ignore notebooks * rm notebook --------- Co-authored-by: guillaume.grolleron <ggroller@lpnhe.in2p3.fr>
1 parent c4a163d commit 3579686

61 files changed

Lines changed: 4214 additions & 2411 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ src/nectarchain/user_scripts/**/test
9292
**.log
9393
**.pdf
9494
**.csv
95+
**.png
9596

9697
#VScode
9798
.vscode/
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# ---
2+
# jupyter:
3+
# jupytext:
4+
# text_representation:
5+
# extension: .py
6+
# format_name: percent
7+
# format_version: '1.3'
8+
# jupytext_version: 1.14.6
9+
# kernelspec:
10+
# display_name: nectarchain
11+
# language: python
12+
# name: python3
13+
# ---
14+
15+
# %%
16+
import logging
17+
import os
18+
import pathlib
19+
20+
logging.basicConfig(
21+
format="%(asctime)s %(name)s %(levelname)s %(message)s", level=logging.INFO
22+
)
23+
log = logging.getLogger(__name__)
24+
log.handlers = logging.getLogger("__main__").handlers
25+
26+
from nectarchain.makers.calibration import (
27+
FlatFieldSPEHHVStdNectarCAMCalibrationTool,
28+
FlatFieldSPENominalStdNectarCAMCalibrationTool,
29+
)
30+
31+
# %%
32+
run_number = 3936
33+
34+
# %%
35+
36+
# !ls -lh $NECTARCAMDATA/runs/*
37+
38+
# %%
39+
tool = FlatFieldSPENominalStdNectarCAMCalibrationTool(
40+
progress_bar=True,
41+
method="LocalPeakWindowSum",
42+
extractor_kwargs={"window_width": 12, "window_shift": 4},
43+
multiproc=True,
44+
nproc=10,
45+
run_number=run_number,
46+
max_events=10000,
47+
log_level=20,
48+
reload_events=True,
49+
# events_per_slice = 200,
50+
asked_pixels_id=[52, 48],
51+
output_path=pathlib.Path(os.environ.get("NECTARCAMDATA", "/tmp"))
52+
/ "tutorials/"
53+
/ f"SPEfit_{run_number}.h5",
54+
)
55+
56+
# %%
57+
tool
58+
59+
# %%
60+
tool.initialize()
61+
62+
# %%
63+
tool.setup()
64+
65+
# %%
66+
tool.start()
67+
68+
# %%
69+
output = tool.finish(return_output_component=True, display=True, figpath=os.getcwd())
70+
output
71+
72+
# %%
73+
output[0].resolution
74+
75+
# %%

0 commit comments

Comments
 (0)