Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value of z_lens with too much precision causes error #51

Open
cgannonucm opened this issue Jan 20, 2024 · 1 comment
Open

Value of z_lens with too much precision causes error #51

cgannonucm opened this issue Jan 20, 2024 · 1 comment

Comments

@cgannonucm
Copy link
Contributor

  • pyHalo version: 0.2.8
  • Python version: 3.11.6
  • Operating System: Ubuntu 23.10

Description

Unexpected error when creating a CDM realization using the pyHalo.preset_models.CDM method.
I was tabulating properties of CDM realizations across different host halo masses / lens redshifts and came across an unexpected error.
It appears that including too many decimal places when specifying a z_lens value causes a crash.

For example:
realization = CDM(z_lens=0.333,z_source=2, sigma_sub=0.3,log_mlow=8,log_mhigh=9,LOS_normalization=0.0,log_m_host=13.18888)
crashes

But
realization = CDM(z_lens=0.33,z_source=2, sigma_sub=0.3,log_mlow=8,log_mhigh=9,LOS_normalization=0.0,log_m_host=13.18888)

executes fine

traceback
Exception Traceback.txt

This problem can be worked around by using np.round to round the value of z_lens before passing to CDM, but I figured this issue could be quite confusing to encounter.

@cgannonucm cgannonucm changed the title Value of z_lens with too many decimal points causes error Value of z_lens with too much precision causes error Jan 20, 2024
@dangilman
Copy link
Owner

Hi @cgannonucm, yes thanks for pointing this out. It's true that due to some settings hard-coded in pyHalo there can be rounding errors that cause division by zero if one specifies lens redshifts to more than two decimal places of precision. I plan on fixing this issue in the next pypi release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants