icecube / FIRESONG

FIRst Extragalactic Simulation Of Neutrino and Gamma-ray
Other
18 stars 8 forks source link

Negative distances for small redshifts #72

Closed tglauch closed 2 years ago

tglauch commented 2 years ago

Using UnivariateSpline for the calculation of the luminosity in def LuminosityDistance(self, z): is pretty dangerous. The spline doesn't necessary behave very well for small redshifts and can even produce negative values.

For example

from firesong.Evolution import get_evolution, SourcePopulation from firesong.Evolution import cosmology population = SourcePopulation(cosmology, get_evolution('NoEvolution')) population.LuminosityDistance(np.full(1001, 0.0017507872720130618))

produces array([-1.04664586, -1.04664586, -1.04664586, ..., -1.04664586, -1.04664586, -1.04664586])

a safer alternative would it be to simply use interp1d or another more stable interpolator