From 88d595bd3c70822c69f2e33fac7a0d005205798a Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Sun, 24 Nov 2019 18:19:38 +0100 Subject: [PATCH 01/14] Correct pedestal statistics --- lstchain/data/onsite_camera_calibration_param.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lstchain/data/onsite_camera_calibration_param.json b/lstchain/data/onsite_camera_calibration_param.json index 1aafcaa7d3..73d78cd3be 100644 --- a/lstchain/data/onsite_camera_calibration_param.json +++ b/lstchain/data/onsite_camera_calibration_param.json @@ -10,7 +10,7 @@ "log_level":"DEBUG" }, "PedestalCalculator":{ - "sample_duration":100000, + "sample_duration":10000, "tel_id":1, "charge_median_cut_outliers": [-10,10], "charge_std_cut_outliers": [-10,10], From 282f4211910fdcfd87f3b7522df7331a5b30d339 Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Fri, 6 Dec 2019 18:24:21 +0100 Subject: [PATCH 02/14] Update muon script with calibrator and tel_id trailet in order to use it also for old data --- .../scripts/lstchain_data_muon_analysis.py | 100 +++++++----------- 1 file changed, 40 insertions(+), 60 deletions(-) diff --git a/lstchain/scripts/lstchain_data_muon_analysis.py b/lstchain/scripts/lstchain_data_muon_analysis.py index b59684acec..830ef38654 100644 --- a/lstchain/scripts/lstchain_data_muon_analysis.py +++ b/lstchain/scripts/lstchain_data_muon_analysis.py @@ -1,22 +1,14 @@ import argparse import sys, os -import numpy as np -from ctapipe.image.extractor import LocalPeakWindowSum -from ctapipe.image.muon.features import ring_containment -from ctapipe.image.muon.features import ring_completeness -from ctapipe.image.muon.features import npix_above_threshold -from ctapipe.image.muon.features import npix_composing_ring -from ctapipe.image.muon.muon_integrator import MuonLineIntegrate -from ctapipe.image.cleaning import tailcuts_clean + from ctapipe.instrument import CameraGeometry -from ctapipe.io.hdf5tableio import HDF5TableReader -from ctapipe.io.containers import FlatFieldContainer, WaveformCalibrationContainer, PedestalContainer from ctapipe.io import event_source -from ctapipe.io import EventSeeker +import numpy as np from lstchain.calib.camera.r0 import LSTR0Corrections from lstchain.image.muon import analyze_muon_event, muon_filter, tag_pix_thr - +from lstchain.calib.camera.calibrator import LSTCameraCalibrator +from traitlets.config.loader import Config from astropy.table import Table @@ -29,6 +21,7 @@ --output_file Data_table.fits --pedestal_file pedestal_file_run446_0000.fits --calibration_file calibration.hdf5 --max_events 1000 +--tel_id 0 ''' @@ -62,6 +55,11 @@ "Default = 442", type = int, default = 442) +parser.add_argument("--tel_id", help = "telescope id" + "Default = 1", + type = int, default = 1) + + args = parser.parse_args() @@ -74,7 +72,7 @@ def main(): print("max events: {}".format(args.max_events)) # Camera geometry - geom = CameraGeometry.from_name("LSTCam-002") + geom = CameraGeometry.from_name("LSTCam-003") # Definition of the output parameters for the table output_parameters = {'event_id': [], @@ -91,41 +89,27 @@ def main(): 'impact_x_array': [], 'impact_y_array': [], } - + + tel_id = args.tel_id + # Calibration related quantities r0calib = LSTR0Corrections( pedestal_path = args.pedestal_file, - r1_sample_start=2,r1_sample_end=38) + r1_sample_start=2,r1_sample_end=38, tel_id=tel_id) - ff_data = FlatFieldContainer() - cal_data = WaveformCalibrationContainer() - ped_data = PedestalContainer() + charge_config = Config({ + "LocalPeakWindowSum": { + "window_shift": 4, + "window_width": 8 + } + }) - dc_to_pe = [] - ped_median = [] - - if (args.run_number > 500): # Not sure where did the tel definition change - with HDF5TableReader(args.calibration_file) as h5_table: - assert h5_table._h5file.isopen == True - for cont in h5_table.read('/tel_1/pedestal', ped_data): - ped_median = cont.charge_median - - for calib in h5_table.read('/tel_1/calibration', cal_data): - dc_to_pe = calib['dc_to_pe'] - h5_table.close() - - else: - with HDF5TableReader(args.calibration_file) as h5_table: - assert h5_table._h5file.isopen == True - for cont in h5_table.read('/tel_0/pedestal', ped_data): - ped_median = cont.charge_median - - for calib in h5_table.read('/tel_0/calibration', cal_data): - dc_to_pe = calib['dc_to_pe'] - h5_table.close() + r1_dl1_calibrator = LSTCameraCalibrator(calibration_path=args.calibration_file, + image_extractor="LocalPeakWindowSum", + config=charge_config,allowed_tels=[tel_id]) # Maximum number of events - if (args.max_events): + if args.max_events: max_events = args.max_events else: max_events = None @@ -133,32 +117,28 @@ def main(): # File open num_muons = 0 source = event_source(input_url = args.input_file, max_events = max_events) + for event in source: + event_id = event.lst.tel[tel_id].evt.event_id + telescope_description = event.inst.subarray.tel[tel_id] + + # drs4 calibration r0calib.calibrate(event) - # Not sure where did the tel definition change - # but we moved to tel[0] to tel[1] at some point - # of the commissioning period - if (args.run_number > 500): - event_id = event.lst.tel[1].evt.event_id - telescope_description = event.inst.subarray.tel[1] - pedcorrectedsamples = event.r1.tel[1].waveform - else: - event_id = event.lst.tel[0].evt.event_id - telescope_description = event.inst.subarray.tel[0] - pedcorrectedsamples = event.r1.tel[0].waveform - integrator = LocalPeakWindowSum(window_shift=4, window_width=9) - integration, pulse_time = integrator(pedcorrectedsamples) - image = (integration - ped_median)*dc_to_pe - - print("Event {}. Number of pixels above 10 phe: {}".format(event_id, - np.size(image[0][image[0] > 10.]))) - + + # r1 calibration + r1_dl1_calibrator(event) + image = event.dl1.tel[tel_id].image + + #print("Event {}. Number of pixels above 10 phe: {}".format(event_id, + # np.size(image[0][image[0] > 10.]))) if not tag_pix_thr(image): #default skipps pedestal and calibration events continue if not muon_filter(image): #default values apply no filtering continue - + print("--> Event {}. Number of pixels above 10 phe: {}".format(event_id, + np.size(image[0][image[0] > 10.]))) + equivalent_focal_length = telescope_description.optics.equivalent_focal_length mirror_area = telescope_description.optics.mirror_area.to("m2") From b75da0be3dfa81ed00116f479d60f440373cb04f Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Tue, 17 Dec 2019 15:35:06 +0100 Subject: [PATCH 03/14] Change default values to standard one --- lstchain/calib/camera/r0.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lstchain/calib/camera/r0.py b/lstchain/calib/camera/r0.py index 6d1c28d657..3c3ba7792c 100644 --- a/lstchain/calib/camera/r0.py +++ b/lstchain/calib/camera/r0.py @@ -37,11 +37,11 @@ class CameraR0Calibrator(Component): offset = Int(default_value=400, help='Define the offset of the baseline').tag(config=True) - r1_sample_start = Int(default_value=None, + r1_sample_start = Int(default_value=2, help='Start sample for r1 waveform', allow_none=True).tag(config=True) - r1_sample_end = Int(default_value=None, + r1_sample_end = Int(default_value=38, help='End sample for r1 waveform', allow_none=True).tag(config=True) From facb9852649d157220fec3eef79b930ecae1ca3c Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Tue, 17 Dec 2019 15:37:23 +0100 Subject: [PATCH 04/14] Eliminate run number information (replaced by tel_id) --- lstchain/scripts/lstchain_data_muon_analysis.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lstchain/scripts/lstchain_data_muon_analysis.py b/lstchain/scripts/lstchain_data_muon_analysis.py index 7a315a2cfb..376e6e06de 100644 --- a/lstchain/scripts/lstchain_data_muon_analysis.py +++ b/lstchain/scripts/lstchain_data_muon_analysis.py @@ -51,10 +51,6 @@ parser.add_argument("--plots_path", help = "Path to the plots", default = None, type = str) -parser.add_argument("--run_number", help = "Run number to analyze." - "Default = 442", - type = int, default = 442) - parser.add_argument("--tel_id", help = "telescope id" "Default = 1", type = int, default = 1) @@ -92,11 +88,11 @@ def main(): tel_id = args.tel_id - # Calibration related quantities + # Low level calibration r0calib = LSTR0Corrections( - pedestal_path = args.pedestal_file, - r1_sample_start=2,r1_sample_end=38, tel_id=tel_id) + pedestal_path = args.pedestal_file, tel_id=tel_id) + # high level calibration and gain selection charge_config = Config({ "LocalPeakWindowSum": { "window_shift": 4, From 2abc79d0bfef5177364112a665eb0fb5ee1df4bd Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Thu, 16 Jan 2020 09:45:30 +0100 Subject: [PATCH 05/14] Add trailets to select only the time calibraiton or the flat field calibration --- .../onsite/onsite_create_calibration_file.py | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/lstchain/scripts/onsite/onsite_create_calibration_file.py b/lstchain/scripts/onsite/onsite_create_calibration_file.py index 01c5c84407..339cf16162 100755 --- a/lstchain/scripts/onsite/onsite_create_calibration_file.py +++ b/lstchain/scripts/onsite/onsite_create_calibration_file.py @@ -29,6 +29,8 @@ optional.add_argument('-s', '--statistics', help="Number of events for the flat-field and pedestal statistics", type=int, default=10000) optional.add_argument('-b','--base_dir', help="Root dir for the output directory tree",type=str, default='/fefs/aswg/data/real') +optional.add_argument('-t','--time_calibration', help="Perform only the time calibration (yes/no)",type=str, default='yes') +optional.add_argument('-f','--ff_calibration', help="Perform only the charge calibration (yes/np)",type=str, default='yes') args = parser.parse_args() run = args.run_number @@ -36,6 +38,8 @@ prod_id = 'v%02d'%args.version stat_events = args.statistics base_dir = args.base_dir +time_calibration = args.time_calibration +ff_calibration = args.ff_calibration max_events = 1000000 @@ -74,14 +78,16 @@ def main(): # produce ff calibration file # + # define charge file names output_file = f"{output_dir}/calibration.Run{run}.0000.hdf5" log_file = f"{output_dir}/log/calibration.Run{run}.0000.log" print(f"\n--> Output file {output_file}") - if os.path.exists(output_file): + if os.path.exists(output_file) and ff_calibration is 'yes': if query_yes_no(">>> Output file exists already. Do you want to remove it?"): os.remove(output_file) else: + print(f"\n--> Stop") exit(1) print(f"\n--> Log file {log_file}") @@ -93,31 +99,32 @@ def main(): exit(1) print(f"\n--> Config file {config_file}") - # run lstchain script - cmd = f"lstchain_data_create_calibration_file " \ - f"--input_file={input_file} --output_file={output_file} --pedestal_file={pedestal_file} " \ - f"--FlatFieldCalculator.sample_size={stat_events} --PedestalCalculator.sample_size={stat_events} " \ - f"--EventSource.max_events={max_events} --config={config_file} > {log_file} 2>&1" + if ff_calibration is 'yes': + # run lstchain script + cmd = f"lstchain_data_create_calibration_file " \ + f"--input_file={input_file} --output_file={output_file} --pedestal_file={pedestal_file} " \ + f"--FlatFieldCalculator.sample_size={stat_events} --PedestalCalculator.sample_size={stat_events} " \ + f"--EventSource.max_events={max_events} --config={config_file} > {log_file} 2>&1" - print("\n--> RUNNING...") - os.system(cmd) + print("\n--> RUNNING...") + os.system(cmd) - # plot and save some results - plot_file=f"{output_dir}/log/calibration.Run{run}.0000.pedestal.Run{ped_run}.0000.pdf" - print(f"\n--> PRODUCING PLOTS in {plot_file} ...") - calib.read_file(output_file) - calib.plot_all(calib.ped_data, calib.ff_data, calib.calib_data, run, plot_file) + # plot and save some results + plot_file=f"{output_dir}/log/calibration.Run{run}.0000.pedestal.Run{ped_run}.0000.pdf" + print(f"\n--> PRODUCING PLOTS in {plot_file} ...") + calib.read_file(output_file) + calib.plot_all(calib.ped_data, calib.ff_data, calib.calib_data, run, plot_file) # # produce drs4 time calibration file # - - time_file = f"{output_dir}/time_calibration.Run{run}.0000.hdf5" - print(f"\n--> PRODUCING TIME CALIBRATION in {time_file} ...") - cmd = f"lstchain_data_create_time_calibration_file --input_file {input_file} " \ - f"--output_file {time_file} -conf {config_file} -ped {pedestal_file} 2>&1" - print("\n--> RUNNING...") - os.system(cmd) + if time_calibration is 'yes': + time_file = f"{output_dir}/time_calibration.Run{run}.0000.hdf5" + print(f"\n--> PRODUCING TIME CALIBRATION in {time_file} ...") + cmd = f"lstchain_data_create_time_calibration_file --input_file {input_file} " \ + f"--output_file {time_file} -conf {config_file} -ped {pedestal_file} 2>&1" + print("\n--> RUNNING...") + os.system(cmd) print("\n--> END") From cfc1b91d938496359f237075c3f302b6eb2095ec Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Thu, 16 Jan 2020 09:46:41 +0100 Subject: [PATCH 06/14] Get geometry infos from the event_source class --- .../scripts/lstchain_data_muon_analysis.py | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lstchain/scripts/lstchain_data_muon_analysis.py b/lstchain/scripts/lstchain_data_muon_analysis.py index 5ce8d47229..b1f3ee01ab 100644 --- a/lstchain/scripts/lstchain_data_muon_analysis.py +++ b/lstchain/scripts/lstchain_data_muon_analysis.py @@ -40,15 +40,15 @@ parser.add_argument("--calibration_file", help = "Path to the file containing the calibration constants", type = str) -parser.add_argument("--time_calibration_file", help = "Path to the calibraiton file with time corrections ", - type = str) +parser.add_argument("--time_calibration_file", help = "Path to the calibration file with time corrections ", + type = str, default='') # Optional argument parser.add_argument("--max_events", help = "Maximum numbers of events to read. " "Default = 100", type = int, default = 100) parser.add_argument("--gain_threshold", help = "Gain threshold in ADC. " - "Default = 4094", type = int, default=4094) + "Default = 3500", type = int, default=3500) parser.add_argument("--plot_rings", help = "Plot figures of the stored rings", default = False, action='store_true') @@ -70,10 +70,11 @@ def main(): print("output file: {}".format(args.output_file)) print("pedestal file: {}".format(args.pedestal_file)) print("calibration file: {}".format(args.calibration_file)) + print("time calibration file: {}".format(args.time_calibration_file)) print("max events: {}".format(args.max_events)) # Camera geometry - geom = CameraGeometry.from_name("LSTCam-003") + #geom = CameraGeometry.from_name("LSTCam-003") # Definition of the output parameters for the table output_parameters = {'event_id': [], @@ -93,13 +94,6 @@ def main(): tel_id = args.tel_id - # Low level calibration - r0calib = LSTR0Corrections( - pedestal_path = args.pedestal_file, tel_id=tel_id) - - - tel_id = args.tel_id - # Low level calibration r0calib = LSTR0Corrections( pedestal_path = args.pedestal_file, tel_id=tel_id) @@ -130,9 +124,16 @@ def main(): num_muons = 0 source = event_source(input_url = args.input_file, max_events = max_events) + # geometry + subarray = source.subarray() + telescope_description = subarray.tel[tel_id] + equivalent_focal_length = telescope_description.optics.equivalent_focal_length + mirror_area = telescope_description.optics.mirror_area.to("m2") + geom = telescope_description.camera + + for event in source: event_id = event.lst.tel[tel_id].evt.event_id - telescope_description = event.inst.subarray.tel[tel_id] # drs4 calibration r0calib.calibrate(event) @@ -152,9 +153,6 @@ def main(): np.size(image[image > 10.]))) - equivalent_focal_length = telescope_description.optics.equivalent_focal_length - mirror_area = telescope_description.optics.mirror_area.to("m2") - muonintensityparam, size_outside_ring, muonringparam, good_ring = \ analyze_muon_event(event_id, image, geom, equivalent_focal_length, mirror_area, args.plot_rings, args.plots_path) From d0cda0aaffb1cd65db9b2bfe5255a338f724b0cc Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Fri, 17 Jan 2020 09:41:07 +0100 Subject: [PATCH 07/14] Add tel_id for processing old files --- .../scripts/onsite/onsite_create_calibration_file.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lstchain/scripts/onsite/onsite_create_calibration_file.py b/lstchain/scripts/onsite/onsite_create_calibration_file.py index 339cf16162..0ea610df7a 100755 --- a/lstchain/scripts/onsite/onsite_create_calibration_file.py +++ b/lstchain/scripts/onsite/onsite_create_calibration_file.py @@ -29,8 +29,10 @@ optional.add_argument('-s', '--statistics', help="Number of events for the flat-field and pedestal statistics", type=int, default=10000) optional.add_argument('-b','--base_dir', help="Root dir for the output directory tree",type=str, default='/fefs/aswg/data/real') -optional.add_argument('-t','--time_calibration', help="Perform only the time calibration (yes/no)",type=str, default='yes') -optional.add_argument('-f','--ff_calibration', help="Perform only the charge calibration (yes/np)",type=str, default='yes') +optional.add_argument('--tel_id', help="telescope id. Default = 1", type=int, default=1) +optional.add_argument('--time_calibration', help="Perform only the time calibration (yes/no)",type=str, default='yes') +optional.add_argument('--ff_calibration', help="Perform only the charge calibration (yes/np)",type=str, default='yes') + args = parser.parse_args() run = args.run_number @@ -40,6 +42,8 @@ base_dir = args.base_dir time_calibration = args.time_calibration ff_calibration = args.ff_calibration +tel_id = args.tel_id + max_events = 1000000 @@ -112,7 +116,7 @@ def main(): # plot and save some results plot_file=f"{output_dir}/log/calibration.Run{run}.0000.pedestal.Run{ped_run}.0000.pdf" print(f"\n--> PRODUCING PLOTS in {plot_file} ...") - calib.read_file(output_file) + calib.read_file(output_file,tel_id) calib.plot_all(calib.ped_data, calib.ff_data, calib.calib_data, run, plot_file) # From 1fb27b6fca58612ba71609eaf571b25a50500e50 Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Fri, 17 Jan 2020 09:42:28 +0100 Subject: [PATCH 08/14] Add trailet tel_id for processing old files --- .../scripts/onsite/onsite_create_drs4_pedestal_file.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lstchain/scripts/onsite/onsite_create_drs4_pedestal_file.py b/lstchain/scripts/onsite/onsite_create_drs4_pedestal_file.py index dcc98c0345..b6a50224ce 100755 --- a/lstchain/scripts/onsite/onsite_create_drs4_pedestal_file.py +++ b/lstchain/scripts/onsite/onsite_create_drs4_pedestal_file.py @@ -26,12 +26,16 @@ type=int, default=8000) optional.add_argument('-b','--base_dir', help="Base dir for the output directory tree", type=str, default='/fefs/aswg/data/real') +optional.add_argument('--tel_id', help="telescope id. Default = 1", + type=int, default=1) + args = parser.parse_args() run = args.run_number prod_id = 'v%02d'%args.prod_version max_events = args.max_events base_dir = args.base_dir +tel_id = args.tel_id def main(): @@ -81,12 +85,10 @@ def main(): # plot and save some results plot_file=f"{output_dir}/log/drs4_pedestal.Run{run}.0000.pdf" print(f"\n--> PRODUCING PLOTS in {plot_file} ...") - drs4.plot_pedestals(input_file, output_file, run, plot_file, tel_id=1, offset_value=300) + drs4.plot_pedestals(input_file, output_file, run, plot_file, tel_id=tel_id, offset_value=300) print("\n--> END") - - except Exception as e: print(f"\n >>> Exception: {e}") From 8f498338aa82ce3d334f7c672e08a02ec0f7c0c3 Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Fri, 17 Jan 2020 09:44:55 +0100 Subject: [PATCH 09/14] Remove unused trailet --- lstchain/tools/lstchain_data_create_calibration_file.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lstchain/tools/lstchain_data_create_calibration_file.py b/lstchain/tools/lstchain_data_create_calibration_file.py index 7728eae5e9..2633de195a 100644 --- a/lstchain/tools/lstchain_data_create_calibration_file.py +++ b/lstchain/tools/lstchain_data_create_calibration_file.py @@ -44,11 +44,6 @@ class CalibrationHDF5Writer(Tool): help='Temporary cut on LG std against Lidar events till the calibox TIB do not work (default for filter 5.2) ' ).tag(config=True) - maximum_charge = Float( - 300, - help='Temporary cut on charge till the calibox TIB do not work' - ).tag(config=True) - one_event = Bool( False, help='Stop after first calibration event' From d32b0d2f33b4f49b3180fea543ee6901b91e974c Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Fri, 17 Jan 2020 09:45:33 +0100 Subject: [PATCH 10/14] Update geometry --- lstchain/visualization/plot_calib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lstchain/visualization/plot_calib.py b/lstchain/visualization/plot_calib.py index 65ab308161..09bff9a260 100644 --- a/lstchain/visualization/plot_calib.py +++ b/lstchain/visualization/plot_calib.py @@ -63,7 +63,7 @@ def plot_all(ped_data, ff_data, calib_data, run=0, plot_file="none"): calib_data: calibration container WaveformCalibrationContainer() """ - camera = CameraGeometry.from_name("LSTCam", 2) + camera = CameraGeometry.from_name("LSTCam", 4) # plot open pdf if plot_file != "none": From 8f631b522fcc8567bee702d7c570bece0ff8e5b3 Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Fri, 17 Jan 2020 09:46:49 +0100 Subject: [PATCH 11/14] Add check on tel_id value --- lstchain/visualization/plot_drs4.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lstchain/visualization/plot_drs4.py b/lstchain/visualization/plot_drs4.py index 72770f90e4..c7a660d653 100644 --- a/lstchain/visualization/plot_drs4.py +++ b/lstchain/visualization/plot_drs4.py @@ -30,6 +30,10 @@ def plot_pedestals(data_file, pedestal_file, run=0 , plot_file="none", tel_id=1, run: run number of data to be corrected plot_file: name of output pdf file + + tel_id: id of the telescope + + offset_value: baseline off_set """ # plot open pdf @@ -64,6 +68,8 @@ def plot_pedestals(data_file, pedestal_file, run=0 , plot_file="none", tel_id=1, config=charge_config) for i, event in enumerate(reader): + if tel_id != event.r0.tels_with_data[0]: + raise Exception(f"Given wrong telescope id {tel_id}, files has id {event.r0.tels_with_data[0]}") # move from R0 to R1 r0_calib.calibrate(event) From 2da23edbdd761936b955f776bf41724e4993869f Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Fri, 17 Jan 2020 14:51:16 +0100 Subject: [PATCH 12/14] Add tel_id argument in order to run on old data --- lstchain/scripts/lstchain_data_muon_analysis.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lstchain/scripts/lstchain_data_muon_analysis.py b/lstchain/scripts/lstchain_data_muon_analysis.py index b1f3ee01ab..4b3a62e48e 100644 --- a/lstchain/scripts/lstchain_data_muon_analysis.py +++ b/lstchain/scripts/lstchain_data_muon_analysis.py @@ -55,8 +55,6 @@ parser.add_argument("--plots_path", help = "Path to the plots", default = None, type = str) - - parser.add_argument("--tel_id", help = "telescope id. " "Default = 1",type = int, default = 1) @@ -125,7 +123,7 @@ def main(): source = event_source(input_url = args.input_file, max_events = max_events) # geometry - subarray = source.subarray() + subarray = source.subarray(tel_id) telescope_description = subarray.tel[tel_id] equivalent_focal_length = telescope_description.optics.equivalent_focal_length mirror_area = telescope_description.optics.mirror_area.to("m2") From d0b231500ebf09b3e0645ffbc4cdaf020a936ef9 Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Mon, 20 Jan 2020 16:46:15 +0100 Subject: [PATCH 13/14] Add a default_time_run trailet to identifay the time calibrarion file: the script create a link to the corresponding calibration file. If the trailet is zero, the script calculate the time calibraiton --- .../scripts/lstchain_data_muon_analysis.py | 2 +- .../onsite/onsite_create_calibration_file.py | 24 +++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lstchain/scripts/lstchain_data_muon_analysis.py b/lstchain/scripts/lstchain_data_muon_analysis.py index 4b3a62e48e..dd123dbd8b 100644 --- a/lstchain/scripts/lstchain_data_muon_analysis.py +++ b/lstchain/scripts/lstchain_data_muon_analysis.py @@ -143,7 +143,7 @@ def main(): if not tag_pix_thr(image): #default skipps pedestal and calibration events continue - if not muon_filter(image): #default values apply no filtering + if not muon_filter(image,800,5000): #default values apply no filtering continue diff --git a/lstchain/scripts/onsite/onsite_create_calibration_file.py b/lstchain/scripts/onsite/onsite_create_calibration_file.py index 0ea610df7a..11d4fbd540 100755 --- a/lstchain/scripts/onsite/onsite_create_calibration_file.py +++ b/lstchain/scripts/onsite/onsite_create_calibration_file.py @@ -29,9 +29,9 @@ optional.add_argument('-s', '--statistics', help="Number of events for the flat-field and pedestal statistics", type=int, default=10000) optional.add_argument('-b','--base_dir', help="Root dir for the output directory tree",type=str, default='/fefs/aswg/data/real') +optional.add_argument('--default_time_run', help="If 0 time calibration is calculated otherwise create a link to the give run time calibration",type=int, default='1625') +optional.add_argument('--ff_calibration', help="Perform the charge calibration (yes/no)",type=str, default='yes') optional.add_argument('--tel_id', help="telescope id. Default = 1", type=int, default=1) -optional.add_argument('--time_calibration', help="Perform only the time calibration (yes/no)",type=str, default='yes') -optional.add_argument('--ff_calibration', help="Perform only the charge calibration (yes/np)",type=str, default='yes') args = parser.parse_args() @@ -40,7 +40,7 @@ prod_id = 'v%02d'%args.version stat_events = args.statistics base_dir = args.base_dir -time_calibration = args.time_calibration +default_time_run = args.default_time_run ff_calibration = args.ff_calibration tel_id = args.tel_id @@ -122,13 +122,29 @@ def main(): # # produce drs4 time calibration file # - if time_calibration is 'yes': + + if default_time_run is 0: time_file = f"{output_dir}/time_calibration.Run{run}.0000.hdf5" print(f"\n--> PRODUCING TIME CALIBRATION in {time_file} ...") cmd = f"lstchain_data_create_time_calibration_file --input_file {input_file} " \ f"--output_file {time_file} -conf {config_file} -ped {pedestal_file} 2>&1" print("\n--> RUNNING...") os.system(cmd) + else: + # otherwise perform a link to the default time calibration file + print(f"\n--> PRODUCING LINK TO DEFAULT TIME CALIBRATION (run {default_time_run})") + file_list = sorted(Path(f"{base_dir}/calibration/").rglob(f'*/{prod_id}/time_calibration.Run{default_time_run}*')) + + + if len(file_list) == 0: + print(f">>> Error: time calibration file for run {default_time_run} not found\n") + raise NameError() + else: + time_calibration_file = file_list[0] + input_dir, name = os.path.split(os.path.abspath(time_calibration_file )) + cmd=f"ln -sf {time_calibration_file} {output_dir}/{name}" + print(f"\n--> Time calibration file: {output_dir}/{name}") + os.system(cmd) print("\n--> END") From 24c5d3064b7bbcebb2f2496945b0a93dc7290b24 Mon Sep 17 00:00:00 2001 From: Franca Cassol Date: Mon, 20 Jan 2020 16:53:30 +0100 Subject: [PATCH 14/14] Add trailet default_time_run and create a link to the time calibration file of that run. If default_time_run=0, it calculate the time calibration file. --- .../scripts/onsite/onsite_create_calibration_file.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lstchain/scripts/onsite/onsite_create_calibration_file.py b/lstchain/scripts/onsite/onsite_create_calibration_file.py index 11d4fbd540..eec17d5481 100755 --- a/lstchain/scripts/onsite/onsite_create_calibration_file.py +++ b/lstchain/scripts/onsite/onsite_create_calibration_file.py @@ -122,9 +122,9 @@ def main(): # # produce drs4 time calibration file # - + time_file = f"{output_dir}/time_calibration.Run{run}.0000.hdf5" + if default_time_run is 0: - time_file = f"{output_dir}/time_calibration.Run{run}.0000.hdf5" print(f"\n--> PRODUCING TIME CALIBRATION in {time_file} ...") cmd = f"lstchain_data_create_time_calibration_file --input_file {input_file} " \ f"--output_file {time_file} -conf {config_file} -ped {pedestal_file} 2>&1" @@ -142,10 +142,11 @@ def main(): else: time_calibration_file = file_list[0] input_dir, name = os.path.split(os.path.abspath(time_calibration_file )) - cmd=f"ln -sf {time_calibration_file} {output_dir}/{name}" - print(f"\n--> Time calibration file: {output_dir}/{name}") + cmd=f"ln -sf {time_calibration_file} {time_file}" os.system(cmd) + print(f"\n--> Time calibration file: {time_file}") + print("\n--> END") except Exception as e: