#exclude acquisition images if targets[i]!=0: #get data and prepare arrays for xhi^2 and scaling ratios im = fits.getdata('results/'+fileNames[i][:-5]+'.reg.fits') Chi = np.ones(n)*np.inf ss = np.zeros(n) #calculate noise in the image sig = iS.calcNoiseProfile(im) for j in range(n): #loop over images of the other target if (targets[i]==1 and targets[j]==2) or (targets[i]==2 and targets[j]==1): tim = fits.getdata('results/'+fileNames[j][:-5]+'.reg.fits') #find scaling ratio and chi^2 ss[j] = iS.findRatio(im,tim,mask) Chi[j] = np.sum(((im - ss[j]*tim)/sig)**2) ### what to use for sigma??? #progress bar percent1 = float(i) / n hashes1 = '#' * int(round(percent1 * 20)) spaces1 = ' ' * (20 - len(hashes1)) percent2 = float(j) / n hashes2 = '#' * int(round(percent2 * 20)) spaces2 = ' ' * (20 - len(hashes2)) sys.stdout.write("\rImages: [{0}] {1}%\tTemplates: [{2}] {3}%".format(hashes1 + spaces1, int(round(percent1 * 100)),hashes2+spaces2, int(round(percent2*100)))) sys.stdout.flush() #find and write min chi^2 best = np.argmin(Chi) f.write(fileNames[i]+'\t'+fileNames[best]+'\n')
if (np.sqrt((i-o)**2+(j-o)**2)<30 and np.sqrt((i-o)**2+(j-o)**2)>10): mask[j,i]=1. n = np.size(targets) for i in range(n): #exclude acquisition images if targets[i]!=0: im = fits.getdata('results/'+fileNames[i][:-5]+'.reg.fits') #load appropriate psf if targets[i]==1: psf = ROXs42B if targets[i]==2: psf = ROXs12 #find scaling ratio, subtract and output image s = iS.findRatio(im,psf,mask)#(o,o),15,15) im = im - s*psf fits.writeto('results/'+fileNames[i][:-5]+'.adi.fits',im) #progress bar percent = float(i) / n hashes = '#' * int(round(percent * 20)) spaces = ' ' * (20 - len(hashes)) sys.stdout.write("\rPercent: [{0}] {1}%".format(hashes + spaces, int(round(percent * 100)))) sys.stdout.flush() sys.stdout.write("\n") #register and stack adi images positions = ascii.read('starPositions.txt') positions['x'] = np.ones(n)*512