def getKernel(screenfile='gaussian_screen.bin'): ''' isotropic case ''' hdr = slimscat.fetch_hdr(screenfile=screenfile) theta = (hdr['wavelength'] * np.log(4)**0.5) / \ (hdr['r0']*np.pi*(1+hdr['m'])) sigma = (theta / (2 * np.sqrt(2 * np.log(2)))) return sigma * 206265 * 1e6 / hdr['dx']
def getKernel(screenfile='gaussian_screen.bin'): ''' isotropic case ''' hdr = slimscat.fetch_hdr(screenfile=screenfile) theta = (hdr['wavelength'] * np.log(4)**0.5) / \ (hdr['r0']*np.pi*(1+hdr['m'])) sigma = (theta/(2*np.sqrt(2*np.log(2)))) return sigma*206265*1e6/hdr['dx']
if __name__ == "__main__": # create model ftot = 3.0 fwhm = 37.0 dx = 4.0 nx = 32 m = model(ftot, fwhm, dx=dx, nx=nx) # mNoisy = initialize(m,dx) mNoisy = addNoise(m.source, dx) mTrue = m.source noise = mNoisy - m.source mTrue = m.source.copy() # check that our model and simulation have matching resolutions hdr = slimscat.fetch_hdr(__screenfile__) assert hdr["dx"] == dx # plt.subplot(121); plt.imshow(m.source); plt.subplot(122); plt.imshow(mNoisy) # plt.figure(); plt.imshow(noise) # plt.show() # fetch scattering kernel sigma = getKernel(__screenfile__) # sample positions t1 = np.tile(np.arange(m.nx), m.nx) t0 = np.repeat(np.arange(m.nx), m.nx, axis=0) t = np.hstack([t0[:, np.newaxis], t1[:, np.newaxis]]) # fit
if __name__ == '__main__': # create model ftot = 3. fwhm = 37. dx = 4. nx = 32 m = model(ftot, fwhm, dx=dx, nx=nx) #mNoisy = initialize(m,dx) mNoisy = addNoise(m.source, dx) mTrue = m.source noise = mNoisy - m.source mTrue = m.source.copy() # check that our model and simulation have matching resolutions hdr = slimscat.fetch_hdr(__screenfile__) assert hdr['dx'] == dx #plt.subplot(121); plt.imshow(m.source); plt.subplot(122); plt.imshow(mNoisy) #plt.figure(); plt.imshow(noise) #plt.show() # fetch scattering kernel sigma = getKernel(__screenfile__) # sample positions t1 = np.tile(np.arange(m.nx), m.nx) t0 = np.repeat(np.arange(m.nx), m.nx, axis=0) t = np.hstack([t0[:, np.newaxis], t1[:, np.newaxis]]) # fit