def companion_mass(pb, x, inc=60.0 * u.deg, mpsr=1.4 * u.solMass): """Commpute the companion mass from the orbital parameters Compute companion mass for a binary system from orbital mechanics, not Shapiro delay. Parameters ---------- pb : Quantity Binary orbital period x : Quantity Projected semi-major axis (aka ASINI) in `pint.ls` inc : Angle, optional Inclination angle, in u.deg or u.rad. Default is 60 deg. mpsr : Quantity, optional Pulsar mass in u.solMass. Default is 1.4 Msun Returns ------- mass : Quantity in u.solMass """ massfunct = mass_funct(pb, x) # Do some unit manipulation here so that scipy bisect doesn't see the units def localmf(mc, mp=mpsr, mf=massfunct, i=inc): return (mass_funct2(mp, mc * u.solMass, i) - mf).value return zeros.bisect(localmf, 0.001, 1000.1) * u.solMass
def pulsar_mass(pb, x, mc, inc): """Compute pulsar mass from orbit and Shapiro delay parameters Return the pulsar mass (in solar mass units) for a binary. Finds the value using a bisection technique. Parameters ---------- pb : Quantity Binary orbital period x : Quantity Projected semi-major axis (aka ASINI) in `pint.ls` mc : Quantity Companion mass in u.solMass inc : Angle Inclination angle, in u.deg or u.rad Returns ------- mass : Quantity in u.solMass """ massfunct = mass_funct(pb, x) # Do some unit manipulation here so that scipy bisect doesn't see the units def localmf(mp, mc=mc, mf=massfunct, i=inc): return (mass_funct2(mp * u.solMass, mc, i) - mf).value return zeros.bisect(localmf, 0.0, 1000.0) * u.solMass
def findrs(c,delta,z,omegam,omegal,h,alp,bet,renc,Mrenc,rmin,rmax): '''Find the scale radius of the generalised NFW profile given an input concentration parameter c=r/rdelta and mass within some radius Mrenc(renc)''' rhocrit = 277.3*h**2*(omegam*(1+z)**3+omegal) c1 = Mrenc*nfwmint(alp,bet,c) c2 = delta*rhocrit*4/3*pi*c**3 #print 'rhocrit = ', rhocrit, renc, Mrenc, rmin, rmax #r = linspace(rmin,rmax,num=1000) #func = zeros(len(r),'double') #for i in xrange(len(r)): # func[i] = abs(c1-c2*r[i]**3*nfwmint(alp,renc/r[i])) #figure() #plot(log10(r),log10(func)) #show() #sys.exit(0) return bisect(lambda x: c1-c2*x**3*nfwmint(alp,bet,renc/x),rmin,rmax)
def findrs(c, delta, z, omegam, omegal, h, alp, bet, renc, Mrenc, rmin, rmax): '''Find the scale radius of the generalised NFW profile given an input concentration parameter c=r/rdelta and mass within some radius Mrenc(renc)''' rhocrit = 277.3 * h**2 * (omegam * (1 + z)**3 + omegal) c1 = Mrenc * nfwmint(alp, bet, c) c2 = delta * rhocrit * 4 / 3 * pi * c**3 #print 'rhocrit = ', rhocrit, renc, Mrenc, rmin, rmax #r = linspace(rmin,rmax,num=1000) #func = zeros(len(r),'double') #for i in xrange(len(r)): # func[i] = abs(c1-c2*r[i]**3*nfwmint(alp,renc/r[i])) #figure() #plot(log10(r),log10(func)) #show() #sys.exit(0) return bisect(lambda x: c1 - c2 * x**3 * nfwmint(alp, bet, renc / x), rmin, rmax)
if (not xmin) or (not xmax): sys.stderr.write("Error: xmin,xmax have not been defined.Abort.\n") sys.exit(1) if len(x0) != len(dx0) or len(x0) != len(fwhm): sys.stderr.write( "Error: Lists x0[:],dx0[0],fwhm[:] have different lengths.Abort.\n") sys.exit(1) # Number of Gaussians that build up mesh ng = len(x0) for i in range(ng): alpha.append(4 * log(2) / (fwhm[i])**2) A.append(2 * sqrt(alpha[i] / pi) / erf(sqrt(alpha[i]) * dx0[i] / 2)) mesh = GauMesh(A, alpha, x0, xmin, xmax) Ntot = mesh.NPoints - 1 print "# NPoints=", Ntot, " NGauss=", ng, " x0=", x0, " dx0=", dx0, " fwhm=", fwhm, " xmin=", xmin, " xmax=", xmax xn0 = xmin format = '%15.10f' for i in range(Ntot): ni = i - Ntot / 2 xn = bisect(meshN, xn0, xmax, (), 1e-15, 10000) if ni != 0: print format % xn xn0 = xn