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

Correct Subarray info in output DL1 files #1347

Merged
merged 2 commits into from
Feb 5, 2025
Merged
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
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, LSTEventSource


from lstchain.calib.camera.pixel_threshold_estimation import get_threshold_from_dl1_file
Expand Down Expand Up @@ -225,15 +225,17 @@
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)

Check warning on line 235 in lstchain/scripts/lstchain_dl1ab.py

View check run for this annotation

Codecov / codecov/patch

lstchain/scripts/lstchain_dl1ab.py#L234-L235

Added lines #L234 - L235 were not covered by tests

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 @@

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)

Check warning on line 322 in lstchain/scripts/lstchain_dl1ab.py

View check run for this annotation

Codecov / codecov/patch

lstchain/scripts/lstchain_dl1ab.py#L321-L322

Added lines #L321 - L322 were not covered by tests

add_source_filenames(outfile, [args.input_file])

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