Skip to content

Commit

Permalink
If an outdated Subarray info is found in input file, it is not
Browse files Browse the repository at this point in the history
propagated to the output. A new one is created and saved instead.
  • Loading branch information
moralejo committed Feb 4, 2025
1 parent 5f490a4 commit 93761ab
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lstchain/scripts/lstchain_dl1ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
apply_time_delta_cleaning,
)
from ctapipe.instrument import SubarrayDescription
from ctapipe_io_lst import constants, OPTICS, load_camera_geometry
from ctapipe_io_lst import constants, OPTICS, LSTEventSource


from lstchain.calib.camera.pixel_threshold_estimation import get_threshold_from_dl1_file
Expand Down Expand Up @@ -225,15 +225,17 @@ def main():
delta_time = config[clean_method_name]["delta_time"]

tel_id = config["allowed_tels"][0] if "allowed_tels" in config else 1
replace_subarray_info = False
try:
subarray_info = SubarrayDescription.from_hdf(args.input_file)
optics = subarray_info.tel[tel_id].optics
camera_geom = subarray_info.tel[tel_id].camera.geometry
except OSError:
log.warning("Subarray description table is not readable because of version incompatibility.")
log.warning("The standard LST optics and camera geometry will be used.")
optics = OPTICS
camera_geom = load_camera_geometry()
replace_subarray_info = True
subarray_info = LSTEventSource.create_subarray(tel_id=tel_id)

optics = subarray_info.tel[tel_id].optics
camera_geom = subarray_info.tel[tel_id].camera.geometry

dl1_container = DL1ParametersContainer()
parameters_to_update = {
Expand Down Expand Up @@ -315,6 +317,10 @@ def main():

with tables.open_file(args.output_file, mode='a', filters=HDF5_ZSTD_FILTERS) as outfile:
copy_h5_nodes(infile, outfile, nodes=nodes_keys)
if replace_subarray_info:
outfile.remove_node("/configuration/instrument", recursive=True)
subarray_info.to_hdf(outfile)

add_source_filenames(outfile, [args.input_file])

# need container to use lstchain.io.add_global_metadata and lstchain.io.add_config_metadata
Expand Down

0 comments on commit 93761ab

Please sign in to comment.