# [AstroPy] Redshift vs. Luminosity Distance

Nicholas Ross npross at roe.ac.uk
Mon Jul 22 20:11:57 EDT 2019

```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> 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
>
>

```