示例#1
0
def lnprob(p, data, bins):

    # unpack parameters
    incl = p[0]
    PA = p[1]
    offx = p[2]
    offy = p[3]
    sbs = p[4:]

    # priors
    # enforce positive surface brightnesses
    if (np.any(sbs) < 0.):
        return -np.inf

    # enforce monotonicity
    if (np.array_equal(np.sort(sbs), sbs[::-1]) == False):
        return -np.inf

    # geometry common sense
    if (incl < 0. or incl > 90. or PA < 0. or PA > 180.):
        return -np.inf


    # unpack data
    u, v, dreal, dimag, dwgt = data
    uvsamples = u, v


    # generate model visibilities
    pars = incl, PA, np.array([offx, offy]), sbs
    mvis = discreteModel(pars, uvsamples, bins)

    
    # compute a chi2 value
    chi2 = np.sum(dwgt*(dreal-mvis.real)**2 + dwgt*(dimag-mvis.imag)**2)


    # return a log-likelihood value
    return -0.5*chi2
示例#2
0
offy = -0.2
SB = (sig/cb)**0.7 * np.exp(-(cb/sig)**2.5)	# fullA distribution; where
						# flux=0.12, sig=0.6, i=50, 
						# PA = 70., offs=[-0.3, -0.2]
int_SB = np.trapz(2.*np.pi*SB*cb, cb)		# a check on the total flux
SB *= flux / int_SB
itheta = incl, PA, np.array([offx, offy]), SB


# FT and sample it for each configuration
ldata = np.load('DATA/base/dummy.c1.sim.alma.cycle3.3.vis.npz')
lu = ldata['u']
lv = ldata['v']
lvis = ldata['Vis']
lrms = 0.035e-3
lo_vis = discreteModel(itheta, [lu, lv], bins)

hdata = np.load('DATA/base/dummy.c2.sim.alma.cycle3.6.vis.npz')
hu = hdata['u']
hv = hdata['v']
hvis = hdata['Vis']
hrms = 0.020e-3
hi_vis = discreteModel(itheta, [hu, hv], bins)



# add (white) noise to the model visibilities; record noise in weights
lnoise = np.random.normal(loc=0., scale=lrms*np.sqrt(len(lu)), size=len(lu))
#lo_vis.real += lnoise 
#lo_vis.imag += lnoise
lo_wgt = np.ones_like(lu)/(lrms*np.sqrt(len(lu)))**2
示例#3
0


# load the "data" (w/ and w/o noise)
data = np.load(filename+'.vis.npz')
u = data['u']
v = data['v']
rho = np.sqrt(u**2 + v**2)
ivis = data['nf_Vis']
vis = data['Vis']
wgt = data['Wgt']


# binned models for the data
ltheta = incl, PA, np.array([offx, offy]), lSB
lvis = discreteModel(ltheta, [u, v], lbins)

vtheta = incl, PA, np.array([offx, offy]), vSB
vvis = discreteModel(vtheta, [u, v], vbins)

xtheta = incl, PA, np.array([offx, offy]), xSB
xvis = discreteModel(xtheta, [u, v], xbins)




# plot them and the residuals (real only, since symmetric for now)
plt.figure(figsize=(7, 10))
plt.clf()
gs = gridspec.GridSpec(3, 1, height_ratios=[1, 1, 1])
示例#4
0
imag = data['Im']
wgt = 10000.*data['Wt']


# deproject
incl = 0.
PA = 0.
offset = np.array([0., 0.])
indata = u, v, real, imag
dvis = deprojectVis(indata, incl=incl, PA=PA, offset=offset)
drho, dreal, dimag = dvis

# initial guess visibilities
ftheta = incl, PA, offset, guess_sb
uvsamples = u, v
fmodelvis = discreteModel(ftheta, uvsamples, bins)
mindata = u, v, fmodelvis.real, fmodelvis.imag
fvis = deprojectVis(mindata, incl=incl, PA=PA, offset=offset)
frho, freal, fimag = fvis

# truth
ttheta = incl, PA, offset, SBtruth
bins_true = rin, rtruth
tmodelvis = discreteModel(ttheta, uvsamples, bins_true)
mindata = u, v, tmodelvis.real, tmodelvis.imag
tvis = deprojectVis(mindata, incl=incl, PA=PA, offset=offset)
trho, treal, timag = tvis

plt.axis([0, 2000., -0.025, 0.15])
plt.plot(drho, dreal, '.y', alpha=0.01)
# loop through initialized walkers