def test_dl1_to_filename(): from lstchain.paths import run_to_dl1_filename, Run assert run_to_dl1_filename(tel_id=1, run=1920, subrun=2) == 'dl1_LST-1.Run01920.0002.h5' assert run_to_dl1_filename(tel_id=1, run=1920, subrun=3, stream=2) == 'dl1_LST-1.2.Run01920.0003.h5' run = Run(tel_id=2, run=5, subrun=1) assert run_to_dl1_filename(*run) == 'dl1_LST-2.Run00005.0001.h5'
def main(): output_dir = args.output_dir.absolute() output_dir.mkdir(exist_ok=True) if not args.input_file.is_file(): log.error('Input file does not exist or is not a file') sys.exit(1) log.setLevel(logging.INFO) handler = logging.StreamHandler() logging.getLogger().addHandler(handler) r0_to_dl1.allowed_tels = {1, 2, 3, 4} # test if this matches data file name pattern try: run = parse_r0_filename(args.input_file) output_filename = output_dir / run_to_dl1_filename( run.tel_id, run.run, run.subrun) except ValueError: # for arbitrary filenames, including mc output_filename = output_dir / r0_to_dl1_filename(args.input_file.name) config = {} if args.config_file is not None: try: config = read_configuration_file(args.config_file) except Exception as e: log.error(f'Configuration file could not be read: {e}') sys.exit(1) config["max_events"] = args.max_events r0_to_dl1.r0_to_dl1(args.input_file, output_filename=output_filename, custom_config=config, pedestal_path=args.pedestal_file, calibration_path=args.calibration_file, time_calibration_path=args.time_calibration_file, pointing_file_path=args.pointing_file, ucts_t0_dragon=args.ucts_t0_dragon, dragon_counter0=args.dragon_counter0, ucts_t0_tib=args.ucts_t0_tib, tib_counter0=args.tib_counter0)
def main(): args = parser.parse_args() output_dir = args.output_dir.absolute() output_dir.mkdir(exist_ok=True, parents=True) if not args.input_file.is_file(): log.error('Input file does not exist or is not a file') sys.exit(1) log.setLevel(logging.INFO) handler = logging.StreamHandler() logging.getLogger().addHandler(handler) r0_to_dl1.allowed_tels = {1, 2, 3, 4} # test if this matches data file name pattern try: run = parse_r0_filename(args.input_file) output_filename = output_dir / run_to_dl1_filename( run.tel_id, run.run, run.subrun) except ValueError: # for arbitrary filenames, including mc output_filename = output_dir / r0_to_dl1_filename(args.input_file.name) config = {} if args.config_file is not None: try: config = read_configuration_file(args.config_file) except Exception as e: log.error(f'Configuration file could not be read: {e}') sys.exit(1) else: config = standard_config # Add to configuration config the parameters provided through command-line, # which supersede those in the file: if args.max_events is not None: config['source_config']['EventSource']['max_events'] = args.max_events lst_event_source = config['source_config']['LSTEventSource'] time_calculator = lst_event_source['EventTimeCalculator'] if args.dragon_reference_time is not None: time_calculator['dragon_reference_time'] = args.dragon_reference_time if args.dragon_reference_counter is not None: time_calculator[ 'dragon_reference_counter'] = args.dragon_reference_counter if args.dragon_module_id is not None: time_calculator['dragon_module_id'] = args.dragon_module_id if args.run_summary_path is not None: time_calculator['run_summary_path'] = args.run_summary_path if args.pointing_file is not None: lst_event_source['PointingSource'][ 'drive_report_path'] = args.pointing_file if args.pedestal_ids_path is not None: lst_event_source['pedestal_ids_path'] = args.pedestal_ids_path if args.default_trigger_type is not None: lst_event_source["default_trigger_type"] = args.default_trigger_type lst_r0_corrections = lst_event_source['LSTR0Corrections'] if args.pedestal_file is not None: lst_r0_corrections['drs4_pedestal_path'] = args.pedestal_file if args.calibration_file is not None: lst_r0_corrections['calibration_path'] = args.calibration_file if args.time_calibration_file is not None: lst_r0_corrections[ 'drs4_time_calibration_path'] = args.time_calibration_file calib_config = config[config['calibration_product']] if args.systematic_correction_file is not None: calib_config[ 'systematic_correction_path'] = args.systematic_correction_file lst_event_source["use_flatfield_heuristic"] = args.use_flatfield_heuristic r0_to_dl1.r0_to_dl1( args.input_file, output_filename=output_filename, custom_config=config, )