sambit-giri / tools21cm

MIT License
22 stars 18 forks source link

cdist_to_z is not independant of the specified cosmology #38

Closed flomertens closed 1 year ago

flomertens commented 1 year ago

Because t2c.cdist_to_z use a precalculated table it is not valid when changing the cosmology parameters to other values than the default, e.g. when setting H0 to 100 for testing purpose.

sambit-giri commented 1 year ago

The table is always calculated again. See the following line: https://github.com/sambit-giri/tools21cm/blob/0825223a03f96fc9c08ff893ea0063a0298b00e7/src/tools21cm/cosmology.py#L169

I agree that it is a bit confusing due to the presence of the precalc_table_cdist, which is a remnant of the previous fixed cosmology version of the package.

To make sure that everything is fine, please run the following e.g. script. cdist1 = 1500.0 cdist2 = t2c.z_to_cdist(t2c.cdist_to_z(cdist1)) print('Comoving distances before and after transformations are {:.3f} and {:.3f} Mpc'.format(cdist1, cdist2) This should give a coming distance very close to what is put in.