Commits
191 191 | self._threshold = float(self._threshold.replace("uJy", "")) / 1e6 |
192 192 | elif "Jy" in self._threshold: |
193 193 | self._threshold = float(self._threshold.replace("Jy", "")) |
194 194 | |
195 195 | |
196 196 | def __init__( self, vis, imagename, field='', spw='', timerange='', uvrange='', antenna='', scan='', observation='', intent='', datacolumn='corrected', imsize=[100], cell=[ ], |
197 197 | phasecenter='', stokes='I', startmodel='', specmode='cube', reffreq='', nchan=-1, start='', width='', outframe='LSRK', veltype='radio', restfreq='', interpolation='linear', |
198 198 | perchanweightdensity=True, gridder='standard', wprojplanes=int(1), mosweight=True, psterm=False, wbawp=True, conjbeams=False, usepointing=False, pointingoffsetsigdev=[ ], |
199 199 | pblimit=0.2, deconvolver='hogbom', smallscalebias=0.0, niter=0, threshold='0.1Jy', nsigma=0.0, cycleniter=-1, nmajor=1, cyclefactor=1.0, minpsffraction=0.05, |
200 200 | maxpsffraction=0.8, scales=[], restoringbeam='', pbcor=False, nterms=int(2), weighting='natural', robust=float(0.5), npixels=0, gain=float(0.1), pbmask=0.2, sidelobethreshold=3.0, |
201 - | noisethreshold=5.0, lownoisethreshold=1.5, negativethreshold=0.0, smoothfactor=1.0, minbeamfrac=0.3, cutthreshold=0.01, growiterations=75, dogrowprune=True, |
201 + | noisethreshold=5.0, lownoisethreshold=1.5, negativethreshold=0.0, smoothfactor=float(1.0), minbeamfrac=0.3, cutthreshold=0.01, growiterations=75, dogrowprune=True, |
202 202 | minpercentchange=-1.0, verbose=False, fastnoise=True, savemodel='none', usemask='user', mask='', parallel=False, history_filter=lambda index, arg, history_value: history_value ): |
203 203 | |
204 204 | self._vis = vis |
205 205 | self._imagename = imagename |
206 206 | self._imsize = imsize |
207 207 | self._cell = cell |
208 208 | self._phasecenter = phasecenter |
209 209 | self._stokes = stokes |
210 210 | self._startmodel = startmodel |
211 211 | self._specmode = specmode |
256 256 | self._datacolumn = datacolumn |
257 257 | self._weighting = weighting |
258 258 | self._robust = robust |
259 259 | self._npixels = npixels |
260 260 | self._gain = gain |
261 261 | self._pbmask = pbmask |
262 262 | self._sidelobethreshold = sidelobethreshold |
263 263 | self._noisethreshold = noisethreshold |
264 264 | self._lownoisethreshold = lownoisethreshold |
265 265 | self._negativethreshold = negativethreshold |
266 - | self._smoothfactor = smoothfactor, |
266 + | self._smoothfactor = smoothfactor |
267 267 | self._minbeamfrac = minbeamfrac |
268 268 | self._cutthreshold = cutthreshold |
269 269 | self._growiterations = growiterations |
270 270 | self._dogrowprune = dogrowprune |
271 271 | self._minpercentchange = minpercentchange |
272 272 | self._verbose = verbose |
273 273 | self._fastnoise = fastnoise |
274 274 | self._savemodel = savemodel |
275 275 | self._parallel = parallel |
276 276 | self._usemask = usemask |
371 371 | |
372 372 | return outrec |
373 373 | |
374 374 | def _update_peakres(self): |
375 375 | if self._deconvolver == 'mtmfs': |
376 376 | residname = self._imagename + '.residual.tt0' |
377 377 | else: |
378 378 | residname = self._imagename + '.residual' |
379 379 | |
380 380 | maskname = self._imagename + '.mask' |
381 + | if not os.path.exists(maskname): |
382 + | maskname = '' |
381 383 | |
382 384 | peakres = imstat(imagename=residname, mask=maskname)['max'] |
383 - | masksum = imstat(imagename=maskname)['sum'] |
385 + | if len(maskname) > 0: |
386 + | masksum = imstat(imagename=maskname)['sum'] |
387 + | else: |
388 + | masksum = [] |
384 389 | |
385 390 | if len(peakres) > 0: |
386 391 | peakres = peakres[0] |
387 392 | else: |
388 393 | peakres = None |
389 394 | |
390 395 | if len(masksum) > 0: |
391 396 | masksum = masksum[0] |
392 397 | else: |
393 398 | masksum = None |
441 446 | gain=self._gain, calcres=True, calcpsf=True, restoration=False, parallel=self._parallel, fullsummary=True) |
442 447 | |
443 448 | |
444 449 | deconv_ret = self._deconvolve(imagename=self._imagename, startmodel=self._startmodel, |
445 450 | deconvolver=self._deconvolver, restoration=False, |
446 451 | threshold=self._threshold, niter=0, |
447 452 | nsigma=self._nsigma, fullsummary=True, fastnoise=self._fastnoise, usemask=self._usemask, |
448 453 | mask=self._mask, pbmask=self._pbmask, sidelobethreshold=self._sidelobethreshold, noisethreshold=self._noisethreshold, |
449 454 | lownoisethreshold=self._lownoisethreshold, negativethreshold=self._negativethreshold, smoothfactor=self._smoothfactor, |
450 455 | minbeamfrac=self._minbeamfrac, cutthreshold=self._cutthreshold, growiterations=self._growiterations, |
451 - | dogrowprune=self._dogrowprune, minpercentchange=self._minpercentchange, verbose=self._verbose) |
456 + | dogrowprune=self._dogrowprune, verbose=self._verbose) |
452 457 | |
453 458 | self.current_imdict.returndict = self.current_imdict.merge(tclean_ret, deconv_ret) |
454 459 | self.global_imdict.returndict = self.current_imdict.returndict |
455 460 | |
456 461 | ## Initial call where niterleft and nmajorleft are same as original input values. |
457 462 | self.hasit, self.stopdescription = self.global_imdict.has_converged(self._niter, self._threshold, self._nmajor) |
458 463 | |
459 464 | self.current_imdict.returndict['stopcode'] = self.hasit |
460 465 | self.current_imdict.returndict['stopDescription'] = self.stopdescription |
461 466 | self._major_done = 0 |
529 534 | self.global_imdict.returndict['stopDescription'] = self.stopdescription |
530 535 | |
531 536 | if not self.hasit: |
532 537 | # If we haven't converged, run deconvolve to update the mask |
533 538 | #print("no convergence, updating mask") |
534 539 | |
535 540 | self._deconvolve(imagename=self._imagename, startmodel=self._startmodel, deconvolver=self._deconvolver, restoration=False, threshold=self._threshold, niter=0, |
536 541 | nsigma=self._nsigma, fullsummary=True, fastnoise=self._fastnoise, usemask=self._usemask, mask=self._mask, pbmask=self._pbmask, |
537 542 | sidelobethreshold=self._sidelobethreshold, noisethreshold=self._noisethreshold, lownoisethreshold=self._lownoisethreshold, |
538 543 | negativethreshold=self._negativethreshold, smoothfactor=self._smoothfactor, minbeamfrac=self._minbeamfrac, cutthreshold=self._cutthreshold, |
539 - | growiterations=self._growiterations, dogrowprune=self._dogrowprune, minpercentchange=self._minpercentchange, verbose=self._verbose) |
544 + | growiterations=self._growiterations, dogrowprune=self._dogrowprune, verbose=self._verbose) |
540 545 | |
541 546 | |
542 547 | if len(self.global_imdict.returndict) > 0 and 'summaryminor' in self.global_imdict.returndict and sum(map(len,self.global_imdict.returndict['summaryminor'].values())) > 0: |
543 548 | self._convergence_result = ( self.global_imdict.returndict['stopDescription'] if 'stopDescription' in self.global_imdict.returndict else '', |
544 549 | self.global_imdict.returndict['stopcode'] if 'stopcode' in self.global_imdict.returndict else 0, |
545 550 | self._major_done, |
546 551 | self._nmajor, |
547 552 | self._niter, |
548 553 | self.__add_per_major_items( self.global_imdict.returndict, |
549 554 | self._convergence_result[5]['major'], |