Commits
99 99 | observation -- observation ID(s) to select. |
100 100 | default '' (all). |
101 101 | """ |
102 102 | |
103 103 | casalog.origin('partition') |
104 104 | |
105 105 | # Initiate the helper class |
106 106 | pdh = ParallelDataHelper('partition', locals()) |
107 107 | |
108 108 | # Validate input and output parameters |
109 - | try: |
110 - | pdh.setupIO() |
111 - | except Exception as instance: |
112 - | casalog.post('%s'%instance,'ERROR') |
113 - | return False |
109 + | pdh.setupIO() |
114 110 | |
115 111 | if createmms: |
116 112 | |
117 113 | if disableparallel: |
118 114 | pdh.bypassParallelProcessing(1) |
119 115 | else: |
120 116 | pdh.bypassParallelProcessing(0) |
121 117 | |
122 118 | # Get a cluster |
123 119 | pdh.setupCluster(thistask='partition') |
124 120 | |
125 121 | # Execute the jobs using cluster |
126 - | try: |
127 - | pdh.go() |
128 - | pdh.bypassParallelProcessing(0) |
129 - | except Exception as instance: |
130 - | casalog.post('%s'%instance,'ERROR') |
131 - | return False |
122 + | pdh.go() |
123 + | pdh.bypassParallelProcessing(0) |
132 124 | |
133 125 | # Create a backup of the flags that are in the MMS |
134 126 | casalog.origin('partition') |
135 127 | if flagbackup and os.path.exists(outputvis): |
136 128 | casalog.post('Create a backup of the flags that are in the MMS') |
137 129 | fh.backupFlags(aflocal=None, msfile=outputvis, prename='partition') |
138 130 | |
139 131 | # Write history to output MS, not the input ms. |
140 132 | try: |
141 133 | param_names = partition.__code__.co_varnames[:partition.__code__.co_argcount] |
142 134 | if is_python3: |
143 135 | vars = locals( ) |
144 136 | param_vals = [vars[p] for p in param_names] |
145 137 | else: |
146 138 | param_vals = [eval(p) for p in param_names] |
147 139 | casalog.post('Updating the history in the output', 'DEBUG1') |
148 140 | write_history(ms(), outputvis, 'partition', param_names, |
149 141 | param_vals, casalog) |
150 142 | except Exception as instance: |
151 143 | casalog.post("*** Error \'%s\' updating HISTORY" % (instance), |
152 144 | 'WARN') |
153 - | return False |
154 145 | |
155 - | return True |
146 + | return |
156 147 | |
157 - | # Create local copies of the MSTransform and ms tools |
158 - | mtlocal = mstransformer() |
159 - | mslocal = ms() |
160 148 | |
161 149 | try: |
162 - | |
150 + | mtlocal = mstransformer() |
151 + | |
163 152 | # Gather all the parameters in a dictionary. |
164 153 | config = {} |
165 154 | config = pdh.setupParameters(inputms=vis, outputms=outputvis, field=field, |
166 155 | spw=spw, array=array, scan=scan, antenna=antenna, correlation=correlation, |
167 156 | uvrange=uvrange,timerange=timerange, intent=intent, observation=str(observation), |
168 157 | feed=feed,taql=taql) |
169 158 | |
170 159 | # ddistart will be used in the tool when re-indexing the spw table |
171 160 | config['ddistart'] = ddistart |
172 - | |
161 + | |
173 162 | config['datacolumn'] = datacolumn |
174 163 | |
175 164 | # Configure the tool and all the parameters |
176 - | |
165 + | |
177 166 | casalog.post('%s'%config, 'DEBUG1') |
178 167 | mtlocal.config(config) |
179 - | |
168 + | |
180 169 | # Open the MS, select the data and configure the output |
181 170 | mtlocal.open() |
182 - | |
171 + | |
183 172 | # Run the tool |
184 173 | casalog.post('Run the tool to partition the MS') |
185 174 | mtlocal.run() |
186 - | |
187 - | mtlocal.done() |
188 - | |
189 - | except Exception as instance: |
190 - | mtlocal.done() |
191 - | casalog.post('%s'%instance,'ERROR') |
192 - | return False |
193 175 | |
194 - | mslocal = None |
195 - | |
196 - | return True |
176 + | finally: |
177 + | mtlocal.done() |