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

Improve calibration "info" and "warning" messages #1140

Merged
merged 3 commits into from
Jul 18, 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
1 change: 1 addition & 0 deletions lstchain/calib/camera/flatfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def calculate_relative_gain(self, event):
self.collect_sample(charge, pixel_mask, arrival_time)

sample_age = (self.trigger_time - self.time_start).to_value(u.s)

# check if to create a calibration event
if (self.num_events_seen > 0 and
(sample_age > self.sample_duration or
Expand Down
3 changes: 3 additions & 0 deletions lstchain/data/onsite_camera_calibration_param.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"log_level": "INFO"
},
"LSTEventSource": {
"MultiFiles": {
"all_subruns": true
},
"allowed_tels": [
1
],
Expand Down
2 changes: 1 addition & 1 deletion lstchain/scripts/onsite/onsite_create_calibration_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def main():
f"--PedestalCalculator.sample_size={stat_events}",
f"--config={config_file}",
f"--log-file={log_file}",
"--log-file-level=DEBUG",
"--log-file-level=INFO",
*remaining_args,
]

Expand Down
29 changes: 20 additions & 9 deletions lstchain/tools/lstchain_create_calibration_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ def __init__(self, **kwargs):
self.processor = None
self.writer = None
self.simulation = False
self.n_calib = 0

def setup(self):

self.log.debug("Opening file")
self.log.info("Opening file")
self.eventsource = EventSource.from_config(parent=self)

self.processor = CalibrationCalculator.from_name(
Expand All @@ -130,7 +131,7 @@ def setup(self):

group_name = 'tel_' + str(tel_id)

self.log.debug(f"Open output file {self.output_file}")
self.log.info(f"Open output file {self.output_file}")

self.writer = HDF5TableWriter(
filename=self.output_file, group_name=group_name, overwrite=True
Expand Down Expand Up @@ -202,16 +203,16 @@ def start(self):

# write flatfield results when enough statistics (also for pedestals)
if (new_ff and new_ped):
self.log.debug(f"Write calibration at event n. {count+1}, event id {event.index.event_id} ")
self.log.info(f"Write calibration at event n. {count+1}, event id {event.index.event_id} ")

self.log.debug(f"Ready flatfield data at event n. {count_ff} "
f"stat = {ff_data.n_events} events")
self.log.info(f"Ready flatfield data at event n. {count_ff} "
f"stat = {ff_data.n_events} events")

# write on file
self.writer.write('flatfield', ff_data)

self.log.debug(f"Ready pedestal data at event n. {count_ped}"
f"stat = {ped_data.n_events} events")
self.log.info(f"Ready pedestal data at event n. {count_ped} "
f"stat = {ped_data.n_events} events")

# write only pedestal data used for calibration
self.writer.write('pedestal', ped_data)
Expand All @@ -223,15 +224,25 @@ def start(self):
self.processor.calculate_calibration_coefficients(event)

# write calib and pixel status
self.log.debug("Write pixel_status data")
self.log.info("Write pixel_status data")
self.writer.write('pixel_status', status_data)

self.log.debug("Write calibration data")
self.log.info("Write calibration data")
self.writer.write('calibration', calib_data)
self.n_calib += 1

if self.one_event:
break

def finish(self):

self.log.info(f"Written {self.n_calib} calibration events")
if self.n_calib == 0:
self.log.critical("!!! No calibration events in the output file !!! : ")
self.log.critical(f"flatfield collected statistics = {self.processor.flatfield.num_events_seen} events")
maxnoe marked this conversation as resolved.
Show resolved Hide resolved
self.log.critical(f"pedestal collected statistics = {self.processor.pedestal.num_events_seen} events")
self.exit(1)

Provenance().add_output_file(
self.output_file,
role='mon.tel.calibration'
Expand Down
Loading