def getmean(inimagedata, blc, trc, tolerance=0.0001, maxiter=50): inimage = makeaipsimage(inimagedata) imean = AIPSTask('imean') imean.indata = inimage imean.blc = AIPSList(blc) imean.trc = AIPSList(trc) imean.doinvers = -1 imean.nboxes = 0 imean.pixrange = AIPSList([0, 0]) imean.functype = '' imean.pixavg = 0 imean.pixstd = 0 imean.docat = 0 imean.dotv = -1 imean.grchan = 0 imean.go() #Set the tolerance to be a fraction of current measured average. tolerance = fabs(imean.pixavg * tolerance) diff = tolerance + 1.0 count = 0 while diff > tolerance and count < maxiter: prevmean = imean.pixavg imean.go() diff = fabs(imean.pixavg - prevmean) count += 1 if count == maxiter: print 'No convergence in IMEAN after ' + str(maxiter) + ' iterations!' return fabs(imean.pixavg)
def pbcorr(inimagedata, outimagedata, pbparm, inverse=0): pbaipsparm = AIPSList(pbparm) inimage = makeaipsimage(inimagedata) outimage = makeaipsimage(outimagedata) pbcor = AIPSTask('pbcor') pbcor.outdata = outimage pbcor.indata = inimage pbcor.doinvers = inverse pbcor.pbparm = pbaipsparm pbcor.go() return (outimage)