Exemple #1
0
def integrand_trapz(del0,m,M0,R0,z):  #2s*f_ESP
    # of A7, divided by 2s; this IS f_ESP
	s = sig0(m2R(m))
	V,r,dmdr = pb.volume_radius_dmdr(m,**cosmo)
	s,s0,sx = sig0(r), sig0(R0),SX(r,R0)
	gamm = gam(r)
	epx,q = epX(m,M0), Q(m,M0)
	meanmu = del0/n.sqrt(s)*sx/s0
	varmu = Q(m,M0)
	varx = 1-gamm**2-gamm**2*(1-epx)**2*(1-q)/q 
	if varx<0:
		print "varx<0, breaking at varx, gamm, epx, q,m,M0="
		print varx, gamm, epx, q, m, M0

#!! varx can be negative

	b = n.arange(0.00001,3.,0.03)
	y = []
	for bx in b:
		newy = prob(bx)*subgrand_trapz(bx,del0,s,s0,sx,epx,q,meanmu,varmu,varx,gamm,R0,V,z)/2/s
		#print 'b,y'
		#print bx,y[-1]
		if n.isnan(newy): 
			print 'NAN detected, breaking at: '
			print bx,prob(bx),del0,s,s0,sx,epx,q,meanmu,varmu,varx,gamm,R0,V
			break
		else:
			y.append(newy)
	return n.trapz(y,b)
Exemple #2
0
def integrand_trapz(del0,m,M0,R0,z):  #2s*f_ESP
    # of A7, divided by 2s; this IS f_ESP
	s = sig0(m2R(m))
	V,r,dmdr = pb.volume_radius_dmdr(m,**cosmo)
	s,s0,sx = sig0(r), sig0(R0),SX(r,R0)
	gamm = gam(r)
	epx,q = epX(m,M0), Q(m,M0)
	meanmu = del0/n.sqrt(s)*sx/s0
	varmu = Q(m,M0)
	varx = 1-gamm**2-gamm**2*(1-epx)**2*(1-q)/q 
	if varx<0:
		print "varx<0, breaking at varx, gamm, epx, q,m,M0="
		print varx, gamm, epx, q, m, M0

#!! varx can be negative

	#b = n.arange(0.00001,30.,0.03)                      #TUNE
	b = n.exp(n.linspace(n.log(0.05),n.log(20.),200))
	y = []
	for bx in b:
		newy = prob(bx)*subgrand_trapz(bx,del0,s,s0,sx,epx,q,meanmu,varmu,varx,gamm,R0,V,z)/2/s
		#print 'b,y'
		#print bx,y[-1]
		if n.isnan(newy): 
			print 'NAN detected, breaking at: '
			print bx,prob(bx),del0,s,s0,sx,epx,q,meanmu,varmu,varx,gamm,R0,V
			break
		else:
			y.append(newy)
	#import IPython; IPython.embed()
	if y[-1]/n.max(y)>1.E-3: print "Warning: choice of bmax too small"
	if y[0]/n.max(y)>1.E-3: print "Warning: choice of bmin too big"
	return n.trapz(y,b)
Exemple #3
0
def integrand_trapz(del0, m, M0, R0, z):  #2s*f_ESP
    # of A7, divided by 2s; this IS f_ESP
    s = sig0(m2R(m))
    V, r, dmdr = pb.volume_radius_dmdr(m, **cosmo)
    s, s0, sx = sig0(r), sig0(R0), SX(r, R0)
    gamm = gam(r)
    epx, q = epX(m, M0), Q(m, M0)
    meanmu = del0 / n.sqrt(s) * sx / s0
    varmu = Q(m, M0)
    varx = 1 - gamm**2 - gamm**2 * (1 - epx)**2 * (1 - q) / q
    if varx < 0:
        print "varx<0, breaking at varx, gamm, epx, q,m,M0="
        print varx, gamm, epx, q, m, M0


#!! varx can be negative

#b = n.arange(0.00001,30.,0.03)                      #TUNE
    b = n.exp(n.linspace(n.log(0.01), n.log(30.),
                         1000))  #Wide range from E-21 to E-280, peaking at E-7
    y = []
    for bx in b:
        newy = prob(bx) * subgrand_trapz(bx, del0, s, s0, sx, epx, q, meanmu,
                                         varmu, varx, gamm, R0, V, z) / 2 / s
        #print 'b,y'
        #print bx,y[-1]
        if n.isnan(newy):
            print 'NAN detected, breaking at: '
            print bx, prob(
                bx), del0, s, s0, sx, epx, q, meanmu, varmu, varx, gamm, R0, V
            break
        else:
            y.append(newy)
    #import IPython; IPython.embed()
    return n.trapz(y, b)
