logging.basicConfig(level=logging.INFO)
logger = logging.getLogger()

# we will use a ring source structure
def source_model(nx,dx,radius,width):
    sigma = width / (2 * np.sqrt(np.log(4))) / dx
    x = np.dot(np.transpose([np.ones(nx)]),[np.arange(nx)-nx/2])
    r = np.sqrt(x**2 + x.T**2)
    m = np.exp(-0.5/sigma**2*(r-radius/dx)**2)
    return m/m.sum()
nx = 256
dx = 0.75
m = source_model(nx,dx,28.,10.)

# initialize the scattering class
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()
Example #2
0
rgb = imread(src_file)[::-1]
I = 255 - (np.array([0.2989, 0.5870, 0.1140])[np.newaxis, np.newaxis, :] *
           rgb).sum(axis=-1)
I *= np.pi / I.sum()

# and smooth image
I = utilities.smoothImage(I, 1., 8.)

# make up some scale for our image. Let's have it span 120 uas.
write_figs = False
wavelength = 1e-3
FOV = 120.
dx = FOV / I.shape[0]

# initialize the scattering screen @ 1mm
b = Brane(I, dx, wavelength=1.e-3, nphi=2**13)

# initialize Target object for calculating visibilities and uv samples
sgra = Target(wavelength=1.e-3)

# calculate uv samples for our closure phase triangle and on the source image
site_triangle = ["SMT", "ALMA", "LMT"]
(uv, hr) = sgra.generateTriangleTracks(sgra.sites(site_triangle),
                                       times=(0., 24., int(24. * 60. / 2.)),
                                       return_hour=True)
CP_src = sgra.calculateCP(b.isrc, b.dx, uv)


# calculate CP on these triangles for a number of screens
def one_sim(i):
    global sgra, b, CP
logger = logging.getLogger()

# import our source image and covert it to gray scale
src_file = 'source_images/nh_01_stern_05_pluto_hazenew2.square.jpg'
rgb = imread(src_file)[::-1]
I = (np.array([0.2989,0.5870,0.1140])[np.newaxis,np.newaxis,:]*rgb).sum(axis=-1)
I *= np.pi/I.sum()

# make up some scale for our image.
write_figs = False
wavelength=1e-3
FOV = 90.
dx = FOV/I.shape[0]

# initialize the scattering screen @ 0.87mm
b = Brane(I,dx,wavelength=0.87e-3,nphi=(2**12,2**14),anisotropy=1,pa=None,r_inner=50,live_dangerously=True)

# estimate the time resolution of our simulation assuming some screen velocity.
screen_velocity = 200.  #km/s
fs = screen_velocity/(b.screen_dx*b.ips) # Hz
num_samples = b.nphi[1]/b.ips - b.nx   # try num_samples = 100 for testing porpoises.
logger.info('Number of samples: {0:g}'.format(num_samples))
logger.info('Sampling interval: {0:g}s'.format(1./fs))
logger.info('Time coverage: {0:g} days'.format(num_samples/fs/(3600.*24.)))

# 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))