Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade nectarchain to ctapipe 0.19 #68

Merged
merged 19 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
ctapipe-version: [v0.12.0]
python-version: [3.8, 3.9, "3.10", 3.11]
ctapipe-version: [v0.19.1]

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ conda env config vars set X509_CERT_DIR=${CONDA_PREFIX}/etc/grid-security/certif
# The following is needed for the environment variables, used for DIRAC configuration, to be available:
mamba deactivate
mamba activate nectarchain
pip install CTADIRAC COMDIRAC
pip install CTADIRAC
dirac-configure
```

Expand Down
7 changes: 2 additions & 5 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ channels:
- default
- conda-forge
dependencies:
- python=3.8 # nail the python version, so conda does not try upgrading / downgrading
- ctapipe=0.12
- python=3.11
- ctapipe=0.19.1
- ctapipe-io-nectarcam
- numpy=1.22 # higher versions >=1.23 don't work due to astropy4 dependency in ctapipe0.12
- jupyterlab
- protozfits=2.0
- pytables>=3.7
- pytest-runner
- pip
- pandas
Expand Down
56 changes: 30 additions & 26 deletions notebooks/Access NectarCAM data using DIRAC API.ipynb

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ classifiers = [
"Topic :: Scientific/Engineering :: Physics",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11"
]
requires-python = "~=3.8"
requires-python = ">=3.8"
dependencies = [
"astropy~=4.2",
"ctapipe~=0.12",
"browser_cookie3",
"ctapipe~=0.19",
"ctapipe-io-nectarcam",
"numpy~=1.22",
"protozfits~=2.0",
"tables>=3.7",
"mechanize",
"pandas",
]
dynamic = ["version"]

Expand Down
21 changes: 13 additions & 8 deletions src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@

class NectarGainSPE(ABC) :
_Ncall = 4000000
_Windows_lenght = 40
_Order = 2

Check warning on line 34 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py#L33-L34

Added lines #L33 - L34 were not covered by tests

def __init__(self) :
#set parameters value for fit
self.__parameters = Parameters()
Expand Down Expand Up @@ -104,8 +107,8 @@
charge = charge_in.data[~histo_in.mask]
histo = histo_in.data[~histo_in.mask]

windows_lenght = 80
order = 2
windows_lenght = NectarGainSPE._Windows_lenght
order = NectarGainSPE._Order

Check warning on line 111 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py#L110-L111

Added lines #L110 - L111 were not covered by tests
histo_smoothed = savgol_filter(histo, windows_lenght, order)

peaks = find_peaks(histo_smoothed,10)
Expand All @@ -126,15 +129,16 @@

if log.getEffectiveLevel() == logging.DEBUG :
log.debug('plotting figures with prefit parameters computation')
fig,ax = plt.subplots(1,1,figsize = (8,8))
fig,ax = plt.subplots(1,1,figsize = (5,5))

Check warning on line 132 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py#L132

Added line #L132 was not covered by tests
ax.errorbar(charge,histo,np.sqrt(histo),zorder=0,fmt=".",label = "data")
ax.plot(charge,histo_smoothed,label = f'smoothed data with savgol filter (windows lenght : {windows_lenght}, order : {order})')
ax.plot(charge,weight_gaussian(charge,coeff_mean[0],coeff_mean[1],coeff_mean[2]),label = 'gaussian fit of the SPE')
ax.vlines(coeff_mean[1],0,peak_value,label = f'mean initial value = {coeff_mean[1] - coeff[1]:.0f}',color = "red")
ax.add_patch(Rectangle((coeff_mean[1]-coeff_mean[2], 0), 2 * coeff_mean[2], peak_value_mean,fc=to_rgba('red', 0.5)))
ax.set_xlim([peak_pos - 500,None])

Check warning on line 138 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py#L138

Added line #L138 was not covered by tests
ax.set_xlabel("Charge (ADC)", size=15)
ax.set_ylabel("Events", size=15)
ax.legend(fontsize=15)
ax.legend(fontsize=7)

Check warning on line 141 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py#L141

Added line #L141 was not covered by tests
os.makedirs(f"{os.environ.get('NECTARCHAIN_LOG')}/{os.getpid()}/figures/",exist_ok=True)
fig.savefig(f"{os.environ.get('NECTARCHAIN_LOG')}/{os.getpid()}/figures/initialization_mean_pixel{extension}_{os.getpid()}.pdf")
fig.clf()
Expand All @@ -149,8 +153,8 @@
charge = charge_in.data[~histo_in.mask]
histo = histo_in.data[~histo_in.mask]

windows_lenght = 80
order = 2
windows_lenght = NectarGainSPE._Windows_lenght
order = NectarGainSPE._Order

Check warning on line 157 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py#L156-L157

Added lines #L156 - L157 were not covered by tests
histo_smoothed = savgol_filter(histo, windows_lenght, order)

peaks = find_peaks(histo_smoothed,10)
Expand All @@ -161,15 +165,16 @@

if log.getEffectiveLevel() == logging.DEBUG :
log.debug('plotting figures with prefit parameters computation')
fig,ax = plt.subplots(1,1,figsize = (8,8))
fig,ax = plt.subplots(1,1,figsize = (5,5))

Check warning on line 168 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py#L168

Added line #L168 was not covered by tests
ax.errorbar(charge,histo,np.sqrt(histo),zorder=0,fmt=".",label = "data")
ax.plot(charge,histo_smoothed,label = f'smoothed data with savgol filter (windows lenght : {windows_lenght}, order : {order})')
ax.plot(charge,weight_gaussian(charge,coeff[0],coeff[1],coeff[2]),label = 'gaussian fit of the pedestal, left tail only')
ax.set_xlim([peak_pos - 500,None])

Check warning on line 172 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py#L172

Added line #L172 was not covered by tests
ax.vlines(coeff[1],0,peak_value,label = f'pedestal initial value = {coeff[1]:.0f}',color = 'red')
ax.add_patch(Rectangle((coeff[1]-coeff[2], 0), 2 * coeff[2], peak_value,fc=to_rgba('red', 0.5)))
ax.set_xlabel("Charge (ADC)", size=15)
ax.set_ylabel("Events", size=15)
ax.legend(fontsize=15)
ax.legend(fontsize=7)

Check warning on line 177 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE.py#L177

Added line #L177 was not covered by tests
os.makedirs(f"{os.environ.get('NECTARCHAIN_LOG')}/{os.getpid()}/figures/",exist_ok=True)
fig.savefig(f"{os.environ.get('NECTARCHAIN_LOG')}/{os.getpid()}/figures/initialization_pedestal_pixel{extension}_{os.getpid()}.pdf")
fig.clf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,17 +457,18 @@


if kwargs.get('figpath',0) != 0 :
fig,ax = plt.subplots(1,1,figsize=(8, 6))
fig,ax = plt.subplots(1,1,figsize=(8, 8))

Check warning on line 460 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE_singlerun.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE_singlerun.py#L460

Added line #L460 was not covered by tests
ax.errorbar(charge,histo,np.sqrt(histo),zorder=0,fmt=".",label = "data")
ax.plot(charge,
np.trapz(histo,charge)*MPE2(charge,parameters['pp'].value, parameters['resolution'].value, parameters['mean'].value, parameters['n'].value, parameters['pedestal'].value, parameters['pedestalWidth'].value, parameters['luminosity'].value),
zorder=1,
linewidth=2,
label = f"SPE model fit \n gain : {gain[0] - gain[1]:.2f} < {gain[0]:.2f} < {gain[0] + gain[2]:.2f} ADC/pe, pvalue = {Statistics.chi2_pvalue(ndof,fit.fval)},\n likelihood = {fit.fval:.2f}")
label = f"SPE model fit \n gain : {gain[0] - gain[1]:.2f} < {gain[0]:.2f} < {gain[0] + gain[2]:.2f} ADC/pe,\n pvalue = {Statistics.chi2_pvalue(ndof,fit.fval)},\n likelihood = {fit.fval:.2f}")
ax.set_xlabel("Charge (ADC)", size=15)
ax.set_ylabel("Events", size=15)
ax.set_title(f"SPE fit pixel {it} with pixel_id : {pixels_id}")
ax.legend(fontsize=15)
ax.set_xlim([parameters['pedestal'].value - 6 * parameters['pedestalWidth'].value, None])
ax.legend(fontsize=18)

Check warning on line 471 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE_singlerun.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE_singlerun.py#L470-L471

Added lines #L470 - L471 were not covered by tests
os.makedirs(kwargs.get('figpath'),exist_ok = True)
fig.savefig(f"{kwargs.get('figpath')}/fit_SPE_pixel{pixels_id}.pdf")
fig.clf()
Expand Down Expand Up @@ -503,17 +504,18 @@


if kwargs.get('figpath',0) != 0 :
fig,ax = plt.subplots(1,1,figsize=(8, 6))
fig,ax = plt.subplots(1,1,figsize=(8, 8))

Check warning on line 507 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE_singlerun.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE_singlerun.py#L507

Added line #L507 was not covered by tests
ax.errorbar(self.charge[pixel],self.histo[pixel],np.sqrt(self.histo[pixel]),zorder=0,fmt=".",label = "data")
ax.plot(self.charge[pixel],
np.trapz(self.histo[pixel],self.charge[pixel])*MPE2(self.charge[pixel],self.__pp.value,self.__resolution.value,self.__mean.value,self.__n.value,self.pedestal.value,self.__pedestalWidth.value,self.__luminosity.value),
zorder=1,
linewidth=2,
label = f"SPE model fit \n gain : {self.__gain[pixel,0] - self.__gain[pixel,1]:.2f} < {self.__gain[pixel,0]:.2f} < {self.__gain[pixel,0] + self.__gain[pixel,2]:.2f} ADC/pe, pvalue = {Statistics.chi2_pvalue(ndof,fit.fval)},\n likelihood = {fit.fval:.2f}")
label = f"SPE model fit \n gain : {self.__gain[pixel,0] - self.__gain[pixel,1]:.2f} < {self.__gain[pixel,0]:.2f} < {self.__gain[pixel,0] + self.__gain[pixel,2]:.2f} ADC/pe,\n pvalue = {Statistics.chi2_pvalue(ndof,fit.fval)},\n likelihood = {fit.fval:.2f}")
ax.set_xlabel("Charge (ADC)", size=15)
ax.set_ylabel("Events", size=15)
ax.set_title(f"SPE fit pixel : {pixel} (pixel id : {self.pixels_id[pixel]})")
ax.legend(fontsize=15)
ax.set_xlim([self.pedestal.value - 6 * self.pedestalWidth.value, None])
ax.legend(fontsize=18)

Check warning on line 518 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE_singlerun.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE_singlerun.py#L517-L518

Added lines #L517 - L518 were not covered by tests
os.makedirs(kwargs.get('figpath'),exist_ok = True)
fig.savefig(f"{kwargs.get('figpath')}/fit_SPE_pixel{self.pixels_id[pixel]}.pdf")
fig.clf()
Expand Down Expand Up @@ -571,7 +573,7 @@
log.debug(f"pedestalWidth updated : {pedestalWidth}")
try :
coeff,var_matrix = NectarGainSPE._get_mean_gaussian_fit(charge,histo,f'{it}_nominal')
if coeff[1] - pedestal.value < 0 : raise Exception("mean gaussian fit not good")
if (coeff[1] - pedestal.value < 0) or ((coeff[1] - coeff[2]) - pedestal.max < 0) : raise Exception("mean gaussian fit not good")

Check warning on line 576 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE_singlerun.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE_singlerun.py#L576

Added line #L576 was not covered by tests
mean = parameters['mean']
mean.value = coeff[1] - pedestal.value
mean.min = (coeff[1] - coeff[2]) - pedestal.max
Expand Down Expand Up @@ -785,7 +787,7 @@
super().run(pixel,multiproc,**kwargs)

def _run_obs(self,pixel,prescan = False,**kwargs) :
if self.__nectarGainSPEresult[pixel]['is_valid'].value :
if self.__nectarGainSPEresult[pixel]['is_valid'] :

Check warning on line 790 in src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE_singlerun.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/NectarGain/SPEfit/NectarGainSPE_singlerun.py#L790

Added line #L790 was not covered by tests
kwargs['pixel_id'] = self.pixels_id[pixel]
super()._run_obs(pixel,prescan,**kwargs)
else :
Expand Down
7 changes: 5 additions & 2 deletions src/nectarchain/calibration/container/charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from numba import guvectorize, float64, int64, bool_

from .waveforms import WaveformsContainer,WaveformsContainers
from .utils import CtaPipeExtractor

Check warning on line 37 in src/nectarchain/calibration/container/charge.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/charge.py#L37

Added line #L37 was not covered by tests



Expand Down Expand Up @@ -131,6 +132,7 @@
self.event_id = np.zeros((self.nevents),dtype = np.uint16)
self.trig_pattern_all = np.zeros((self.nevents,self.CAMERA.n_pixels,4),dtype = bool)


@classmethod
def from_waveforms(cls,waveformContainer : WaveformsContainer,method : str = "FullWaveformSum",**kwargs) :
""" create a new ChargeContainer from a WaveformsContainer
Expand Down Expand Up @@ -299,11 +301,12 @@

log.debug(f"Extracting charges with method {method} and extractor_kwargs {extractor_kwargs}")
ImageExtractor = eval(method)(waveformContainer.subarray,**extractor_kwargs)

if channel == constants.HIGH_GAIN:
out = np.array([ImageExtractor(waveformContainer.wfs_hg[i],waveformContainer.TEL_ID,channel) for i in range(len(waveformContainer.wfs_hg))]).transpose(1,0,2)
out = np.array([CtaPipeExtractor.get_image_peak_time(ImageExtractor(waveformContainer.wfs_hg[i],waveformContainer.TEL_ID,channel,waveformContainer.broken_pixels_hg)) for i in range(len(waveformContainer.wfs_hg))]).transpose(1,0,2)

Check warning on line 306 in src/nectarchain/calibration/container/charge.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/charge.py#L306

Added line #L306 was not covered by tests
return out[0],out[1]
elif channel == constants.LOW_GAIN:
out = np.array([ImageExtractor(waveformContainer.wfs_lg[i],waveformContainer.TEL_ID,channel) for i in range(len(waveformContainer.wfs_lg))]).transpose(1,0,2)
out = np.array([CtaPipeExtractor.get_image_peak_time(ImageExtractor(waveformContainer.wfs_lg[i],waveformContainer.TEL_ID,channel,waveformContainer.broken_pixels_lg)) for i in range(len(waveformContainer.wfs_lg))]).transpose(1,0,2)

Check warning on line 309 in src/nectarchain/calibration/container/charge.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/charge.py#L309

Added line #L309 was not covered by tests
return out[0],out[1]
else :
raise ArgumentError(f"channel must be {constants.LOW_GAIN} or {constants.HIGH_GAIN}")
Expand Down
5 changes: 5 additions & 0 deletions src/nectarchain/calibration/container/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from pathlib import Path
from typing import List,Tuple

from ctapipe.containers import DL1CameraContainer

Check warning on line 13 in src/nectarchain/calibration/container/utils.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/utils.py#L13

Added line #L13 was not covered by tests


import logging
logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s %(message)s')
Expand Down Expand Up @@ -180,3 +182,6 @@
else :
return ChainGenerator.chain(list[0],ChainGenerator.chainEventSource(list[1:]))

class CtaPipeExtractor():
def get_image_peak_time(cameraContainer : DL1CameraContainer) :
return cameraContainer.image, cameraContainer.peak_time

Check warning on line 187 in src/nectarchain/calibration/container/utils.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/utils.py#L185-L187

Added lines #L185 - L187 were not covered by tests
51 changes: 43 additions & 8 deletions src/nectarchain/calibration/container/waveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
obj = object.__new__(cls)
return obj

def __init__(self,run_number : int,max_events : int = None,nevents : int = -1,run_file = None):
def __init__(self,run_number : int,max_events : int = None,nevents : int = -1,run_file = None, init_arrays : bool = False):

Check warning on line 43 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L43

Added line #L43 was not covered by tests
"""construtor

Args:
Expand All @@ -52,7 +52,9 @@
"""

self.__run_number = run_number
#gerer ici le fait de traiter plusieurs fichiers ou simplement 1 par 1
self.__run_file = run_file
self.__max_events = max_events

Check warning on line 56 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L55-L56

Added lines #L55 - L56 were not covered by tests

self.__reader = WaveformsContainer.load_run(run_number,max_events,run_file = run_file)

#from reader members
Expand All @@ -68,12 +70,20 @@
#run properties
if nevents != -1 :
self.__nevents = nevents if max_events is None else min(max_events,nevents) #self.check_events()
self.__reader = None

Check warning on line 73 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L73

Added line #L73 was not covered by tests
else :
self.__nevents = self.check_events()
#reload file (bc check_events has drained reader generator)
self.__reader = WaveformsContainer.load_run(run_number,max_events,run_file = run_file)

log.info(f"N_events : {self.nevents}")

if init_arrays :
self.__init_arrays()

Check warning on line 80 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L79-L80

Added lines #L79 - L80 were not covered by tests

def __init_arrays(self,**kwargs) :
log.debug('creation of the EventSource reader')
self.__reader = WaveformsContainer.load_run(self.__run_number,self.__max_events,run_file = self.__run_file)

Check warning on line 84 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L82-L84

Added lines #L82 - L84 were not covered by tests

log.debug("create wfs, ucts, event properties and triger pattern arrays")

Check warning on line 86 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L86

Added line #L86 was not covered by tests
#define zeros members which will be filled therafter
self.wfs_hg = np.zeros((self.nevents,self.npixels,self.nsamples),dtype = np.uint16)
self.wfs_lg = np.zeros((self.nevents,self.npixels,self.nsamples),dtype = np.uint16)
Expand All @@ -86,6 +96,14 @@
#self.trig_pattern = np.zeros((self.nevents,self.npixels),dtype = bool)
#self.multiplicity = np.zeros((self.nevents,self.npixels),dtype = np.uint16)

self.__broken_pixels_hg = np.zeros((self.npixels),dtype = bool)
self.__broken_pixels_lg = np.zeros((self.npixels),dtype = bool)

Check warning on line 100 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L99-L100

Added lines #L99 - L100 were not covered by tests


def __compute_broken_pixels(self,**kwargs) :
log.warning("computation of broken pixels is not yet implemented")
self.__broken_pixels_hg = np.zeros((self.npixels),dtype = bool)
self.__broken_pixels_lg = np.zeros((self.npixels),dtype = bool)

Check warning on line 106 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L103-L106

Added lines #L103 - L106 were not covered by tests

@staticmethod
def load_run(run_number : int,max_events : int = None, run_file = None) :
Expand All @@ -98,8 +116,8 @@
Returns:
List[ctapipe_io_nectarcam.NectarCAMEventSource]: List of EventSource for each run files
"""
generic_filename,filenames = DataManagement.findrun(run_number)
if run_file is None :
generic_filename,_ = DataManagement.findrun(run_number)

Check warning on line 120 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L120

Added line #L120 was not covered by tests
log.info(f"{str(generic_filename)} will be loaded")
eventsource = NectarCAMEventSource(input_url=generic_filename,max_events=max_events)
else :
Expand Down Expand Up @@ -135,6 +153,9 @@
Args:
compute_trigger_patern (bool, optional): To recompute on our side the trigger patern. Defaults to False.
"""
if not(hasattr(self, "wfs_hg")) :
self.__init_arrays()

Check warning on line 157 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L156-L157

Added lines #L156 - L157 were not covered by tests

wfs_hg_tmp=np.zeros((self.npixels,self.nsamples),dtype = np.uint16)
wfs_lg_tmp=np.zeros((self.npixels,self.nsamples),dtype = np.uint16)

Expand All @@ -159,7 +180,7 @@
self.wfs_hg[i] = wfs_hg_tmp
self.wfs_lg[i] = wfs_lg_tmp


self.__compute_broken_pixels()

Check warning on line 183 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L183

Added line #L183 was not covered by tests

#if compute_trigger_patern and np.max(self.trig_pattern) == 0:
# self.compute_trigger_patern()
Expand Down Expand Up @@ -262,6 +283,8 @@
table_trigger = hdul[4].data
cls.trig_pattern_all = table_trigger["trig_pattern_all"]

cls.__compute_broken_pixels()

Check warning on line 286 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L286

Added line #L286 was not covered by tests

return cls


Expand Down Expand Up @@ -345,6 +368,13 @@
res = res.transpose(res.shape[1],res.shape[0],res.shape[2])
return res


@property
def _run_file(self) : return self.__run_file

Check warning on line 373 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L372-L373

Added lines #L372 - L373 were not covered by tests

@property
def _max_events(self) : return self.__max_events

Check warning on line 376 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L375-L376

Added lines #L375 - L376 were not covered by tests

@property
def reader(self) : return self.__reader

Expand All @@ -369,7 +399,12 @@
@property
def run_number(self) : return self.__run_number

@property
def broken_pixels_hg(self) : return self.__broken_pixels_hg

Check warning on line 403 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L402-L403

Added lines #L402 - L403 were not covered by tests

@property
def broken_pixels_lg(self) : return self.__broken_pixels_lg

Check warning on line 406 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L405-L406

Added lines #L405 - L406 were not covered by tests

#physical properties
@property
def multiplicity(self) : return np.uint16(np.count_nonzero(self.trig_pattern,axis = 1))
Expand All @@ -395,7 +430,7 @@
obj = object.__new__(cls)
return obj

def __init__(self,run_number : int,max_events : int = None) :
def __init__(self,run_number : int,max_events : int = None, init_arrays : bool = False) :

Check warning on line 433 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L433

Added line #L433 was not covered by tests
"""initialize the waveformsContainer list inside the main object

Args:
Expand All @@ -407,7 +442,7 @@
self.waveformsContainer = []
self.__nWaveformsContainer = 0
for i,file in enumerate(filenames) :
self.waveformsContainer.append(WaveformsContainer(run_number,max_events=max_events,run_file=file))
self.waveformsContainer.append(WaveformsContainer(run_number,max_events=max_events,run_file=file, init_arrays= init_arrays))

Check warning on line 445 in src/nectarchain/calibration/container/waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/calibration/container/waveforms.py#L445

Added line #L445 was not covered by tests
self.__nWaveformsContainer += 1
if not(max_events is None) : max_events -= self.waveformsContainer[i].nevents
log.info(f'WaveformsContainer number {i} is created')
Expand Down
Loading
Loading