18from __future__
import print_function
20Generate Chebyshev coefficients for BAYESTAR uniform-in-comoving-volume prior.
24import astropy.cosmology
25import astropy.units
as u
29parser = argparse.ArgumentParser()
31 'cosmology', choices=astropy.cosmology.parameters.available,
32 default=
'WMAP9', nargs=
'?', help=
'Cosmological model')
33args = parser.parse_args()
35cosmo = 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)
69DL = np.logspace(0, 6, 32)
72log_dVC_dVL = np.log(dVC_dVL)
79high_z_x0 = np.log(1e6)
81high_z_slope = scipy.misc.derivative(func, high_z_x0)
82high_z_intercept = high_z_y0 - high_z_slope * high_z_x0
84filename = os.path.basename(__file__)
85print(
'/* DO NOT EDIT. Automatically generated by', filename,
'*/')
86print(
'static const double dVC_dVL_data[] = {')
87print(*(
'\t{:+.8e}'.format(c)
for c
in log_dVC_dVL), sep=
',\n')
89print(
'static const double dVC_dVL_tmin = {:.15f};'.format(log_DL[0]))
90print(
'static const double dVC_dVL_tmax = {:.15f};'.format(log_DL[-1]))
91print(
'static const double dVC_dVL_dt = {:.15f};'.format(
93print(
'static const double dVC_dVL_high_z_slope = {:.15f};'.format(
95print(
'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
123DL = np.logspace(-2, 6, 1000)
126print(
'static const double dVC_dVL_test_x[] = {')
127print(*(
'\t{:+.8e}'.format(c)
for c
in DL), sep=
',\n')
129print(
'static const double dVC_dVL_test_y[] = {')
130print(*(
'\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.