Source
1
1
from __future__ import absolute_import
2
2
import os
3
3
import shutil
4
4
import string
5
5
import copy
6
6
import math
7
-
from taskinit import mttool, mstool, casalog
8
-
from mstools import write_history
9
-
from parallel.parallel_data_helper import ParallelDataHelper
10
-
import flaghelper as fh
7
+
8
+
# get is_CASA6 and is_python3
9
+
from casatasks.private.casa_transition import *
10
+
if is_CASA6:
11
+
from casatasks import casalog
12
+
from casatools import ms, mstransformer
13
+
from .parallel.parallel_data_helper import ParallelDataHelper
14
+
from . import flaghelper as fh
15
+
from .mstools import write_history
16
+
else:
17
+
from taskinit import mttool, mstool, casalog
18
+
from mstools import write_history
19
+
from parallel.parallel_data_helper import ParallelDataHelper
20
+
import flaghelper as fh
21
+
22
+
ms = mstool
23
+
mstransformer = mttool
11
24
12
25
def partition(vis,
13
26
outputvis,
14
27
createmms,
15
28
separationaxis,
16
29
numsubms,
17
30
flagbackup, # only for MMS
18
31
datacolumn,
19
32
field,
20
33
spw,
119
132
120
133
# Create a backup of the flags that are in the MMS
121
134
casalog.origin('partition')
122
135
if flagbackup and os.path.exists(outputvis):
123
136
casalog.post('Create a backup of the flags that are in the MMS')
124
137
fh.backupFlags(aflocal=None, msfile=outputvis, prename='partition')
125
138
126
139
# Write history to output MS, not the input ms.
127
140
try:
128
141
param_names = partition.__code__.co_varnames[:partition.__code__.co_argcount]
129
-
param_vals = [eval(p) for p in param_names]
142
+
if is_python3:
143
+
vars = locals( )
144
+
param_vals = [vars[p] for p in param_names]
145
+
else:
146
+
param_vals = [eval(p) for p in param_names]
130
147
casalog.post('Updating the history in the output', 'DEBUG1')
131
-
write_history(mstool(), outputvis, 'partition', param_names,
148
+
write_history(ms(), outputvis, 'partition', param_names,
132
149
param_vals, casalog)
133
150
except Exception as instance:
134
151
casalog.post("*** Error \'%s\' updating HISTORY" % (instance),
135
152
'WARN')
136
153
return False
137
154
138
155
return True
139
156
140
-
141
157
# Create local copies of the MSTransform and ms tools
142
-
mtlocal = mttool()
143
-
mslocal = mstool()
158
+
mtlocal = mstransformer()
159
+
mslocal = ms()
144
160
145
161
try:
146
162
147
163
# Gather all the parameters in a dictionary.
148
164
config = {}
149
165
config = pdh.setupParameters(inputms=vis, outputms=outputvis, field=field,
150
166
spw=spw, array=array, scan=scan, antenna=antenna, correlation=correlation,
151
167
uvrange=uvrange,timerange=timerange, intent=intent, observation=str(observation),
152
168
feed=feed,taql=taql)
153
169
168
184
casalog.post('Run the tool to partition the MS')
169
185
mtlocal.run()
170
186
171
187
mtlocal.done()
172
188
173
189
except Exception as instance:
174
190
mtlocal.done()
175
191
casalog.post('%s'%instance,'ERROR')
176
192
return False
177
193
178
-
179
-
180
194
mslocal = None
181
195
182
196
return True