[AstroPy] Redshift vs. Luminosity Distance

Craig, Matthew W mcraig at mnstate.edu
Tue Jul 23 10:31:02 EDT 2019


Hi Nic,

Thanks for posting the solution you got — it is useful to see both the question and answer, and awesome when users are able to provide the answer :)

Matt Craig

schedule:  http://physics.mnstate.edu/craig
——
Professor
Department of Physics and Astronomy
Minnesota State University Moorhead
1104 7th Ave S, Moorhead MN 56563

office: Hagen 307F
phone: (218) 477-2439
fax: (218) 477-2290

On Jul 22, 2019, at 7:11 PM, Nicholas Ross <npross at roe.ac.uk<mailto:npross at roe.ac.uk>> wrote:


Apologies for additional email, but

DLs_for_axis = np.array([0.01, 500., 1000., 2000., 3000., 5000., 6000.]) * u.Mpc
redshift_ticks = [z_at_value(cosmo.luminosity_distance, DLs) for DLs in DLs_for_axis]

seems to solve this one.

Thanks,
Nic



On Jul 22, 2019, at 4:54 PM, Nicholas Ross <npross at roe.ac.uk<mailto:npross at roe.ac.uk>> wrote:

Hi,

Been struggling with this one::

import astropy.units as u
from astropy.cosmology import FlatLambdaCDM
from astropy.cosmology import z_at_value

cosmo = FlatLambdaCDM(H0=67.7, Om0=0.307)
luminosity_distances = np.array([0.0, 500., 1000., 2000., 3000., 5000., 6000.]) * u.Mpc
z_at_value(cosmo.luminosity_distance, luminosity_distances)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-0294161797b4> in <module>()
      5 cosmo = FlatLambdaCDM(H0=67.7, Om0=0.307)  #Banados thesis
      6 luminosity_distances = np.array([0.0, 500., 1000., 2000., 3000., 5000., 6000.]) * u.Mpc
----> 7 z_at_value(cosmo.luminosity_distance, luminosity_distances)
~/anaconda3/lib/python3.6/site-packages/astropy/cosmology/funcs.py in z_at_value(func, fval, zmin, zmax, ztol, maxfun)
    116     fval_zmin = func(zmin)
    117     fval_zmax = func(zmax)
--> 118     if np.sign(fval - fval_zmin) != np.sign(fval_zmax - fval):
    119         warnings.warn("""\
    120 fval is not bracketed by func(zmin) and func(zmax). This means either…


Is this because astropy.cosmology returns the luminosity distance — which is monotonic with
redshift in a flat/open cosmology, as
dL = dA*(1+z)^2
where dA is the non-monotonic angular diameter distance??

Thanks,
Nic



_______________________________________________
AstroPy mailing list
AstroPy at python.org<mailto:AstroPy at python.org>
https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fastropy&data=02%7C01%7Cmcraig%40mnstate.edu%7C2b7678df2460404e68d208d70f05a965%7C5011c7c60ab446ab9ef4fae74a921a7f%7C0%7C0%7C636994389340198526&sdata=EB4BsmXwJ2wCipIYi6whCNRCwwd0320yGtWz4pRoxkA%3D&reserved=0

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20190723/1ad81f83/attachment-0001.html>


More information about the AstroPy mailing list