18 from __future__
import print_function
20 Generate Chebyshev coefficients for BAYESTAR uniform-in-comoving-volume prior.
24 import astropy.cosmology
25 import astropy.units
as u
29 parser = argparse.ArgumentParser()
31 'cosmology', choices=astropy.cosmology.parameters.available,
32 default=
'WMAP9', nargs=
'?', help=
'Cosmological model')
33 args = parser.parse_args()
35 cosmo = astropy.cosmology.default_cosmology.get_cosmology_from_string(
40 """Ratio between the comoving volume element dVC and a
41 DL**2 prior at redshift z."""
43 DH = cosmo.hubble_distance
44 DM_by_DH = (cosmo.comoving_transverse_distance(z) / DH).value
45 DC_by_DH = (cosmo.comoving_distance(z) / DH).value
50 ret = np.cosh(np.sqrt(Ok0) * DC_by_DH)
52 ret = np.cos(np.sqrt(-Ok0) * DC_by_DH)
54 ret += DM_by_DH * cosmo.efunc(z)
55 ret *= np.square(zplus1)
61 return astropy.cosmology.z_at_value(
62 cosmo.luminosity_distance, DL * u.Mpc)
69 DL = np.logspace(0, 6, 32)
72 log_dVC_dVL = np.log(dVC_dVL)
79 high_z_x0 = np.log(1e6)
80 high_z_y0 =
func(high_z_x0)
81 high_z_slope = scipy.misc.derivative(func, high_z_x0)
82 high_z_intercept = high_z_y0 - high_z_slope * high_z_x0
84 filename = os.path.basename(__file__)
85 print(
'/* DO NOT EDIT. Automatically generated by', filename,
'*/')
86 print(
'static const double dVC_dVL_data[] = {')
87 print(*(
'\t{:+.8e}'.format(c)
for c
in log_dVC_dVL), sep=
',\n')
89 print(
'static const double dVC_dVL_tmin = {:.15f};'.format(log_DL[0]))
90 print(
'static const double dVC_dVL_tmax = {:.15f};'.format(log_DL[-1]))
91 print(
'static const double dVC_dVL_dt = {:.15f};'.format(
93 print(
'static const double dVC_dVL_high_z_slope = {:.15f};'.format(
95 print(
'static const double dVC_dVL_high_z_intercept = {:.15f};'.format(
100 """An alternate expression of dVC_dVL_for_DL."""
103 DH = cosmo.hubble_distance
104 DC = cosmo.comoving_distance(z)
105 DM = cosmo.comoving_transverse_distance(z)
106 dVC_dz = cosmo.differential_comoving_volume(z)
112 dDM_dDC = np.cosh(np.sqrt(Ok0) * DC / DH)
114 dDM_dDC = np.cos(np.sqrt(-Ok0) * DC / DH)
116 dDC_dz = DH * cosmo.inv_efunc(z)
117 dDL_dz = DM + (1 + z) * dDM_dDC * dDC_dz
118 dVL_dz = np.square(DL) * dDL_dz / u.sr
120 return dVC_dz / dVL_dz
123 DL = np.logspace(-2, 6, 1000)
126 print(
'static const double dVC_dVL_test_x[] = {')
127 print(*(
'\t{:+.8e}'.format(c)
for c
in DL), sep=
',\n')
129 print(
'static const double dVC_dVL_test_y[] = {')
130 print(*(
'\t{:+.8e}'.format(c)
for c
in dVC_dVL), sep=
',\n')
def dVC_dVL_for_z(z)
Ratio between the comoving volume element dVC and a DL**2 prior at redshift z.
def exact_dVC_dVL(DL)
An alternate expression of dVC_dVL_for_DL.