Esempio n. 1
0
def plot_data(data,samples,stellarmod,gamma=0,beta=3,n=512):

    rc=np.percentile(samples[:,0],[16,50,84])
    rt=np.percentile(samples[:,1],[16,50,84])
    mtot=10**np.percentile(samples[:,2],[16,50,84])


    t1=Tbetamodel(rc=rc[0],rt=rt[0],Mmax=mtot[0],gamma=gamma,beta=beta,n=n)
    t2=Tbetamodel(rc=rc[1],rt=rt[1],Mmax=mtot[1],gamma=gamma,beta=beta,n=n)
    t3=Tbetamodel(rc=rc[2],rt=rt[2],Mmax=mtot[2],gamma=gamma,beta=beta,n=n)

    m1=Multimodel(t1,stellarmod)
    m2=Multimodel(t2,stellarmod)
    m3=Multimodel(t3,stellarmod)

    j1=Jsolver(s.dens,s.sdens,m1.mass)
    j2=Jsolver(s.dens,s.sdens,m2.mass)
    j3=Jsolver(s.dens,s.sdens,m3.mass)

    r=np.linspace(0.,2.5,100)
    plt.errorbar(data[:,0],data[:,1],data[:,2],fmt='o')
    plt.plot(r,j1.vdisp(r))
    plt.plot(r,j2.vdisp(r))
    plt.plot(r,j3.vdisp(r))
    plt.xlim(0,2.5)
    plt.savefig=('plot.pdf')
Esempio n. 2
0
def lnlike(theta,x,y,yerr,stellarmod):

    rc,rt,Mtot,gamma,beta=theta
    t=Tbetamodel(rc=rc,rt=rt,Mmax=Mtot,gamma=gamma,beta=beta,n=512,use_c=True)
    totmodel=Multimodel(stellarmod,t)
    j=Jsolver(stellarmod.dens,stellarmod.sdens,totmodel.mass)
    teodisp=j.vdisp(x,mode='F',use_c=False)
    return -np.sum( ((y-teodisp)/(yerr))**2)
Esempio n. 3
0
from OpOp.jsolver import Jsolver


data=np.loadtxt('data.txt')
samples=np.loadtxt('samples.txt')

rc=np.percentile(samples[:,0],[16,50,84])
rt=np.percentile(samples[:,1],[16,50,84])
mtot=10**np.percentile(samples[:,2],[16,50,84])
print(mtot)
t1=Tbetamodel(rc=rc[0],rt=rt[0],Mmax=mtot[0],gamma=1,beta=2,n=512)
t2=Tbetamodel(rc=rc[1],rt=rt[1],Mmax=mtot[1],gamma=1,beta=2,n=512)
t3=Tbetamodel(rc=rc[2],rt=rt[2],Mmax=mtot[2],gamma=1,beta=2,n=512)

mtots=5e7
s=Sersic(0.71,0.581,mtots)
m1=Multimodel(t1,s)
m2=Multimodel(t2,s)
m3=Multimodel(t3,s)

j1=Jsolver(s.dens,s.sdens,m1.mass)
j2=Jsolver(s.dens,s.sdens,m2.mass)
j3=Jsolver(s.dens,s.sdens,m3.mass)

r=np.linspace(0.,2.5,100)
plt.errorbar(data[:,0],data[:,1],data[:,2],fmt='o')
plt.plot(r,j1.vdisp(r))
plt.plot(r,j2.vdisp(r))
plt.plot(r,j3.vdisp(r))
plt.xlim(0,2.5)
plt.show()
Esempio n. 4
0
    plt.plot(r,j3.vdisp(r))
    plt.xlim(0,2.5)
    plt.savefig=('plot.pdf')

t=Tbetamodel(rc=3.5,rt=6,Mmax=3.05e9,gamma=0,beta=3,n=512)
t2=Tbetamodel(rc=28.4,rt=36.4,Mmax=1.89e10,gamma=1,beta=3,n=512)
mtots=5e7
s=Sersic(0.71,0.581,mtots)
m=Multimodel(t,s)
m2=Multimodel(t2,s)

r=np.logspace(np.log10(0.01),np.log10(2),20)
m=Multimodel(t,s)

j=Jsolver(s.dens,s.sdens,m.mass)
a=j.vdisp(r,mode='F')
out=np.zeros((len(a),3))
out[:,0]=r
noise=np.random.normal(scale=0.5,size=len(a))
out[:,1]=a+noise
out[:,2]=noise
plt.errorbar(out[:,0],out[:,1],out[:,2],fmt='o')

np.savetxt('data.txt',out)



def lnlike(theta,x,y,yerr,stellarmod):

    rc,rt,Mtot,gamma,beta=theta
    t=Tbetamodel(rc=rc,rt=rt,Mmax=Mtot,gamma=gamma,beta=beta,n=512,use_c=True)