From 9d19aad6eb3d201fc3f89886b18bc77fc0b69f20 Mon Sep 17 00:00:00 2001 From: Axel Donath Date: Tue, 17 Oct 2023 09:53:51 -0400 Subject: [PATCH] Adapt workflow to use config.path_data and config.path_results --- config/config.yaml | 4 ++-- workflow/Snakefile | 12 +++++++----- workflow/rules/gather.smk | 4 ++-- workflow/rules/gtbin.smk | 4 ++-- workflow/rules/gtexpcube2.smk | 4 ++-- workflow/rules/gtltcube.smk | 4 ++-- workflow/rules/gtmktime.smk | 4 ++-- workflow/rules/gtpsf.smk | 4 ++-- workflow/rules/gtselect.smk | 4 ++-- workflow/rules/prepare-gp-dataset.smk | 8 ++++---- workflow/rules/prepare-gp-datasets-yaml.smk | 4 ++-- workflow/rules/prepare-gp-model.smk | 4 ++-- workflow/rules/summarize-gp-datasets.smk | 10 +++++----- workflow/rules/summarize-gp-spectra.smk | 8 ++++---- 14 files changed, 40 insertions(+), 38 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index c685214..429cd3e 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -1,7 +1,7 @@ name: my-config scfile: data/L231017092559388FF7BE86_SC00.fits -data_path: data/ -result_path: results/ +path_data: data/ +path_results: results/ event_types: ["psf0", "psf1", "psf2", "psf3"] fermitools: gtselect: diff --git a/workflow/Snakefile b/workflow/Snakefile index 82986db..cf9525e 100644 --- a/workflow/Snakefile +++ b/workflow/Snakefile @@ -271,6 +271,8 @@ class FermiToolsConfig(BaseConfig): class SnakeMakeFermiLATConfig(BaseConfig): name: str = "my-config" scfile: str + path_data: str = "data" + path_results: str = "results" event_types: List[EventTypeEnum] = ["FRONT", "BACK"] ltcube: Optional[str] = None fermitools = FermiToolsConfig = FermiToolsConfig() @@ -304,8 +306,8 @@ include: "rules/summarize-gp-spectra.smk" # all rule rule all: input: - expand("results/{config_name}/datasets/{config_name}-{event_type}-dataset.fits", config_name=config_obj.name, event_type=config_obj.event_types), - expand("results/{config_name}/datasets/{config_name}-datasets-all.yaml", config_name=config_obj.name), - expand("results/{config_name}/model/{config_name}-model.yaml", config_name=config_obj.name), - expand("results/{config_name}/summary/images/{event_type}/{config_name}-{event_type}-counts-image.png", config_name=config_obj.name, event_type=config_obj.event_types), - expand("results/{config_name}/summary/images/{config_name}-counts-spectra.png", config_name=config_obj.name), \ No newline at end of file + expand("config[path_results]/{config_name}/datasets/{config_name}-{event_type}-dataset.fits", config_name=config_obj.name, event_type=config_obj.event_types), + expand("config[path_results]/{config_name}/datasets/{config_name}-datasets-all.yaml", config_name=config_obj.name), + expand("config[path_results]/{config_name}/model/{config_name}-model.yaml", config_name=config_obj.name), + expand("config[path_results]/{config_name}/summary/images/{event_type}/{config_name}-{event_type}-counts-image.png", config_name=config_obj.name, event_type=config_obj.event_types), + expand("config[path_results]/{config_name}/summary/images/{config_name}-counts-spectra.png", config_name=config_obj.name), \ No newline at end of file diff --git a/workflow/rules/gather.smk b/workflow/rules/gather.smk index 81c90a4..bb7ac0b 100644 --- a/workflow/rules/gather.smk +++ b/workflow/rules/gather.smk @@ -1,5 +1,5 @@ rule gather_event_files: output: - "results/events.txt" + "{config[path_results]}/events.txt" shell: - "ls data/*_PH* > {output}" \ No newline at end of file + "ls {config[path_data]}/*_PH* > {output}" \ No newline at end of file diff --git a/workflow/rules/gtbin.smk b/workflow/rules/gtbin.smk index 66e507d..52e1169 100644 --- a/workflow/rules/gtbin.smk +++ b/workflow/rules/gtbin.smk @@ -1,8 +1,8 @@ rule gtbin: input: - "results/{config_name}/events/filtered/{config_name}-{event_type}-events-selected-filtered.fits" + "config[path_results]/{config_name}/events/filtered/{config_name}-{event_type}-events-selected-filtered.fits" output: - "results/{config_name}/maps/{event_type}/{config_name}-{event_type}-counts.fits" + "config[path_results]/{config_name}/maps/{event_type}/{config_name}-{event_type}-counts.fits" log: "logs/{config_name}/{event_type}/gtbin.log" run: args = gtbin.to_cmd_args() diff --git a/workflow/rules/gtexpcube2.smk b/workflow/rules/gtexpcube2.smk index ae46b75..3b3dd34 100644 --- a/workflow/rules/gtexpcube2.smk +++ b/workflow/rules/gtexpcube2.smk @@ -1,8 +1,8 @@ rule gtexpcube2: input: - "results/{config_name}/{config_name}-ltcube.fits" + "config[path_results]/{config_name}/{config_name}-ltcube.fits" output: - "results/{config_name}/maps/{event_type}/{config_name}-{event_type}-exposure.fits" + "config[path_results]/{config_name}/maps/{event_type}/{config_name}-{event_type}-exposure.fits" log: "logs/{config_name}/{event_type}/gtexpcube2.log" run: diff --git a/workflow/rules/gtltcube.smk b/workflow/rules/gtltcube.smk index 9ed09ea..911a62c 100644 --- a/workflow/rules/gtltcube.smk +++ b/workflow/rules/gtltcube.smk @@ -1,8 +1,8 @@ rule gtltcube: input: - expand("results/{config_name}/events/filtered/{config_name}-{event_type}-events-selected-filtered.fits", config_name=config["name"], event_type=config_obj.event_types) + expand("config[path_results]/{config_name}/events/filtered/{config_name}-{event_type}-events-selected-filtered.fits", config_name=config["name"], event_type=config_obj.event_types) output: - "results/{config_name}/{config_name}-ltcube.fits" + "config[path_results]/{config_name}/{config_name}-ltcube.fits" log: "logs/{config_name}/gtltcube.log" run: diff --git a/workflow/rules/gtmktime.smk b/workflow/rules/gtmktime.smk index 15f4e1b..e7021d7 100644 --- a/workflow/rules/gtmktime.smk +++ b/workflow/rules/gtmktime.smk @@ -1,8 +1,8 @@ rule gtmktime: input: - "results/{config_name}/events/{config_name}-{event_type}-events-selected.fits" + "config[path_results]/{config_name}/events/{config_name}-{event_type}-events-selected.fits" output: - "results/{config_name}/events/filtered/{config_name}-{event_type}-events-selected-filtered.fits" + "config[path_results]/{config_name}/events/filtered/{config_name}-{event_type}-events-selected-filtered.fits" log: "logs/{config_name}/{event_type}/gtmktime.log" run: diff --git a/workflow/rules/gtpsf.smk b/workflow/rules/gtpsf.smk index df4042f..998aea9 100644 --- a/workflow/rules/gtpsf.smk +++ b/workflow/rules/gtpsf.smk @@ -1,8 +1,8 @@ rule gtpsf: input: - "results/{config_name}/{config_name}-ltcube.fits" + "config[path_results]/{config_name}/{config_name}-ltcube.fits" output: - "results/{config_name}/maps/{event_type}/{config_name}-{event_type}-psf.fits" + "config[path_results]/{config_name}/maps/{event_type}/{config_name}-{event_type}-psf.fits" log: "logs/{config_name}/{event_type}/gtpsf.log" run: diff --git a/workflow/rules/gtselect.smk b/workflow/rules/gtselect.smk index 56b09d2..67bb763 100644 --- a/workflow/rules/gtselect.smk +++ b/workflow/rules/gtselect.smk @@ -1,8 +1,8 @@ rule gtselect: input: - "results/events.txt" + "config[path_results]/events.txt" output: - "results/{config_name}/events/{config_name}-{event_type}-events-selected.fits" + "config[path_results]/{config_name}/events/{config_name}-{event_type}-events-selected.fits" log: "logs/{config_name}/{event_type}/gtselect.log" run: diff --git a/workflow/rules/prepare-gp-dataset.smk b/workflow/rules/prepare-gp-dataset.smk index 6328445..a53eab0 100644 --- a/workflow/rules/prepare-gp-dataset.smk +++ b/workflow/rules/prepare-gp-dataset.smk @@ -1,10 +1,10 @@ rule prepare_gp_dataset: input: - "results/{config_name}/maps/{event_type}/{config_name}-{event_type}-counts.fits", - "results/{config_name}/maps/{event_type}/{config_name}-{event_type}-exposure.fits", - "results/{config_name}/maps/{event_type}/{config_name}-{event_type}-psf.fits", + "config[path_results]/{config_name}/maps/{event_type}/{config_name}-{event_type}-counts.fits", + "config[path_results]/{config_name}/maps/{event_type}/{config_name}-{event_type}-exposure.fits", + "config[path_results]/{config_name}/maps/{event_type}/{config_name}-{event_type}-psf.fits", output: - "results/{config_name}/datasets/{config_name}-{event_type}-dataset.fits", + "config[path_results]/{config_name}/datasets/{config_name}-{event_type}-dataset.fits", log: "logs/{config_name}/{event_type}/prepare-gp-dataset.log" run: diff --git a/workflow/rules/prepare-gp-datasets-yaml.smk b/workflow/rules/prepare-gp-datasets-yaml.smk index b286460..f4125a8 100644 --- a/workflow/rules/prepare-gp-datasets-yaml.smk +++ b/workflow/rules/prepare-gp-datasets-yaml.smk @@ -1,8 +1,8 @@ rule prepare_gp_datasets_yaml: input: - expand("results/{config_name}/datasets/{config_name}-{event_type}-dataset.fits", config_name=config["name"], event_type=config_obj.event_types) + expand("config[path_results]/{config_name}/datasets/{config_name}-{event_type}-dataset.fits", config_name=config["name"], event_type=config_obj.event_types) output: - "results/{config_name}/datasets/{config_name}-datasets-all.yaml" + "config[path_results]/{config_name}/datasets/{config_name}-datasets-all.yaml" log: "logs/{config_name}/prepare-gp-datasets-yaml.log" run: diff --git a/workflow/rules/prepare-gp-model.smk b/workflow/rules/prepare-gp-model.smk index 3dd9002..f199451 100644 --- a/workflow/rules/prepare-gp-model.smk +++ b/workflow/rules/prepare-gp-model.smk @@ -1,7 +1,7 @@ rule prepare_gp_model: output: - "results/{config_name}/model/{config_name}-model.yaml", - "results/{config_name}/model/{config_name}-galactic-diffuse-model.fits", + "config[path_results]/{config_name}/model/{config_name}-model.yaml", + "config[path_results]/{config_name}/model/{config_name}-galactic-diffuse-model.fits", log: "logs/{config_name}/prepare-gp-model.log" run: diff --git a/workflow/rules/summarize-gp-datasets.smk b/workflow/rules/summarize-gp-datasets.smk index 09cbee5..a467e43 100644 --- a/workflow/rules/summarize-gp-datasets.smk +++ b/workflow/rules/summarize-gp-datasets.smk @@ -1,12 +1,12 @@ rule summarize_gp_dataset: input: - "results/{config_name}/datasets/{config_name}-{event_type}-dataset.fits" + "config[path_results]/{config_name}/datasets/{config_name}-{event_type}-dataset.fits" output: - report("results/{config_name}/summary/images/{event_type}/{config_name}-{event_type}-counts-image.png", caption="../report/caption-counts.rst", category="Counts", subcategory="{event_type}"), - report("results/{config_name}/summary/images/{event_type}/{config_name}-{event_type}-counts-grid.png", caption="../report/caption-counts.rst", category="Counts", subcategory="{event_type}"), + report("config[path_results]/{config_name}/summary/images/{event_type}/{config_name}-{event_type}-counts-image.png", caption="../report/caption-counts.rst", category="Counts", subcategory="{event_type}"), + report("config[path_results]/{config_name}/summary/images/{event_type}/{config_name}-{event_type}-counts-grid.png", caption="../report/caption-counts.rst", category="Counts", subcategory="{event_type}"), - report("results/{config_name}/summary/images/{event_type}/{config_name}-{event_type}-exposure-image.png", caption="../report/caption-exposure.rst", category="Exposure", subcategory="{event_type}"), - report("results/{config_name}/summary/images/{event_type}/{config_name}-{event_type}-exposure-grid.png", caption="../report/caption-exposure.rst", category="Exposure", subcategory="{event_type}"), + report("config[path_results]/{config_name}/summary/images/{event_type}/{config_name}-{event_type}-exposure-image.png", caption="../report/caption-exposure.rst", category="Exposure", subcategory="{event_type}"), + report("config[path_results]/{config_name}/summary/images/{event_type}/{config_name}-{event_type}-exposure-grid.png", caption="../report/caption-exposure.rst", category="Exposure", subcategory="{event_type}"), log: "logs/{config_name}/{event_type}/prepare-gp-dataset.log" run: diff --git a/workflow/rules/summarize-gp-spectra.smk b/workflow/rules/summarize-gp-spectra.smk index ca42231..0d59915 100644 --- a/workflow/rules/summarize-gp-spectra.smk +++ b/workflow/rules/summarize-gp-spectra.smk @@ -1,10 +1,10 @@ rule summarize_gp_spectra: input: - "results/{config_name}/datasets/{config_name}-datasets-all.yaml" + "config[path_results]/{config_name}/datasets/{config_name}-datasets-all.yaml" output: - report("results/{config_name}/summary/images/{config_name}-counts-spectra.png", caption="../report/caption-counts.rst", category="Counts"), - report("results/{config_name}/summary/images/{config_name}-exposure-spectra.png", caption="../report/caption-counts.rst", category="Exposure"), - report("results/{config_name}/summary/images/{config_name}-psf-spectra.png", caption="../report/caption-counts.rst", category="PSF"), + report("config[path_results]/{config_name}/summary/images/{config_name}-counts-spectra.png", caption="../report/caption-counts.rst", category="Counts"), + report("config[path_results]/{config_name}/summary/images/{config_name}-exposure-spectra.png", caption="../report/caption-counts.rst", category="Exposure"), + report("config[path_results]/{config_name}/summary/images/{config_name}-psf-spectra.png", caption="../report/caption-counts.rst", category="PSF"), log: "logs/{config_name}/summarize-gp-spectra.log" run: