-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolarkat-pipeline.yml
502 lines (431 loc) · 13.5 KB
/
solarkat-pipeline.yml
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
_include:
- omstimelation/oms-cabs.yml
# # override default imaging settings from oms-cabs
lib:
steps:
wsclean:
base:
params:
ms: '{recipe.ms}'
prefix: '{recipe.image-prefix}'
size: 6076
scale: 1.5asec
## this augments the standard 'opts' config section to tweak logging settings
opts:
log:
dir: './{root.dir_out}/logs/log-{run.datetime}'
name: log-{info.fqname}.txt
nest: 2
symlink: log
boom:
name: boom
info: "imaging of deep transient follow-up"
assign:
image-prefix: '{recipe.dir_out}/im{info.suffix}/im{info.suffix}{recipe.suffix}'
mask-prefix: '{recipe.dir_out}/im{info.suffix}/mask{info.suffix}{recipe.suffix}'
assign_based_on:
obs:
L1:
ms: MIGHTEE_CDFS_raw-J0333_2741-corr.ms
dir_out: obs1lb
perscan_dir_out: perscan_ms
pertime_dir_out: pertime_ms
perscan_ms_name: MIGHTEE_CDFS_raw-J0333_2741-corr-split.ms
sun_images: image_sun
band: L
inputs:
obs:
choices: [L1]
info: "Selects observation, see labels above"
suffix:
dtype: str
default: ''
dir_out:
dtype: str
ms:
dtype: MS
splitted_ms_suffix:
dtype: str
default: '_scan_'
ms_list:
dtype: List[MS]
steps:
image-1:
info: "auto-masked deep I clean"
_use: lib.steps.wsclean.image
params:
column: DATA
temp_dir: temp_dir
save-source-list: false
mask-1:
cab: breizorro
params:
restored_image: "{previous.restored-mfs}"
mask: '{previous.prefix}-mask.fits'
threshold: 20
image-2:
info: "auto-masked deep I clean"
_use: lib.steps.wsclean.image
params:
column: DATA
fits-mask: "{previous.mask}"
temp_dir: temp_dir
save-source-list: false
save-flags-1:
cab: flagman
params:
ms: '{recipe.ms}'
name: "after 1GC"
mode: save
restore-flags-1:
cab: flagman
params:
ms: '{recipe.ms}'
name: "after 1GC"
mode: restore
quartical_1:
cab: quartical
info: "Peel off axis source"
params:
input_ms.path: '{recipe.ms}'
solver.terms: [K]
K.type: phase
K.direction_dependent: false
K.freq_interval: '0'
K.time_interval: '4'
K.initial_estimate: true
input_ms.time_chunk: '128'
solver.iter_recipe: [100]
input_model.recipe: MODEL_DATA
output.overwrite: 'true'
output.products: [corrected_data]
output.columns: [SELFCAL_DATA]
save-flags-2:
cab: flagman
params:
ms: '{recipe.ms}'
name: "after 2GC"
mode: save
image-3:
info: "auto-masked deep I clean"
_use: lib.steps.wsclean.image
params:
column: SELFCAL_DATA
temp_dir: temp_dir
save-source-list: false
fits-mask: "{steps.image-1.prefix}-mask.fits"
mask-2:
cab: breizorro
params:
restored_image: "{previous.restored-mfs}"
mask: '{previous.prefix}-mask.fits'
threshold: 5
image-4:
info: "auto-masked deep I clean"
_use: lib.steps.wsclean.image
params:
column: SELFCAL_DATA
temp_dir: temp_dir
save-source-list: true
fits-mask: "{previous.mask}"
niter: 1000000
multiscale: false
backup_UVW:
cab: backup_UVW
params:
ms: '{recipe.ms}'
UVW_colname: 'UVW'
restore_UVW:
cab: restore_UVW
skip: true
params:
ms: '{recipe.ms}'
UVW_colname: 'UVW'
scan_numbers:
cab:
command: |
from casacore.tables import table
import numpy
scans=[]
maintab = table(ms,ack=False)
scan_no = list(numpy.unique(maintab.getcol('SCAN_NUMBER')))
for scan in scan_no:
scans.append(str(scan))
print(scans)
flavour: python-code
inputs:
ms:
dtype: MS
outputs:
scans:
dtype: List[str]
params:
ms: '{recipe.ms}'
split_ms_by_scan:
params:
scan_list: '=steps.scan_numbers.scans'
ms: '=steps.scan_numbers.ms'
recipe:
inputs:
scan_list:
dtype: List[str]
ms:
dtype: MS
for_loop:
var: scan
over: scan_list
steps:
casa_split_scan:
cab: splitms_scan
params:
vis: '{root.ms}'
scan: '{recipe.scan}'
outputvis: '{root.dir_out}/{root.perscan_dir_out}/{recipe.ms}-scan-{recipe.scan@index}'
datacolumn: DATA
sun_coordinates:
cab: sun_coordinates
params:
ms: '{recipe.ms}'
outfile: 'sun_coordinates.txt'
shift_to_sun:
cab: shift_to_sun
params:
ms: '{recipe.ms}'
sun_coords: '{previous.outfile}'
splitted_ms_dir: '{recipe.dir_out}/{recipe.perscan_dir_out}'
image_sun:
params:
ms_list: =GLOB("{recipe.dir_out}/{recipe.perscan_dir_out}/*scan*.ms") # insert folder path then glob#
image-prefix: '{recipe.dir_out}/im-sun{info.suffix}/im{info.suffix}{recipe.suffix}'
recipe:
inputs:
ms_list:
dtype: List[MS]
image-prefix:
dtype: str
for_loop:
var: mss
over: ms_list
steps:
image:
_use: lib.steps.wsclean.image
params:
ms: '{recipe.mss}'
prefix: '{recipe.image-prefix}'
column: DATA
temp_dir: temp_dir
niter: 1
multiscale: false
subtract-model: true
#--------------------------------------------------------#
#split individual scans further by time#
#--------------------------------------------------------#
split_ms_by_time:
params:
ms_list: =GLOB("{recipe.dir_out}/{recipe.perscan_dir_out}/*scan*.ms") #insert folder path then glob#
image-prefix: '{recipe.dir_out}/im-sun{info.suffix}/im{info.suffix}{recipe.suffix}'
recipe:
inputs:
ms_list:
dtype: List[MS]
image-prefix:
dtype: str
for_loop:
var: mss
over: ms_list
steps:
perscan_get_timeranges:
cab: perscan_timerange_intervals
params:
scan_list: '{recipe.mss}'
interval: 3
loop_timeranges:
params:
timeranges: '=steps.perscan_get_timeranges.timeranges'
ms: '=steps.perscan_get_timeranges.scan_list'
recipe:
inputs:
ms:
dtype: MS
timeranges:
dtype: List[str]
for_loop:
var: timerange
over: timeranges
steps:
Casa-split-time:
cab: splitms_time
params:
vis: '{recipe.ms}'
timerange: '{recipe.timerange}'
outputvis: '{recipe.ms}-interval-{recipe.timerange@index}'
datacolumn: DATA
sun_coordinates_by_time:
params:
timerange_ms_list: =GLOB("{recipe.dir_out}/{recipe.pertime_dir_out}/*interval*") # insert folder path then glob#
recipe:
inputs:
timerange_ms_list:
dtype: List[MS]
image-prefix:
dtype: str
for_loop:
var: mss
over: timerange_ms_list
steps:
sun_coordinates:
cab: pertime_sun_coordinates
params:
ms: '{recipe.mss}'
# sun_coordinates_by_time:
# params:
# timerange_ms_list: =GLOB("{recipe.dir_out}/{recipe.pertime_dir_out}/*interval*") # insert folder path then glob#
# recipe:
# inputs:
# timerange_ms_list:
# dtype: List[MS]
# image-prefix:
# dtype: str
# for_loop:
# var: mss
# over: timerange_ms_list
# steps:
# sun_coordinates:
# cab:
# command: |
# from astropy.coordinates import solar_system_ephemeris, EarthLocation, AltAz
# from astropy.coordinates import get_body_barycentric, get_body, get_moon
# from pyrap.tables import table
# import numpy
# from astropy.time import Time
# from astropy.coordinates import SkyCoord
# from astropy import units as u
# def format_coords(ra0,dec0):
# c = SkyCoord(ra0*u.deg,dec0*u.deg,frame='fk5')
# hms = str(c.ra.to_string(u.hour))
# dms = str(c.dec)
# return hms,dms
# # MeerKAT
# obs_lat = -30.71323598930457
# obs_lon = 21.443001467965008
# loc = EarthLocation.from_geodetic(obs_lat,obs_lon) #,obs_height,ellipsoid)
# maintab = table(ms,ack=False)
# scans = list(numpy.unique(maintab.getcol('SCAN_NUMBER')))
# lines=[]
# t_scan = numpy.mean(maintab.getcol('TIME'))
# t = Time(t_scan/86400.0,format='mjd')
# with solar_system_ephemeris.set('builtin'):
# sun = get_body('Sun', t, loc)
# sun_ra = sun.ra.value
# sun_dec = sun.dec.value
# sun_hms=format_coords(sun_ra,sun_dec)
# sun_coordinates=str(sun_hms)
# print(sun_coordinates)
# flavour: python-code
# inputs:
# ms:
# dtype: MS
# outputs:
# sun_coordinates:
# dtype: str
# params:
# ms: '{recipe.mss}'
# shift_to_sun_pertime:
# cab:
# command: |
# import numpy
# from pyrap.tables import table
# import sys, os
# maintab = table(ms,ack=False)
# os.system(f"chgcentre {ms} {sun_coordinate}")
# UVW_new=maintab.getcol('UVW')
# #UVW_old=maintab.getcol('UVW_backup')
# #print(UVW_new,'Old UVW are:')
# print(UVW_new,'New UVW are:')
# flavour: python-code
# inputs:
# ms:
# dtype: MS
# required: true
# sun_coordinate:
# dtype: str
# params:
# ms: '=steps.sun_coordinates.ms'
# sun_coordinate: '=steps.sun_coordinates.sun_coordinates'
split_ms_by_time2:
params:
ms_list: =GLOB("{recipe.dir_out}/{recipe.perscan_dir_out}/*scan*.ms") # insert folder path then glob#
image-prefix: '{recipe.dir_out}/im-sun{info.suffix}/im{info.suffix}{recipe.suffix}'
recipe:
inputs:
ms_list:
dtype: List[MS]
image-prefix:
dtype: str
for_loop:
var: mss
over: ms_list
steps:
perscan_get_timeranges:
cab:
command: |
from pyrap.tables import table
from astropy.time import Time
import numpy as np
dic={ "-": "/", " ":"/"}
def replace_all(text, dic):
for i, j in dic.items():
text = text.replace(i, j)
return text
array=[]
timerange_array=[]
tb = table(scan_list)
all_times = list(np.unique(tb.getcol('TIME')))
t0 = all_times[0]
t1 = all_times[-1]
dt = (t1-t0)/(interval)
for i in range(interval):
t2=dt*i+t0
t_iso = Time(t2/86400.0,format='mjd').iso
array.append(t_iso)
for i in range(len(array)):
if i < (len(array)-1):
timerange=replace_all(array[i],dic)+'~'+replace_all(array[i+1],dic)
timerange_array.append(timerange)
else:
print()
timeranges=timerange_array
print(timerange_array)
flavour: python-code
inputs:
scan_list:
dtype: MS
interval:
dtype: int
outputs:
timeranges:
dtype: List[str]
params:
scan_list: '{recipe.mss}'
interval: 3
loop_timeranges:
params:
timeranges: '=steps.perscan_get_timeranges.timeranges'
ms: '=steps.perscan_get_timeranges.scan_list'
recipe:
inputs:
ms:
dtype: MS
timeranges:
dtype: List[str]
for_loop:
var: timerange
over: timeranges
steps:
Casa-split-time:
cab: splitms_time
params:
vis: '{recipe.ms}'
timerange: '{recipe.timerange}'
outputvis: '{recipe.ms}-interval-{recipe.timerange@index}'
datacolumn: DATA