Skip to content

Commit

Permalink
Adapt workflow to use config.path_data and config.path_results
Browse files Browse the repository at this point in the history
  • Loading branch information
adonath committed Oct 17, 2023
1 parent 2a455f6 commit 9d19aad
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 38 deletions.
4 changes: 2 additions & 2 deletions config/config.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
12 changes: 7 additions & 5 deletions workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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),
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),
4 changes: 2 additions & 2 deletions workflow/rules/gather.smk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rule gather_event_files:
output:
"results/events.txt"
"{config[path_results]}/events.txt"
shell:
"ls data/*_PH* > {output}"
"ls {config[path_data]}/*_PH* > {output}"
4 changes: 2 additions & 2 deletions workflow/rules/gtbin.smk
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
4 changes: 2 additions & 2 deletions workflow/rules/gtexpcube2.smk
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions workflow/rules/gtltcube.smk
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions workflow/rules/gtmktime.smk
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions workflow/rules/gtpsf.smk
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions workflow/rules/gtselect.smk
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
8 changes: 4 additions & 4 deletions workflow/rules/prepare-gp-dataset.smk
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions workflow/rules/prepare-gp-datasets-yaml.smk
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions workflow/rules/prepare-gp-model.smk
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
10 changes: 5 additions & 5 deletions workflow/rules/summarize-gp-datasets.smk
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
8 changes: 4 additions & 4 deletions workflow/rules/summarize-gp-spectra.smk
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 9d19aad

Please sign in to comment.