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

Using A_s instead of sigma8 in a 3x2pt forecast is generating invalid values in CCL boltzmann.py when performing derivative calculations #62

Open
bruno-moraes opened this issue Jul 5, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@bruno-moraes
Copy link
Collaborator

bruno-moraes commented Jul 5, 2024

TL;DR: A call to boltzmann.py within CCL is failing in the derivative calculation, presumably due to O(10^-9) values in A_s.

Explanation: When attempting a 3x2pt forecast, it runs and completes when the sigma8 parameter is used. If A_s is used instead, the Jupyter kernel dies after a few seconds when trying to calculate the Fisher matrix. Running the code as a python script from the command line, the error returned is:

(forecasting) brunomor@Brunos-MacBook-Pro-2 forecasts_neutrinos_workshop2024 % time python 2024-07-02_neutrino_3x2pt_SRD.py 
forecasting_strawberry_run.sacc
/Users/brunomor/miniforge3/envs/forecasting/lib/python3.12/site-packages/pyccl/boltzmann.py:170: RuntimeWarning: invalid value encountered in log
  ln_p_k_and_z[i, :] = np.log(pk[sind, :])
zsh: abort      python 2024-07-02_neutrino_3x2pt_SRD.py

The trace did not contain information about where this error occurred, so I ran pdb on the script (my first time, so not very skillfully) and found the spot where it is breaking:

> /Users/brunomor/lib/python/augur/augur/analyze.py(191)get_fisher_matrix()
-> if self.derivatives is None:
(Pdb) n
> /Users/brunomor/lib/python/augur/augur/analyze.py(192)get_fisher_matrix()
-> self.get_derivatives(method=method)
(Pdb) n
/Users/brunomor/miniforge3/envs/forecasting/lib/python3.12/site-packages/pyccl/boltzmann.py:170: RuntimeWarning: invalid value encountered in log ln_p_k_and_z[i, :] = np.log(pk[sind, :])
zsh: abort      python 2024-07-02_neutrino_3x2pt_SRD.py
@bruno-moraes bruno-moraes added the bug Something isn't working label Jul 5, 2024
@bruno-moraes bruno-moraes self-assigned this Jul 5, 2024
@bruno-moraes
Copy link
Collaborator Author

I will work on this now.

@bruno-moraes
Copy link
Collaborator Author

@fjaviersanchez , I could pinpoint more or less where the error is, but this is something I never fixed before. I assume it's numerical instabilities in the derivatives due to the small values of A_s compared to the other parameters. I won't be able to solve it now.

@bruno-moraes bruno-moraes changed the title Jupyter kernel dying when running a 3x2pt forecast with A_s and m_nu Using A_s instead of sigma8 in a 3x2pt forecast is generating invalid values in CCL boltzmann.py when performing derivative calculations Jul 5, 2024
@fjaviersanchez
Copy link
Collaborator

Thank you for checking and identifying the issue! I think this can be potentially solved when we add the stem derivative method. One potential solution is to normalize all parameters internally for the derivatives and then change back or change the step size dynamically, but will check first if the easy fix works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants