-
Notifications
You must be signed in to change notification settings - Fork 0
/
Run_find_cont.py
51 lines (40 loc) · 2 KB
/
Run_find_cont.py
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
"""
This script takes the command line input in order to generate a dirty cube for each sideband per correlator
(asic and/or swarm) per track, using a coarse pixel size of 3 arcsec. Each dirty cube is then fed into the
findContinuum script, which determines the line-free channels from an averaged spectrum.
"""
import os
import sys
import glob
import numpy as np
import findContinuum
sourcename = sys.argv[6]
Phase_Center = sys.argv[3] + " " + sys.argv[4] + " " + sys.argv[5]
path = os.getcwd()
os.chdir('./'+sourcename+'_MIR/')
for filename in glob.iglob('*.fits'):
t = os.path.splitext(filename)
f = str(t[0])
if not os.path.exists(f+'.ms'):
importuvfits(fitsfile=filename, vis=f+'.ms')
else:
continue
imagesize = np.loadtxt('/reduction/czdata/dwalker/New/fcont_latest/Image_size_threshold.txt', dtype='str')
"""
Image size here is scaled since the cell size in tclean is smoothed to 3 arcsec, compared to 1 arcsec for
the final imaging. This is because the findContinuum routine takes a long time to run, especially with
small pixels and hence a large image size. As we're only interested in the averaged spectrum, we don't
care to much about image resolution at this stage.
"""
for i in range(0,len(imagesize[:]),1):
if sourcename in imagesize[i][0]:
ImageSize = [int(imagesize[i][2])/6,int(imagesize[i][2])/6]
for filename in glob.iglob('*.ms'):
t = os.path.splitext(filename)
f = str(t[0])
if not os.path.exists(f+'.dirty.image'):
tclean(vis=filename,imagename=f+'.dirty',niter=0,gain=0.1,psfmode='hogbom',imagermode='mosaic',
scaletype='SAULT',ftmachine='mosaic',interactive=False,imsize=ImageSize,cell="3arcsec",
robust=0.5,weighting='briggs',stokes='I',chaniter=False,mode='frequency',phasecenter=Phase_Center)
if not os.path.exists(f+'.dirty.image_findContinuum.dat'):
findContinuum.findContinuum(f+'.dirty.image',sigmaFindContinuum=5.0,singleContinuum=True)