filenames.append( sm.capsule_corp(im, t, t_exp=1, i=i, zero=3.1415, path=img_dir)) cmd = ' ' for files in filenames: cmd += ' ' + files coadd = os.path.join(img_dir, 'coadd.fits') swarp = shlex.split('swarp ' + cmd + ' -IMAGEOUT_NAME ' + coadd) subprocess.call(swarp) with pc.ImageEnsemble(filenames) as ensemble: # S = ensemble.calculate_S(n_procs=4) R, S = ensemble.calculate_R(n_procs=4, return_S=True) if isinstance(S, np.ma.masked_array): S = S.filled(1.) if isinstance(R, np.ma.masked_array): R = R.real.filled(1.) shdu = fits.PrimaryHDU(S) shdulist = fits.HDUList([shdu]) shdulist.writeto(os.path.join(img_dir, 'S.fits'), overwrite=True) rhdu = fits.PrimaryHDU(R.real)
if not os.path.exists(img_dir): os.makedirs(img_dir) for i in range(40): im = sm.image(m, N, t_exp=i + 1, X_FWHM=xfwhm, Y_FWHM=yfwhm, theta=theta, SN=SN, bkg_pdf='poisson') filenames.append( sm.capsule_corp(im, t, t_exp=i + 1, i=i, zero=zero + i, path=img_dir)) ensemble = pc.ImageEnsemble(filenames) S_hat_stack, S_stack, S_hat, S, R_hat = ensemble.calculate_R(n_procs=4, debug=True) S_inv = pc._ifftwn(S_hat) d = S - S_inv plt.hist(d.real.flatten(), log=True) plt.title('Histograma diferencia pixeles fourier inverso') plt.show() plt.hist(d.imag.flatten(), log=True) plt.title('Histograma diferencia pixeles fourier inverso') plt.show()
from properimage import propercoadd as pc from properimage import utils # ============================================================================= # PSF measure test by propercoadd # ============================================================================= #datapath = os.path.abspath('/home/bos0109/DATA/Data/Tolar2015/CAMPAÑA_LIGO_OBS #ERVACIONES_MACON/20151212/preprocessed/Landolt_C53') datapath = os.path.abspath('/home/bruno/Documentos/Data/ESO085-030') for root, dirs, files in os.walk(datapath): fs = [os.path.join(root, afile) for afile in files] print 'files to process: {}'.format(fs) with pc.ImageEnsemble(fs, pow_th=0.01) as ensemble: R, S = ensemble.calculate_R(n_procs=4, return_S=True) test_dir = os.path.abspath('./test/test_images/real_coadd_test/') if not os.path.exists(test_dir): os.mkdir(test_dir) utils.plot_S(S, path=os.path.join(test_dir, 'S.png')) utils.plot_R(R, path=os.path.join(test_dir, 'R.png')) utils.encapsule_S(S, path=os.path.join(test_dir, 'S.fits')) utils.encapsule_R(R, path=os.path.join(test_dir, 'R.fits'))