Exemple #4
0
def All(x,b,m,del0,M0,z): #z,y,x,c,c,c
	V,r,dmdr = pb.volume_radius_dmdr(m,**cosmo)
	R0 = m2R(M0)
	s,s0,sx = sig0(r), sig0(R0),SX(r,R0)
	Bb = B(z,b,s)
	gamm = gam(r)
	epx,q = epX(m,M0), Q(m,M0)
	#print 'gamm,epx,q =',gamm,epx,q 
	meanmu = del0/n.sqrt(s)*sx/s0
	varmu = Q(m,M0)
	meanx = gamm*((Bb-del0*sx/s0)*(1-epx)/q/n.sqrt(s)+Bb*epx/n.sqrt(s))
	varx = 1-gamm**2-gamm**2*(1-epx)**2*(1-q)/q 
	fact = V/Vstar(R0)*pG(Bb/n.sqrt(s),meanmu, varmu)
	#print b, Bb/n.sqrt(s),meanmu,varmu,pG(Bb/n.sqrt(s),meanmu, varmu)
	return fact*prob(b)*(x/gamm-b)*F(x)*pG(x,meanx,varx)/2/sig0(m2R(m))*dsdm(m)
Exemple #5
0
def subgrand(b,del0,m,M0,z):
	V,r,dmdr = pb.volume_radius_dmdr(m,**cosmo)
	R0 = m2R(M0)
	s,s0,sx = sig0(r), sig0(R0),SX(r,R0)
	Bb = B(z,b,s)
	gamm = gam(r)
	epx,q = epX(m,M0), Q(m,M0)
	print 'gamm,epx,q =',gamm,epx,q 
	meanmu = del0/n.sqrt(s)*sx/s0
	varmu = Q(m,M0)
	meanx = gamm*((Bb-del0*sx/s0)*(1-epx)/q/n.sqrt(s)+Bb*epx/n.sqrt(s))
	varx = 1-gamm**2-gamm**2*(1-epx)**2*(1-q)/q 
	fact = V/Vstar(R0)*pG(Bb/n.sqrt(s),meanmu, varmu)
	print b, Bb/n.sqrt(s),meanmu,varmu,pG(Bb/n.sqrt(s),meanmu, varmu)
	factint = quad(lambda x: (x/gamm-b)*F(x)*pG(x,meanx,varx),b*gamm,100)[0]
	#print fact, factint
	return fact*factint
Exemple #6
0
def All(x, b, m, del0, M0, z):  #z,y,x,c,c,c
    V, r, dmdr = pb.volume_radius_dmdr(m, **cosmo)
    R0 = m2R(M0)
    s, s0, sx = sig0(r), sig0(R0), SX(r, R0)
    Bb = B(z, b, s)
    gamm = gam(r)
    epx, q = epX(m, M0), Q(m, M0)
    #print 'gamm,epx,q =',gamm,epx,q
    meanmu = del0 / n.sqrt(s) * sx / s0
    varmu = Q(m, M0)
    meanx = gamm * ((Bb - del0 * sx / s0) *
                    (1 - epx) / q / n.sqrt(s) + Bb * epx / n.sqrt(s))
    varx = 1 - gamm**2 - gamm**2 * (1 - epx)**2 * (1 - q) / q
    fact = V / Vstar(R0) * pG(Bb / n.sqrt(s), meanmu, varmu)
    #print b, Bb/n.sqrt(s),meanmu,varmu,pG(Bb/n.sqrt(s),meanmu, varmu)
    return fact * prob(b) * (x / gamm - b) * F(x) * pG(
        x, meanx, varx) / 2 / sig0(m2R(m)) * dsdm(m)
Exemple #7
0
def subgrand(b, del0, m, M0, z):
    V, r, dmdr = pb.volume_radius_dmdr(m, **cosmo)
    R0 = m2R(M0)
    s, s0, sx = sig0(r), sig0(R0), SX(r, R0)
    Bb = B(z, b, s)
    gamm = gam(r)
    epx, q = epX(m, M0), Q(m, M0)
    print 'gamm,epx,q =', gamm, epx, q
    meanmu = del0 / n.sqrt(s) * sx / s0
    varmu = Q(m, M0)
    meanx = gamm * ((Bb - del0 * sx / s0) *
                    (1 - epx) / q / n.sqrt(s) + Bb * epx / n.sqrt(s))
    varx = 1 - gamm**2 - gamm**2 * (1 - epx)**2 * (1 - q) / q
    fact = V / Vstar(R0) * pG(Bb / n.sqrt(s), meanmu, varmu)
    print b, Bb / n.sqrt(s), meanmu, varmu, pG(Bb / n.sqrt(s), meanmu, varmu)
    factint = quad(lambda x: (x / gamm - b) * F(x) * pG(x, meanx, varx),
                   b * gamm, 100)[0]
    #print fact, factint
    return fact * factint
