You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
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.
The text was updated successfully, but these errors were encountered:
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
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
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.
The text was updated successfully, but these errors were encountered: