From 441531f26a5d59e7086bc79f940467cfbe75376a Mon Sep 17 00:00:00 2001 From: Elisa-Visentin Date: Tue, 10 Sep 2024 10:43:54 +0000 Subject: [PATCH 1/2] fix config --- .../semi_automatic_scripts/dl1_production.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/magicctapipe/scripts/lst1_magic/semi_automatic_scripts/dl1_production.py b/magicctapipe/scripts/lst1_magic/semi_automatic_scripts/dl1_production.py index bfd17707e..8f608934a 100644 --- a/magicctapipe/scripts/lst1_magic/semi_automatic_scripts/dl1_production.py +++ b/magicctapipe/scripts/lst1_magic/semi_automatic_scripts/dl1_production.py @@ -41,7 +41,7 @@ logger.setLevel(logging.INFO) -def config_file_gen(target_dir, source_name, config_file): +def config_file_gen(target_dir, source_name, config_dict): """ Here we create the configuration file needed for transforming DL0 into DL1 @@ -52,17 +52,10 @@ def config_file_gen(target_dir, source_name, config_file): Directory to store the results source_name : str Name of the target source - config_file : str - Path to MCP configuration file (e.g., resources/config.yaml) + config_dict : dict + Dictionary of a configuration file (e.g., resources/config.yaml) """ - if config_file == "": - config_file = resource_file("config.yaml") - with open( - config_file, "rb" - ) as fc: # "rb" mode opens the file in binary format for reading - config_dict = yaml.safe_load(fc) - conf = { "mc_tel_ids": config_dict["mc_tel_ids"], "LST": config_dict["LST"], @@ -213,13 +206,21 @@ def main(): ) as f: # "rb" mode opens the file in binary format for reading config = yaml.safe_load(f) - telescope_ids = list(config["mc_tel_ids"].values()) + env_name = config["general"]["env_name"] config_file = config["general"]["base_config_file"] source_in = config["data_selection"]["source_name_database"] source = config["data_selection"]["source_name_output"] cluster = config["general"]["cluster"] target_dir = Path(config["directories"]["workspace_dir"]) + + if config_file == "": + config_file = resource_file("config.yaml") + with open( + config_file, "rb" + ) as fc: # "rb" mode opens the file in binary format for reading + config_dict = yaml.safe_load(fc) + telescope_ids = list(config_dict["mc_tel_ids"].values()) if source_in is None: source_list = joblib.load("list_sources.dat") @@ -244,7 +245,7 @@ def main(): directories_generator_real( str(target_dir), telescope_ids, MAGIC_runs, source_name ) # Here we create all the necessary directories in the given workspace and collect the main directory of the target - config_file_gen(target_dir, source_name, config_file) + config_file_gen(target_dir, source_name, config_dict) # Below we run the analysis on the MAGIC data From 5a7d22fe53f602487868f06161560cdf915212b4 Mon Sep 17 00:00:00 2001 From: Elisa-Visentin Date: Tue, 10 Sep 2024 13:24:41 +0000 Subject: [PATCH 2/2] lint --- .../lst1_magic/semi_automatic_scripts/dl1_production.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/magicctapipe/scripts/lst1_magic/semi_automatic_scripts/dl1_production.py b/magicctapipe/scripts/lst1_magic/semi_automatic_scripts/dl1_production.py index 8f608934a..ef1e9d36c 100644 --- a/magicctapipe/scripts/lst1_magic/semi_automatic_scripts/dl1_production.py +++ b/magicctapipe/scripts/lst1_magic/semi_automatic_scripts/dl1_production.py @@ -206,14 +206,13 @@ def main(): ) as f: # "rb" mode opens the file in binary format for reading config = yaml.safe_load(f) - env_name = config["general"]["env_name"] config_file = config["general"]["base_config_file"] source_in = config["data_selection"]["source_name_database"] source = config["data_selection"]["source_name_output"] cluster = config["general"]["cluster"] target_dir = Path(config["directories"]["workspace_dir"]) - + if config_file == "": config_file = resource_file("config.yaml") with open(