[AstroPy] astropy.cosmology

Erik Tollerud erik.tollerud at gmail.com
Fri Dec 6 15:19:16 EST 2013


Right now I think Juande's solution is indeed the best way right now.
I think the reason for only having the "forward" version of these is
that it's not clear exactly which of all the cosmology functions
should have inverses.

But we could add inverse versions of everything, basically implemented
the way Juande is suggesting here.  Then they could later be optimized
when someone wants to make them faster. If anyone wants to issue a PR
doing that, I think it might be useful...

On Thu, Dec 5, 2013 at 12:06 PM, Juande Santander Vela <jdsant at iaa.es> wrote:
> Hi, Enrique,
>
> I don’t find the age function in astropy.cosmology, but the loopback_time, but I think the answer stands.
>
> If you want to obtain the inverse function, assuming loopback_time is continuous, and it should, you can use scipy.optimize methods to find out the redshift. For instance, the redshift corresponding to a 0.2Gyears lookback time, you can do:
>
>  from  scipy.optimize import newton
>  import astropy.cosmology as cosmo
>
>  newton(lambda x: cosmo.lookback_time(x).value-0.2, 0)
>
> or, in general:
>
>  from  scipy.optimize import newton
>  import astropy.cosmology as cosmo
>
>  def redshift_from_lookback_time(gyears):
>     return newton(lambda x: cosmo.lookback_time(x).value-gyears, 0)
>
> Hope that helps.
>
> El 05/12/2013, a las 11:01, ES.Enrique Perez <eperez at iaa.es> escribió:
>
>> Geetings.
>>
>> I may have overlooked the answer in the docs, but really haven't been able to find it:
>>
>> astropy.cosmology age(some_redshift) provides the age corresponding to a given redshfit,
>> but what is the reverse function that provides the redshift corresponding to a given age?
>>
>> Thanks,
>> Enrique
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at scipy.org
>> http://mail.scipy.org/mailman/listinfo/astropy
>
> --
> Juande Santander Vela
> VIA-SKA Project Manager
> Instituto de Astrofísica de Andalucía (IAA-CSIC)
> Glorieta de la Astronomía s/n, E-18008, Granada, Spain
>
> Henry Ford: La mayoría de la gente gasta más tiempo y energías en intentar esquivar los problemas que en tratar de resolverlos.
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy



-- 
Erik



More information about the AstroPy mailing list