From afda9f7715d6e3c082dbec31f280a88a38d8b036 Mon Sep 17 00:00:00 2001 From: "guillaume.grolleron" Date: Tue, 25 Apr 2023 16:19:39 +0200 Subject: [PATCH 1/2] -change std to FullWavefromSum -typo bugfix --- .../NectarGain/PhotoStat/PhotoStat.py | 6 +++--- .../ggrolleron/load_wfs_compute_charge.py | 21 ++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/nectarchain/calibration/NectarGain/PhotoStat/PhotoStat.py b/src/nectarchain/calibration/NectarGain/PhotoStat/PhotoStat.py index 0d5c3e99..2dae67d5 100644 --- a/src/nectarchain/calibration/NectarGain/PhotoStat/PhotoStat.py +++ b/src/nectarchain/calibration/NectarGain/PhotoStat/PhotoStat.py @@ -27,9 +27,9 @@ class PhotoStatGain(ABC): def _readFF(self,FFRun,maxevents: int = None,**kwargs) : log.info('reading FF data') - method = kwargs.get('method','std') + method = kwargs.get('method','FullWaveformSum') FFchargeExtractorWindowLength = kwargs.get('FFchargeExtractorWindowLength',None) - if method != 'std' : + if method != 'FullWaveformSum' : if FFchargeExtractorWindowLength is None : e = Exception(f"we have to specify FFchargeExtractorWindowLength argument if charge extractor method is not FullwaveformSum") log.error(e,exc_info=True) @@ -68,7 +68,7 @@ def _readFF(self,FFRun,maxevents: int = None,**kwargs) : def _readPed(self,PedRun,maxevents: int = None,**kwargs) : log.info('reading Ped data') - method = 'std'#kwargs.get('method','std') + method = 'FullWaveformSum'#kwargs.get('method','std') if isinstance(PedRun,int) : try : self.Pedcharge = ChargeContainer.from_file(f"{os.environ['NECTARCAMDATA']}/charges/{method}",PedRun) diff --git a/src/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py b/src/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py index adcb2b9c..3c85607c 100644 --- a/src/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py +++ b/src/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py @@ -47,7 +47,7 @@ nargs="+", #default=[], help='FF max events to be load', - type=list) + type=int) #n_events in runs parser.add_argument('--spe_nevents', @@ -64,7 +64,7 @@ nargs="+", #default=[], help='FF n events to be load', - type=list) + type=int) #boolean arguments parser.add_argument('--reload_wfs', @@ -187,12 +187,12 @@ def main(spe_run_number : list = [], #print(kwargs) spe_nevents = kwargs.pop('spe_nevents',[-1 for i in range(len(spe_run_number))]) - ff_nevents = kwargs.pop('spe_nevents',[-1 for i in range(len(ff_run_number))]) - ped_nevents = kwargs.pop('spe_nevents',[-1 for i in range(len(ped_run_number))]) + ff_nevents = kwargs.pop('ff_nevents',[-1 for i in range(len(ff_run_number))]) + ped_nevents = kwargs.pop('ped_nevents',[-1 for i in range(len(ped_run_number))]) spe_max_events = kwargs.pop('spe_max_events',[None for i in range(len(spe_run_number))]) - ff_max_events = kwargs.pop('spe_max_events',[None for i in range(len(ff_run_number))]) - ped_max_events = kwargs.pop('spe_max_events',[None for i in range(len(ped_run_number))]) + ff_max_events = kwargs.pop('ff_max_events',[None for i in range(len(ff_run_number))]) + ped_max_events = kwargs.pop('ped_max_events',[None for i in range(len(ped_run_number))]) runs_list = spe_run_number + ff_run_number + ped_run_number nevents = spe_nevents + ff_nevents + ped_nevents @@ -251,7 +251,14 @@ def main(spe_run_number : list = [], log.info(f"arguments passed to main are : {arg}") - path= args.extractorMethod+f"_{args.extractor_kwargs['window_shift']}-{args.extractor_kwargs['window_width']-args.extractor_kwargs['window_shift']}" + path= args.extractorMethod + if args.extractorMethod in ["GlobalPeakWindowSum", "LocalPeakWindowSum"] : + path +=f"_{args.extractor_kwargs['window_shift']}-{args.extractor_kwargs['window_width']-args.extractor_kwargs['window_shift']}" + elif args.extractorMethod in ["SlidingWindowMaxSum"] : + path +=f"_{args.extractor_kwargs['window_width']}" + elif args.extractorMethod in ["FixedWindowSum"] : + path +=f"_{args.extractor_kwargs['peak_index']}_{args.extractor_kwargs['window_shift']}-{args.extractor_kwargs['window_width']-args.extractor_kwargs['window_shift']}" + arg['path'] = path main(**arg) From aebcdd8c43185f88fbc0b3ee433a0cdb9badc979 Mon Sep 17 00:00:00 2001 From: "guillaume.grolleron" Date: Tue, 25 Apr 2023 16:20:57 +0200 Subject: [PATCH 2/2] -add name to HDU extension in WaveformsContainer / ChargeContainer --- src/nectarchain/calibration/container/charge.py | 12 ++++++------ src/nectarchain/calibration/container/waveforms.py | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/nectarchain/calibration/container/charge.py b/src/nectarchain/calibration/container/charge.py index cb15cb2f..d511cc8d 100644 --- a/src/nectarchain/calibration/container/charge.py +++ b/src/nectarchain/calibration/container/charge.py @@ -194,10 +194,10 @@ def write(self,path : Path,**kwargs) : hdr['COMMENT'] = f"The charge containeur for run {self.__run_number} with {self.__method} method : primary is the pixels id, then you can find HG charge, LG charge, HG peak and LG peak, 2 last HDU are composed of event properties and trigger patern" primary_hdu = fits.PrimaryHDU(self.pixels_id,header=hdr) - charge_hg_hdu = fits.ImageHDU(self.charge_hg) - charge_lg_hdu = fits.ImageHDU(self.charge_lg) - peak_hg_hdu = fits.ImageHDU(self.peak_hg) - peak_lg_hdu = fits.ImageHDU(self.peak_lg) + charge_hg_hdu = fits.ImageHDU(self.charge_hg,name = "HG charge") + charge_lg_hdu = fits.ImageHDU(self.charge_lg,name = "LG charge") + peak_hg_hdu = fits.ImageHDU(self.peak_hg, name = 'HG peak time') + peak_lg_hdu = fits.ImageHDU(self.peak_lg, name = 'LG peak time') col1 = fits.Column(array = self.event_id, name = "event_id", format = '1I') col2 = fits.Column(array = self.event_type, name = "event_type", format = '1I') @@ -207,12 +207,12 @@ def write(self,path : Path,**kwargs) : col6 = fits.Column(array = self.multiplicity, name = "multiplicity", format = '1I') coldefs = fits.ColDefs([col1, col2, col3, col4, col5, col6]) - event_properties = fits.BinTableHDU.from_columns(coldefs) + event_properties = fits.BinTableHDU.from_columns(coldefs, name = 'event properties') col1 = fits.Column(array = self.trig_pattern_all, name = "trig_pattern_all", format = f'{4 * self.CAMERA.n_pixels}L',dim = f'({self.CAMERA.n_pixels},4)') col2 = fits.Column(array = self.trig_pattern, name = "trig_pattern", format = f'{self.CAMERA.n_pixels}L') coldefs = fits.ColDefs([col1, col2]) - trigger_patern = fits.BinTableHDU.from_columns(coldefs) + trigger_patern = fits.BinTableHDU.from_columns(coldefs, name = 'trigger patern') hdul = fits.HDUList([primary_hdu, charge_hg_hdu, charge_lg_hdu,peak_hg_hdu,peak_lg_hdu,event_properties,trigger_patern]) try : diff --git a/src/nectarchain/calibration/container/waveforms.py b/src/nectarchain/calibration/container/waveforms.py index d96dfa8d..3f9f854f 100644 --- a/src/nectarchain/calibration/container/waveforms.py +++ b/src/nectarchain/calibration/container/waveforms.py @@ -187,8 +187,8 @@ def write(self,path : str, **kwargs) : primary_hdu = fits.PrimaryHDU(self.pixels_id,header=hdr) - wfs_hg_hdu = fits.ImageHDU(self.wfs_hg) - wfs_lg_hdu = fits.ImageHDU(self.wfs_lg) + wfs_hg_hdu = fits.ImageHDU(self.wfs_hg,name = "HG Waveforms") + wfs_lg_hdu = fits.ImageHDU(self.wfs_lg,name = "LG Waveforms") col1 = fits.Column(array = self.event_id, name = "event_id", format = '1J') @@ -199,13 +199,13 @@ def write(self,path : str, **kwargs) : col6 = fits.Column(array = self.multiplicity, name = "multiplicity", format = '1I') coldefs = fits.ColDefs([col1, col2, col3, col4, col5, col6]) - event_properties = fits.BinTableHDU.from_columns(coldefs) + event_properties = fits.BinTableHDU.from_columns(coldefs,name = 'event properties') col1 = fits.Column(array = self.trig_pattern_all, name = "trig_pattern_all", format = f'{4 * self.CAMERA.n_pixels}L',dim = f'({self.CAMERA.n_pixels},4)') col2 = fits.Column(array = self.trig_pattern, name = "trig_pattern", format = f'{self.CAMERA.n_pixels}L') coldefs = fits.ColDefs([col1, col2]) - trigger_patern = fits.BinTableHDU.from_columns(coldefs) - + trigger_patern = fits.BinTableHDU.from_columns(coldefs,name = 'trigger patern') + hdul = fits.HDUList([primary_hdu, wfs_hg_hdu, wfs_lg_hdu,event_properties,trigger_patern]) try : hdul.writeto(Path(path)/f"waveforms_run{self.run_number}{suffix}.fits",overwrite=kwargs.get('overwrite',False))