@@ -301,6 +301,7 @@ def test_merge_telescope_data(tmp_path, prod6_gamma_simtel_path):
301301 as processing all telescopes together.
302302 """
303303
304+ from ctapipe .core import traits
304305 from ctapipe .io .hdf5merger import CannotMerge
305306 from ctapipe .tools .merge import MergeTool
306307 from ctapipe .tools .process import ProcessorTool
@@ -322,7 +323,7 @@ def test_merge_telescope_data(tmp_path, prod6_gamma_simtel_path):
322323 "sub2_dl1b" : tmp_path / "gamma_sub2_noimages.dl1b.h5" ,
323324 "merged" : tmp_path / "gamma_merged.dl1.h5" ,
324325 "merged_appendmode" : tmp_path / "gamma_merged_appendmode.dl1.h5" ,
325- "tel_ids_invalid " : tmp_path / "duplicated_tel_ids_invalid .dl1.h5" ,
326+ "invalid " : tmp_path / "invalid .dl1.h5" ,
326327 "required_node_invalid" : tmp_path / "required_node_invalid.dl1.h5" ,
327328 }
328329 # Select a few telescopes that cover different telescope types
@@ -364,6 +365,7 @@ def test_merge_telescope_data(tmp_path, prod6_gamma_simtel_path):
364365 str (outputs ["sub2" ]),
365366 f"--output={ outputs [merged_mode_name ]} " ,
366367 "--telescope-events" ,
368+ "--no-dl2-subarray" ,
367369 "--combine-telescope-data" ,
368370 ],
369371 cwd = tmp_path ,
@@ -394,17 +396,49 @@ def test_merge_telescope_data(tmp_path, prod6_gamma_simtel_path):
394396
395397 # Check that merging files with overlapping telescope IDs raises an error
396398 # When combining telescope data, telescope IDs must be unique.
399+ argv_options = [
400+ str (outputs ["sub1" ]),
401+ str (outputs [merged_mode_name ]),
402+ f"--output={ outputs ['invalid' ]} " ,
403+ "--combine-telescope-data" ,
404+ ]
397405 with pytest .raises (
398406 ValueError , match = "Duplicate telescope IDs found when merging file"
399407 ):
400408 run_tool (
401409 MergeTool (),
402410 argv = [
403- str (outputs ["sub1" ]),
404- str (outputs [merged_mode_name ]),
411+ * argv_options ,
405412 "--telescope-events" ,
406- "--combine-telescope-data" ,
407- f"--output={ outputs ['tel_ids_invalid' ]} " ,
413+ "--no-dl2-subarray" ,
414+ ],
415+ cwd = tmp_path ,
416+ raises = True ,
417+ )
418+
419+ # Check that merging files with incompatible options raises a TraitError
420+ with pytest .raises (
421+ traits .TraitError , match = "Merge strategy 'combine-telescope-data' requires"
422+ ):
423+ run_tool (
424+ MergeTool (),
425+ argv = [
426+ * argv_options ,
427+ "--no-telescope-events" ,
428+ "--no-dl2-subarray" ,
429+ ],
430+ cwd = tmp_path ,
431+ raises = True ,
432+ )
433+ with pytest .raises (
434+ traits .TraitError , match = "Merge strategy 'combine-telescope-data' requires"
435+ ):
436+ run_tool (
437+ MergeTool (),
438+ argv = [
439+ * argv_options ,
440+ "--telescope-events" ,
441+ "--dl2-subarray" ,
408442 ],
409443 cwd = tmp_path ,
410444 raises = True ,
@@ -430,6 +464,7 @@ def test_merge_telescope_data(tmp_path, prod6_gamma_simtel_path):
430464 str (outputs ["sub2_dl1b" ]),
431465 "--telescope-events" ,
432466 "--combine-telescope-data" ,
467+ "--no-dl2-subarray" ,
433468 f"--output={ outputs ['required_node_invalid' ]} " ,
434469 ],
435470 cwd = tmp_path ,
0 commit comments