def testCoaddMultipleCores(self): R2, P_r2, mask2 = pc.stack_R(self.imgs, align=False, n_procs=4) R, P_r, mask = pc.stack_R(self.imgs, align=False, n_procs=2) np.testing.assert_allclose(R.real, R2.real, rtol=0.2, atol=0.5) np.testing.assert_allclose(P_r.real, P_r2.real, rtol=0.2, atol=0.5) np.testing.assert_allclose(mask, mask2, rtol=0.2, atol=1)
def main(): imgsdir = '/home/bruno/Documentos/Data/SNiPTF/imgs' imgsdir = '/home/bruno/Data/SNiPTF/imgs' imgsdir = '/home/bruno/Data/LIGO_O2/Jan04/20171119/PGC073926/calibrated' dest_dir = './test/test_images/test_sniptf' imgs = glob.glob(imgsdir + '/aligned_PGC073926-*.fits') mask = glob.glob(imgsdir + '/*mask*.fits') imgs.sort() mask.sort() #~ print imgs #~ print mask #~ for animg in imgs: #~ img = fits.open(animg, 'update') #~ img[0].data = img[0].data[:495, :495] #~ img[0].header['NAXIS1'] = 495 #~ img[0].header['NAXIS2'] = 495 #~ img.flush() #~ img.close() #images = [s.SingleImage(animg, mask=amask) for animg, amask in zip(imgs, mask)] images = [s.SingleImage(animg) for animg in imgs] for j, an_img in enumerate(images): an_img.inf_loss = 0.18 plot.plot_psfbasis(an_img.kl_basis, path=os.path.join(dest_dir, 'psf_basis_{}.png'.format(j)), nbook=False) x, y = an_img.get_afield_domain() plot.plot_afields(an_img.kl_afields, x, y, path=os.path.join(dest_dir, 'afields_{}.png'.format(j)), nbook=False, size=4) fits.writeto(os.path.join(dest_dir, 'mask_{}.fits'.format(j)), an_img.mask.astype('uint8'), overwrite=True) fits.writeto(os.path.join(dest_dir, 'S_comp_{}.fits'.format(j)), an_img.s_component, overwrite=True) fits.writeto(os.path.join(dest_dir, 'interped_{}.fits'.format(j)), an_img.interped, overwrite=True) plot.plt.imshow(an_img.psf_hat_sqnorm().real) plot.plt.colorbar() plot.plt.savefig( os.path.join(dest_dir, 'psf_hat_sqnorm_{}.png'.format(j))) plot.plt.close() R, P_r = pc.stack_R(images, align=False, n_procs=4, inf_loss=0.25) fits.writeto(os.path.join(dest_dir, 'R.fits'), R.real, overwrite=True) fits.writeto(os.path.join(dest_dir, 'P.fits'), P_r.real, overwrite=True) for an_img in images: an_img._clean() return
def testCoadd2Core(self): R, P_r, mask = pc.stack_R(self.imgs, align=False, n_procs=2) self.assertIsInstance(R, np.ndarray) self.assertIsInstance(P_r, np.ndarray) self.assertIsInstance(mask, np.ndarray)