-
Notifications
You must be signed in to change notification settings - Fork 5
/
benchmark_beamformer.nf
271 lines (241 loc) · 9.45 KB
/
benchmark_beamformer.nf
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#!/usr/bin/env nextflow
params.help = false
if ( params.help ) {
help = """beamform.nf: A pipeline that will beamform and splice on all input pointings.
|Required argurments:
| --obsid Observation ID you want to process [no default]
| --calid Observation ID of calibrator you want to process [no default]
| --begin First GPS time to process [no default]
| --end Last GPS time to process [no default]
| --all Use entire observation span. Use instead of -b & -e. [default: false]
|
|Optional arguments:
| --summed Add this flag if you the beamformer output as summed polarisations
| (only Stokes I). This reduces the data size by a factor of 4.
| [default: False]
| --ipfb Perform an the inverse PFB to produce high time resolution beamformed
| vdif files [default: false]
| --vcstools_version
| The vcstools module version to use [default: master]
| --mwa_search_version
| The mwa_search module bersion to use [default: master]
| --no_combined_check
| Don't check if all the combined files are available [default: false]
| -w The Nextflow work directory. Delete the directory once the processs
| is finished [default: ${workDir}]""".stripMargin()
println(help)
exit(0)
}
//Work out total obs time
if ( params.all ) {
// an estimation since there's no easy way to make this work
println("Benchmarks don't need the full observation")
exit(0)
}
else {
obs_length = params.end - params.begin + 1
}
bench_max_pointings = 20
//Required temp SSD mem required for gpu jobs
temp_mem = (int) (0.0012 * obs_length * bench_max_pointings + 1)
temp_mem_single = (int) (0.0024 * obs_length + 2)
if ( ! params.summed ) {
temp_mem = temp_mem * 4
temp_mem_single = temp_mem_single *4
}
if ( params.summed ) {
bf_out = " -p -s "
}
else {
bf_out = " -p "
}
process make_pointings {
output:
path "*txt"
"""
#!/usr/bin/env python
pointing_list_list = []
arcsec = 0
p_ra, p_dec = ["00:00:00.00", "00:00:00.00"]
dec_deg, dec_min, dec_sec = p_dec.split(":")
for pn in range(1, ${bench_max_pointings} + 1):
temp_list = []
for n in range(1, pn + 1):
out_dec_sec = float(dec_sec) + arcsec
out_dec_min = int(dec_min)
out_dec_deg = int(dec_deg)
if out_dec_sec > 59:
out_dec_min = out_dec_min + out_dec_sec // 60
out_dec_sec = out_dec_sec % 60
if out_dec_min > 59:
out_dec_deg = out_dec_deg + out_dec_min // 60
out_dec_min = out_dec_min % 60
temp_list.append("{0}_{1:02d}:{2:d}:{3:05.2f}".format(p_ra,
out_dec_deg, int(out_dec_min), out_dec_sec))
arcsec += 1
pointing_list_list.append(temp_list)
for pointing_list in pointing_list_list:
with open('pointings_n{}.txt'.format(len(pointing_list)),'w') as out_file:
for pointing in pointing_list:
out_file.write("{}\\n".format(pointing))
"""
}
process make_beam {
label 'gpu'
time '12h'
errorStrategy 'retry'
maxRetries 1
maxForks 48
if ( "$HOSTNAME".startsWith("farnarkle") ) {
clusterOptions = "--gres=gpu:1 --tmp=${temp_mem}GB"
scratch '$JOBFS'
beforeScript "module use ${params.module_dir}; module load vcstools/${params.vcstools_version}"
}
else if ( "$HOSTNAME".startsWith("x86") ) {
clusterOptions = "--gres=gpu:1"
scratch '/ssd'
//container = "file:///${params.containerDir}/vcstools/vcstools_${params.vcstools_version}.sif"
beforeScript "module use ${params.module_dir}; module load vcstools/${params.vcstools_version}"
}
else if ( "$HOSTNAME".startsWith("garrawarla") ) {
clusterOptions = "--gres=gpu:1 --tmp=${temp_mem}GB"
scratch '/nvmetmp'
//container = "file:///${params.containerDir}/vcstools/vcstools_${params.vcstools_version}.sif"
beforeScript "module use ${params.module_dir}; module load vcstools/${params.vcstools_version}"
}
else if ( "$HOSTNAME".startsWith("galaxy") ) {
beforeScript "module use ${params.module_dir}; module load vcstools/${params.vcstools_version}"
}
else {
container = "cirapulsarsandtransients/vcstools:${params.vcstools_version}"
}
input:
each channel_pair
val utc
each point
tuple val(begin), val(end)
output:
path "make_beam*txt"
"""
make_beam -o $params.obsid -b $begin -e $end -a 128 -n 128 \
-f ${channel_pair[0]} -J ${params.didir}/DI_JonesMatrices_node${channel_pair[1]}.dat \
-d ${params.vcsdir}/${params.obsid}/combined -P ${point.join(",")} \
-r 10000 -m ${params.vcsdir}/${params.obsid}/${params.obsid}_metafits_ppds.fits \
${bf_out} -t 6000 -z $utc &> make_beam_${channel_pair[1]}_n${point.size()}_output.txt
rm */*fits
"""
}
process make_beam_ipfb {
label 'gpu'
time '12h'
errorStrategy 'retry'
maxRetries 1
maxForks 12
if ( "$HOSTNAME".startsWith("farnarkle") ) {
clusterOptions = "--gres=gpu:1 --tmp=${temp_mem_single}GB"
scratch '$JOBFS'
beforeScript "module use ${params.module_dir}; module load vcstools/${params.vcstools_version}"
}
else if ( "$HOSTNAME".startsWith("x86") ) {
clusterOptions = "--gres=gpu:1"
scratch '/ssd'
container = "file:///${params.containerDir}/vcstools/vcstools_${params.vcstools_version}.sif"
}
else if ( "$HOSTNAME".startsWith("garrawarla") ) {
clusterOptions = "--gres=gpu:1 --tmp=${temp_mem_single}GB"
scratch '/nvmetmp'
//container = "file:///${params.containerDir}/vcstools/vcstools_${params.vcstools_version}.sif"
beforeScript "module use ${params.module_dir}; module load vcstools/${params.vcstools_version}"
}
else if ( "$HOSTNAME".startsWith("galaxy") ) {
beforeScript "module use ${params.module_dir}; module load vcstools/${params.vcstools_version}"
}
else {
container = "cirapulsarsandtransients/vcstools:${params.vcstools_version}"
}
input:
each channel_pair
val utc
each point
tuple val(begin), val(end)
output:
path "make_beam*txt"
"""
make_beam -o $params.obsid -b $begin -e $end -a 128 -n 128 \
-f ${channel_pair[0]} -J ${params.didir}/DI_JonesMatrices_node${channel_pair[1]}.dat \
-d ${params.vcsdir}/${params.obsid}/combined -P ${point} \
-r 10000 -m ${params.vcsdir}/${params.obsid}/${params.obsid}_metafits_ppds.fits \
-p -v -t 6000 -z $utc &> make_beam_${channel_pair[1]}_IPFB_output.txt
rm */*fits
"""
}
process make_beam_single {
label 'gpu'
time '12h'
errorStrategy 'retry'
maxRetries 1
maxForks 12
if ( "$HOSTNAME".startsWith("galaxy") ) {
beforeScript "module use ${params.module_dir}; module load vcstools/nswainston"
}
else if ( "$HOSTNAME".startsWith("farnarkle") ) {
clusterOptions = "--gres=gpu:1 --tmp=${temp_mem_single}GB"
scratch '$JOBFS'
container = "file:///${params.containerDir}/vcstools/vcstools_single-pixel_legacy.sif"
}
else if ( "$HOSTNAME".startsWith("x86") ) {
clusterOptions = "--gres=gpu:1"
scratch '/ssd'
container = "file:///${params.containerDir}/vcstools/vcstools_single-pixel_legacy.sif"
}
else if ( "$HOSTNAME".startsWith("garrawarla") ) {
clusterOptions = "--gres=gpu:1 --tmp=${temp_mem_single}GB"
scratch '/nvmetmp'
container = "file:///${params.containerDir}/vcstools/vcstools_single-pixel_legacy.sif"
//beforeScript "module use ${params.module_dir}; module load vcstools/${params.vcstools_version}"
}
input:
each channel_pair
val utc
val point
tuple val(begin), val(end)
output:
path "make_beam*txt"
"""
make_beam -o $params.obsid -b $begin -e $end -a 128 -n 128 \
-f ${channel_pair[0]} -J ${params.didir}/DI_JonesMatrices_node${channel_pair[1]}.dat \
-d ${params.vcsdir}/${params.obsid}/combined -R ${point.split("_")[0]} -D ${point.split("_")[1]} \
-r 10000 -m ${params.vcsdir}/${params.obsid}/${params.obsid}_metafits_ppds.fits \
-p -z $utc &> make_beam_${channel_pair[1]}_single-pixel_output.txt
rm *fits
"""
}
process calc_beamformer_benchmarks {
input:
path files
output:
stdout()
"""
calc_beamformer_benchmarks.py --max_pointing_num ${bench_max_pointings}
"""
}
include { pre_beamform } from './beamform_module'
single_pointing = Channel.of("00:00:00.00_00:00:00.00")
workflow {
pre_beamform()
make_pointings()
make_beam( pre_beamform.out[1],\
pre_beamform.out[2],\
make_pointings.out.flatten().map{ it -> it.splitCsv().collect().flatten() },\
pre_beamform.out[0] )
make_beam_single( pre_beamform.out[1],\
pre_beamform.out[2],\
single_pointing,\
pre_beamform.out[0] )
make_beam_ipfb( pre_beamform.out[1],\
pre_beamform.out[2],\
single_pointing,\
pre_beamform.out[0] )
calc_beamformer_benchmarks( make_beam.out.concat(make_beam_single.out, make_beam_ipfb.out).collect() )
calc_beamformer_benchmarks.out.view()
}