-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_files.py~
executable file
·42 lines (39 loc) · 1.34 KB
/
check_files.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
#!/usr/bin/env python
import glob
import os
import subprocess,shlex,shutil
import sys
# Script for converting uvfits to miriad and then performing uvlin
files = glob.glob('*.uvfits')
filebase = 'scienceData_SB8957_SMC1-1_M344-06'
interleave = sys.argv[1]
print(interleave)
# Check that the miriad file exists for every uvfits file
for beam in range(0,36):
#for file in files:
file = '%s%s.beam%02d_SL.uvfits' % (filebase,interleave,beam)
print(file)
mirfile = file.split('.uvfits')[0]+'.mir'
# If not load the file into miriad
if not os.path.exists(mirfile):
cmd = 'fits in=%s out=%s op=uvin' %(file,mirfile )
print(cmd)
args =shlex.split(cmd)
p = subprocess.Popen(args,stdout=subprocess.PIPE)
p.wait()
for beam in range(0,36):
mirfile = '%s%s.beam%02d_SL.mir' % (filebase,interleave,beam)
namestr = 'SMC_'
newfile = mirfile.replace(filebase,namestr)
tempfile = newfile.replace("beam","b")
uvlinfile = tempfile.split('.mir')[0]+'.uvlin'
cmd=' uvlin vis=%s chans=150,450,1180,1400 out=%s' %(mirfile,uvlinfile)
print(cmd)
args =shlex.split(cmd)
p = subprocess.Popen(args,stdout=subprocess.PIPE)
p.wait()
cmd='puthd in=%s/restfreq value=1.42040575' % uvlinfile
print(cmd)
args =shlex.split(cmd)
p = subprocess.Popen(args,stdout=subprocess.PIPE)
p.wait()