Exemple #8
0
def integrand_trapz(del0,m,M0,R0,z):  #2s*f_ESP
	s = sig0(m2R(m))
	V,r,dmdr = pb.volume_radius_dmdr(m,**cosmo)
	s,s0,sx = sig0(r), sig0(R0),SX(r,R0)
	gamm = gam(r)
	epx,q = epX(m,M0), Q(m,M0)
	meanmu = del0/n.sqrt(s)*sx/s0
	varmu = Q(m,M0)
	varx = 1-gamm**2-gamm**2*(1-epx)**2*(1-q)/q 
	b = n.arange(0.000001,3.,0.03)
	y = []
	for bx in b:
		y.append(prob(bx)*subgrand_trapz(bx,del0,s,s0,sx,epx,q,meanmu,varmu,varx,gamm,R0,V,z)/2/s)
		#print 'b,y'
		#print bx,y[-1]
		if n.isnan(y[-1]): 
			print 'NAN detected, breaking at: '
			print bx,prob(bx),del0,s,s0,sx,epx,q,meanmu,varmu,varx,gamm,R0,V
			break
	return n.trapz(y,b,dx=0.05)
Exemple #9
0
def integrand_trapz(del0, m, M0, R0, z):  #2s*f_ESP
    # of A7, divided by 2s; this IS f_ESP
    s = sig0(m2R(m))
    V, r, dmdr = pb.volume_radius_dmdr(m, **cosmo)
    s, s0, sx = sig0(r), sig0(R0), SX(r, R0)
    gamm = gam(r)
    epx, q = epX(m, M0), Q(m, M0)
    meanmu = del0 / np.sqrt(s) * sx / s0
    varmu = q
    varx = 1 - gamm**2
    #print varmu, varx

    if varx < 0:
        print "varx<0, breaking at varx, gamm, epx, q,m,M0="
        print varx, gamm, epx, q, m, M0

    #b = np.arange(0.00001,30.,0.03)                      #TUNE
    b = np.logspace(-6, 3, 100)
    y = _integrand_trapz_y(b, del0, s, s0, sx, epx, q, meanmu, varmu, varx,
                           gamm, R0, V, z)
    if (y == 0.).all(): return 0.
    blims = _blims(b, y)
    while blims[0] == blims[1]:
        b = np.logspace(np.log10(blims[0] * 0.99), np.log10(blims[1] * 1.01),
                        100)
        y = _integrand_trapz_y(b, del0, s, s0, sx, epx, q, meanmu, varmu, varx,
                               gamm, R0, V, z)
        blims = _blims(b, y)
    b = np.logspace(np.log10(blims[0]), np.log10(blims[1]), 100)
    y = _integrand_trapz_y(b, del0, s, s0, sx, epx, q, meanmu, varmu, varx,
                           gamm, R0, V, z)
    if y[-1] / np.max(y) > 1.E-3:
        print "Warning: choice of bmax too small"
        print y
        print blims
        import IPython
        IPython.embed()
        raise (Exception)
    if y[0] / np.max(y) > 1.E-3:
        print "Warning: choice of bmin too big"
    return np.trapz(y, b)
Exemple #10
0
def integrand_trapz(del0, m, M0, R0, z):  #2s*f_ESP
    s = sig0(m2R(m))
    V, r, dmdr = pb.volume_radius_dmdr(m, **cosmo)
    s, s0, sx = sig0(r), sig0(R0), SX(r, R0)
    gamm = gam(r)
    epx, q = epX(m, M0), Q(m, M0)
    meanmu = del0 / n.sqrt(s) * sx / s0
    varmu = Q(m, M0)
    varx = 1 - gamm**2 - gamm**2 * (1 - epx)**2 * (1 - q) / q
    b = n.arange(0.000001, 3., 0.03)
    y = []
    for bx in b:
        y.append(
            prob(bx) * subgrand_trapz(bx, del0, s, s0, sx, epx, q, meanmu,
                                      varmu, varx, gamm, R0, V, z) / 2 / s)
        #print 'b,y'
        #print bx,y[-1]
        if n.isnan(y[-1]):
            print 'NAN detected, breaking at: '
            print bx, prob(
                bx), del0, s, s0, sx, epx, q, meanmu, varmu, varx, gamm, R0, V
            break
    return n.trapz(y, b, dx=0.05)