b = Brane(m,dx,wavelength=1.3e-3,nphi=(2**12,2**12),screen_res=6,r_inner=50) # points along the uv axes where to record the visibility u = np.linspace(0.,10e9,num=50) # generate a bunch of scattering instances tic = time.time() u_vis = [] v_vis = [] num_sims = 100 avg = np.zeros_like(b.isrc) for i in range(num_sims): # create a new instance of the random phases b.generatePhases() # calculate the scattered image b.scatter() # keep track of the average avg += b.iss # calculate the visibility function along the u and v axis. u_vis.append(np.array([utilities.FTElementFast(b.iss,b.dx,[u_,0]) for u_ in u])) v_vis.append(np.array([utilities.FTElementFast(b.iss,b.dx,[0,u_]) for u_ in u])) avg /= num_sims logger.info('took {0:g}s'.format(time.time()-tic)) # make figures write_figs = False fig_file = '../_static/ensemble_average/' extent=b.dx*b.nx//2*np.array([1,-1,-1,1]) ensemble = utilities.ensembleSmooth(b.isrc,b.dx,b) u_kernel = utilities.getUVKernel(u,np.zeros_like(u),b) v_kernel = utilities.getUVKernel(np.zeros_like(u),u,b)
# generate the screen (this takes a while) logger.info('generating screen...') tic = time.time() b.generatePhases() logger.info('took {0:g}s'.format(time.time()-tic)) # generate time series (this takes a while) logger.info('generating time series...') fluxes = [] frames = [] tic = time.time() for i in range(num_samples): # update source image to include a sinusoidal flux modulation b.setModel(I*(1. - 0.4*np.sin(2*np.pi*i/(2*num_samples))), dx) # comment out to speedup b.scatter(move_pix=i*b.ips) fluxes.append(b.iss.sum()) frames.append(b.iss) logger.info('took {0:g}s'.format(time.time()-tic)) # 1962.92s # make figures fig_file = '../_static/time_variability/' extent=b.dx*b.nx//2*np.array([1,-1,-1,1]) plt.figure() plt.subplot(121) isrc_smooth = utilities.smoothImage(b.isrc,b.dx,2.*b.dx) plt.imshow(isrc_smooth,extent=extent,cmap=cmap) plt.xlabel('$\Delta\\alpha$ [$\mu$as]'); plt.ylabel('$\Delta\delta$ [$\mu$as]') plt.subplot(122)