Skip to content

Commit

Permalink
Merge pull request #1341 from cta-observatory/config-to-dl1check
Browse files Browse the repository at this point in the history
Propagate config to datacheck files
  • Loading branch information
rlopezcoto authored Jan 23, 2025
2 parents 035f60f + 3bfbd1b commit 51b1027
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lstchain/datachecks/dl1_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def check_dl1(filenames, output_path, max_cores=4, create_pdf=False, batch=False

# create the dl1_datacheck containers (one per subrun) for the three
# event types, and add them to the list dl1datacheck:
# process_dl1_file also provides, as the 4th return, a string containing
# the configuration found in each DL1 file
with Pool(max_cores) as pool:
func_args = [(filename, histogram_binning) for
filename in filenames]
Expand Down Expand Up @@ -175,6 +177,13 @@ def check_dl1(filenames, output_path, max_cores=4, create_pdf=False, batch=False
file = h5py.File(datacheck_filename, mode='a')
file.create_dataset('/dl1datacheck/used_trigger_tag', (1,), 'S32',
[trigger_source.encode('ascii')])
# Write the configuration:
cosmics_table = file.get('/dl1datacheck/cosmics')
if cosmics_table is not None:
# We take the configuration of the first of the DL1 files (if more than
# one was processed), assuming the analysis was homogeneous!
cosmics_table.attrs['config'] = dl1datacheck[0][3]

file.close()

# do the plots and save them to a pdf file
Expand Down Expand Up @@ -216,6 +225,9 @@ def process_dl1_file(filename, bins, tel_id=1):
If one or more of them is None, it means they have not been filled,
due to lack of events if the given type in the input DL1 file.
configuration: string containing the configuration stored in the attrs of
the input dl1 table (settings used in the analysis)
"""

logger = logging.getLogger(__name__)
Expand All @@ -237,6 +249,7 @@ def process_dl1_file(filename, bins, tel_id=1):
m2deg = np.rad2deg(u.m / equivalent_focal_length * u.rad) / u.m

parameters = read_table(filename, dl1_params_lstcam_key)
configuration = parameters.meta['config']

# convert cog distance to camera center from meters to degrees:
parameters['r'] = parameters['r'].quantity * m2deg
Expand Down Expand Up @@ -314,7 +327,7 @@ def process_dl1_file(filename, bins, tel_id=1):
dl1datacheck_cosmics = None

return dl1datacheck_pedestals, dl1datacheck_flatfield, \
dl1datacheck_cosmics
dl1datacheck_cosmics, configuration


def plot_datacheck(datacheck_filename, out_path=None, batch=False,
Expand Down

0 comments on commit 51b1027

Please sign in to comment.