Skip to content
Snippets Groups Projects
Commit 990d95dd authored by Colm Talbot's avatar Colm Talbot
Browse files

Merge branch 'update_cosmology' into 'master'

Update cosmology

See merge request Monash/tupak!97
parents 6582bbbc 1ae5fb25
No related branches found
No related tags found
No related merge requests found
......@@ -2,8 +2,8 @@
"""
Tutorial to demonstrate running parameter estimation sampling in non-standard parameters for an injected signal.
This example estimates the masses using a uniform prior in chirp mass and mass ratio and distance using a uniform in
comoving volume prior on luminosity distance between luminosity distances of 100Mpc and 5Gpc, the cosmology is WMAP7.
This example estimates the masses using a uniform prior in chirp mass, mass ratio and redshift.
The cosmology is according to the Planck 2015 data release.
"""
from __future__ import division, print_function
import tupak
......
......@@ -21,21 +21,23 @@ def redshift_to_comoving_distance(redshift):
return Planck15.comoving_distance(redshift).value
@np.vectorize
def luminosity_distance_to_redshift(distance):
return z_at_value(Planck15.luminosity_distance, distance * u.Mpc)
@np.vectorize
def comoving_distance_to_redshift(distance):
return z_at_value(Planck15.comoving_distance, distance * u.Mpc)
def comoving_distance_to_luminosity_distance(distance):
redshift = z_at_value(Planck15.comoving_distance, distance * u.Mpc)
redshift = comoving_distance_to_redshift(distance)
return redshift_to_luminosity_distance(redshift)
def luminosity_distance_to_comoving_distance(distance):
redshift = z_at_value(Planck15.luminosity_distance, distance * u.Mpc)
redshift = luminosity_distance_to_redshift(distance)
return redshift_to_comoving_distance(redshift)
......@@ -426,11 +428,7 @@ def generate_non_standard_parameters(sample):
output_sample['cos_tilt_2'] = np.cos(output_sample['tilt_2'])
output_sample['cos_iota'] = np.cos(output_sample['iota'])
try:
output_sample['redshift'] = luminosity_distance_to_redshift(sample['luminosity_distance'])
except u.core.UnitsError:
output_sample['redshift'] = [luminosity_distance_to_redshift(distance)
for distance in sample['luminosity_distance']]
output_sample['redshift'] = luminosity_distance_to_redshift(sample['luminosity_distance'])
return output_sample
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment