-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmakefile
144 lines (128 loc) · 6.1 KB
/
Smakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# https://stackoverflow.com/questions/66466082/how-do-i-write-a-snakemake-input-when-not-all-jobs-successfully-output-files-fro
import os
configfile: "config.yaml"
FIELD = config['FIELD']
CUBE = str(config['CUBE'])
wildcard_constraints:
beams="\d+"
rule all:
input:
"mos_" + FIELD + "/sm_rename_cube"+CUBE+".txt"
rule make_bin_mask:
input:
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_image_sofiaFS_mask.fits"
output:
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_image_sofiaFS_mask_bin.fits"
shell:
"python3 /mnt/scratch/stuff/aper_sf2/src/binary_mask.py -t "+FIELD+" -c "+CUBE
rule dilate_mask:
input:
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_image_sofiaFS_mask_bin.fits"
output:
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_image_sofiaFS_mask_bin_dil.fits"
shell:
"python3 /mnt/scratch/stuff/aper_sf2/src/dilate_binmask.py -t "+FIELD+" -c "+CUBE
rule smooth:
input:
FIELD+"/HI_B0{bm}_cube"+CUBE+"_spline_clean_image.fits"
output:
FIELD+"/HI_B0{bm}_cube"+CUBE+"_spline_clean_smooth_image.fits"
singularity:
"/mnt/software/containers/apercal.sif"
# threads:
# 11
shell:
"python ../scratch/stuff/aper_sf2/src/smooth_wa.py -t "+FIELD+" -b {wildcards.bm} -c "+CUBE
rule generate_new_pb:
input:
FIELD+"/HI_B0{bm}_cube"+CUBE+"_spline_clean_smooth_image.fits",
"/mnt/scratch/apertif/cbeams/{bm}_gp_avg_orig.fits"
output:
FIELD+"/HI_B0{bm}_cube"+CUBE+"_spline_clean_smooth_pb.fits"
shell:
"python3 /mnt/scratch/stuff/aper_cube_stack/modules/regrid_aperpb.py -t {input[0]} -b {wildcards.bm} -p /mnt/scratch/apertif/cbeams/"
# shell("mv {input[0]} {output}")
def aggregate_input(wildcards):
beams, = glob_wildcards(FIELD+"/HI_B0{xx}_cube"+CUBE+"_spline_clean_image.fits")
found_files = expand(FIELD+"/HI_B0{xx}_cube"+CUBE+"_spline_clean_smooth_image.fits", xx=beams)
found_files2 = expand(FIELD+"/HI_B0{xx}_cube"+CUBE+"_spline_clean_smooth_pb.fits", xx=beams)
return found_files+found_files2
checkpoint make_mosaic3:
input:
pb = aggregate_input,
output:
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image.fits",
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image.hdr",
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_noise.fits",
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_weights.fits",
temp("mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image_fields"),
temp("mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image_fields.tbl"),
temp("mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image_fields_regrid"),
temp("mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image_fields_regrid.tbl"),
temp("mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_beams_regrid"),
temp("mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_beams_regrid.tbl"),
#temp("mos_"+FIELD+"/HI_B0{beam}_cube"+CUBE+"_spline_clean_imageR.fits"),
#temp("mos_"+FIELD+"/HI_B0{beam}_cube"+CUBE+"_spline_clean_imageR_area.fits"),
#temp("mos_"+FIELD+"/HI_B0{beam}_cube"+CUBE+"_spline_clean_pbR.fits"),
#temp("mos_"+FIELD+"/HI_B0{beam}_cube"+CUBE+"_spline_clean_pbR_area.fits")
run:
input = list(input)
mos_params = " ".join([i.split("/")[1] for i in input if "spline_clean_smooth_image" in i])
os.system('mosaic-queen -mc 0.1 -n '+FIELD+'_HIcube'+CUBE+'_clean_smooth -i '+FIELD+' -o mos_'+FIELD+' -t '+mos_params+' -r')
os.system('rm -rf mos_'+FIELD+'/*imageR*')
os.system('rm -rf mos_'+FIELD+'/*pbR*')
rule dilmask:
input:
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image.fits",
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_image_sofiaFS_mask_bin_dil.fits"
output:
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_image_sofiaFS_mask_bin_dil_sm.fits"
shell:
"python ../scratch/stuff/aper_sf2/src/dilate_binmask.py -t "+FIELD+" -c "+CUBE+" -f {input[1]} -s sm"
rule run_sofia3:
input:
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image.fits",
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_image_sofiaFS_mask_bin_dil_sm.fits"
output:
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image_cat.txt",
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image_cat.xml",
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image_mask-2d.fits",
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image_mask.fits"
shell:
"/usr/bin/sofia ../scratch/stuff/aper_sf2/sofia_final_template.par input.data={input[0]} input.mask={input[1]}"
rule generate_full_spec:
input:
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image.fits",
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image_cat.xml"
output:
"mos_"+FIELD+"/sm_specfull_cube"+CUBE+".txt"
shell: # ADD PREFIX OPTION HERE! Done? Unnecessary?
"python3 ../scratch/stuff/aper_sf2/src/get_specfull.py -t "+FIELD+" -c "+CUBE+" -p sm; "
"touch {output}"
rule run_sip:
input:
"mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_smooth_image_cat.xml",
# "mos_"+FIELD+"/"+FIELD+"_HIcube"+CUBE+"_clean_image.fits",
"mos_"+FIELD+"/sm_specfull_cube"+CUBE+".txt"
output:
"mos_"+FIELD+"/sm_sip_cube"+CUBE+".txt"
shell:
"sofia_image_pipeline -c {input[0]} -s panstarrs -i 5 -m; "
#"sofia_image_pipeline -c {input[0]} -s 'DSS2 Blue' 'GALEX Near UV' -i 5 -m; "
"touch {output}"
rule edit_sip_figs:
input:
"mos_"+FIELD+"/sm_sip_cube"+CUBE+".txt"
output:
"mos_"+FIELD+"/sm_sip_cube"+CUBE+"_edit.txt"
shell:
"python3 ../scratch/stuff/aper_sf2/src/edit_sip_images.py -t "+FIELD+" -c "+CUBE+" -w; "
"touch {output}"
rule rename_pngs:
input:
"mos_" + FIELD + "/sm_sip_cube"+CUBE+"_edit.txt"
output:
"mos_" + FIELD + "/sm_rename_cube"+CUBE+".txt"
shell: # ADD PREFIX OPTION HERE! Done
"python3 ../scratch/stuff/aper_sf2/src/rename_combo.py -t " + FIELD + " -c "+CUBE+" -p sm -w; "
"touch {output}"