示例#1
0
print res



# Export the visibility data to uvfits/text
obs.save_txt('obs.txt') # exports a text file with the visibilities
obs.save_uvfits('obs.uvp') # exports a UVFITS file modeled on template.UVP

# Generate an image prior
npix = 100
fov = 1*im.xdim * im.psize
zbl = np.sum(im.imvec) # total flux
prior_fwhm = 200*vb.RADPERUAS # Gaussian size in microarcssec
emptyprior = vb.make_square(obs, npix, fov)
flatprior = vb.add_flat(emptyprior, zbl)
gaussprior = vb.add_gauss(emptyprior, zbl, (prior_fwhm, prior_fwhm, 0, 0, 0))

# Image total flux with the bispectrum
flux = np.sum(im.imvec)
#out = mx.maxen_amp_cphase(obs, gaussprior, gaussprior, flux, maxit=50, alpha_clphase=1000, alpha_visamp=1000)

out = mx.maxen_bs(obs, gaussprior, gaussprior, flux, maxit=25, alpha=5000)
 
# Blur the image with a circular beam and image again to help convergance
out = mx.blur_circ(out, res)
out = mx.maxen_bs(obs, out, out, flux, maxit=100, alpha=500, entropy="tv")
out = mx.blur_circ(out, res/2)
out = mx.maxen_bs(obs, out, out, flux, maxit=100, alpha=100, entropy="tv")
out = mx.blur_circ(out, res/2)
out = mx.maxen_bs(obs, out, out, flux, maxit=100, alpha=50, entropy="tv")
示例#2
0
# If the image has an odd number of pixels, make it even
if im.xdim%2 == 0:
	newim = im.imvec.reshape(im.ydim, im.xdim)
	newim = newim[:-1,:-1]
	im = vb.Image(newim, im.psize, im.ra, im.dec, rf=im.rf, source=im.source, mjd=im.mjd)

# Generate an image prior
obs = im.observe(eht, tint_sec, tadv_sec, tstart_hr, tstop_hr, bw_hz, sgrscat=False, ampcal=True, phasecal=True)
npix = im.psize*(im.xdim-1.0)/im.xdim
npix = 101 #This must be odd
fov = 1.0*im.xdim * im.psize 
zbl = np.sum(im.imvec) # total flux
emptyprior = vb.make_square(obs, npix, fov)

#Here is the 2-Gaussian fit from Rusen's paper
Rusen_2gauss_image = vb.add_gauss(emptyprior, 0.77, (18.*vb.RADPERUAS, 18.*vb.RADPERUAS, 0, 0, 0))
Rusen_2gauss_image = vb.add_gauss(Rusen_2gauss_image, 2.37, (58.*vb.RADPERUAS, 58.*vb.RADPERUAS, 0, 0, 0),x=29.0*vb.RADPERUAS,y=36.0*vb.RADPERUAS)

#Here is the Crescent fit from Rusen's paper (im, flux, Rp, Rn, a, b, x=0, y=0):
Rusen_Crescent_image = vb.add_crescent(emptyprior, 3.14, 49.0*vb.RADPERUAS, 12.0*vb.RADPERUAS, -1.0*vb.RADPERUAS, 25.0*vb.RADPERUAS)

#Here is the Crescent fit from Michael's paper (im, flux, Rp, Rn, a, b, x=0, y=0):
Michael_Crescent_image = vb.add_crescent(emptyprior, 3.14, 47.9881*vb.RADPERUAS, 11.3345*vb.RADPERUAS, -6.716*vb.RADPERUAS, 33.9294*vb.RADPERUAS)

#Here is the Annulus fit from Michael's paper (im, flux, Rp, Rn, a, b, x=0, y=0):
Michael_Annulus_image = vb.add_crescent(emptyprior, 3.14, 97.0/2.0*vb.RADPERUAS, 21.0/2.0*vb.RADPERUAS, 0.0, 0.0)

#Here's how to add scattering (following https://arxiv.org/abs/1610.05326)
#ep is the "epsilon screen", which is the normalized scattering screen in Fourier space. Each component is an independent, normalized, complex Gaussian random number. To generate new screen realizations, just change the seed value, rngseed. If you want to see how the scattering looks for different polarizations or frequencies, just use the same ep and everything should work out fine. ep needs to have the same FOV and number of pixels as the unscattered image.

ep = so.MakeEpsilonScreen(Michael_Crescent_image.xdim,Michael_Crescent_image.ydim,rngseed=34)
示例#3
0
sizeFinal = 64; 


############ RUN OPTIMIZATION ###############

# determine the multiplier you use to increase the scale
if(nScales == 1):
    scaleFactor = 1
else:
    scaleFactor = np.exp((np.log(sizeFinal) - np.log(sizeStart))/(nScales-1));


# create the prior
emptyprior = vb.make_square(obs, sizeStart, fov)
emptyprior.pulse = pulses.trianglePulse2D
gaussprior = vb.add_gauss(emptyprior, flux, (prior_fwhm, prior_fwhm, 0, 0, 0))
gaussprior.pulse = pulses.trianglePulse2D

# initial image
cleanI = mx.maxen_bs(obs, gaussprior, gaussprior, flux, maxit=50, alpha=1e5, stop=1e-15)

# iterate through scales
for s in range(1,nScales+1):

    # resize the image
    sizeCurr = np.round(scaleFactor**(s-1)*sizeStart);
    cleanI = vb.resample_square(cleanI, sizeCurr)
    
    # solve for the image under different patch noise levels (beta) 
    for beta in (1.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0):