Photomeson interactions - fixes and automated tests#191
Photomeson interactions - fixes and automated tests#191pwit07 wants to merge 41 commits intocosimoNigro:photomesons_interactionsfrom
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
| comments="#", | ||
| usecols=(0, 1), | ||
| unpack="True", | ||
| converters={0: lambda x: float(x.replace(',', '.')), |
There was a problem hiding this comment.
better to use dot as decimal separator in files directly
| @@ -1,8 +1,25 @@ | |||
| # test the kernels | |||
| import numpy as np | |||
| # import numpy as np | |||
|
|
||
| # to be used only for the the validation | ||
| from astropy.modeling.models import BlackBody | ||
| import matplotlib.pyplot as plt |
There was a problem hiding this comment.
probably not needed, no plots should be generated by test file
| # Blob with proton population | ||
| E_star = 3e20 * u.Unit("eV") | ||
| gamma_star = (E_star / mpc2).to_value("") | ||
| # p_p, gamma_c, gamma_min, gamma_max = 2, 1e3*gamma_star, (1.0*u.Unit("GeV")/mpc2).to_value(""), 1e6*gamma_star |
| #func = CubicSpline(eta_eta0, s) | ||
| func = lambda x: np.interp(x, eta_eta0, s) | ||
| # func = lambda x: np.interp(x, eta_eta0, s) | ||
| func = lambda x: log_interp(x, eta_eta0, s) |
There was a problem hiding this comment.
keep only the log interpolation
agnpy/photo_meson/photo_meson.py
Outdated
| "muon_antineutrino", | ||
| ] | ||
|
|
||
| eta_0 = 0.313 |
There was a problem hiding this comment.
move to evaluate_spectrum
| # Integral on eta to be done from eta_0 to infinity | ||
| eta = np.logspace( | ||
| log10(eta_0), | ||
| log10(eta_0) + 5, |
There was a problem hiding this comment.
define e.g. eta_0_range in parameters of the function with a default value of 5
agnpy/targets/targets.py
Outdated
| self.name = "Cosmic Microwave Background Radiation" | ||
| a = 7.5657 * 1e-15 * u.Unit("erg cm-3 K-4") # radiation constant | ||
| T = 2.72548 * u.K | ||
| self.bb = BlackBody(T) |
|
View / edit / reply to this conversation on ReviewNB jsitarek commented on 2026-02-09T15:58:17Z Line #43. # s_val_log = np.interp(eta_val, eta_eta0, s) remove the unnecessary commented out lines |
|
View / edit / reply to this conversation on ReviewNB jsitarek commented on 2026-02-09T15:58:18Z Line #55. # ax[0,i].set_ylim(2e-2,2e0) removed not needed commented out code |
|
View / edit / reply to this conversation on ReviewNB jsitarek commented on 2026-02-09T15:58:19Z Line #59. ax[0,i].set_xscale('log')
make a simple loop |
|
View / edit / reply to this conversation on ReviewNB jsitarek commented on 2026-02-09T15:58:20Z Line #37. interp_file, delimiter=";", dtype="float", comments="#", usecols=(0, 1), unpack="True",converters={0: lambda x: float(x.replace(',', '.')),
change , to . already in the input files |
|
View / edit / reply to this conversation on ReviewNB jsitarek commented on 2026-02-09T15:58:20Z Line #63. ax[0].text(0.2, 0.7, r"$\eta$ = 1.5 $\eta_{0}$", fontsize=12, horizontalalignment='center', verticalalignment='center', transform=ax[0].transAxes)
use param_tab value (also some things can go into a for loop |
|
View / edit / reply to this conversation on ReviewNB jsitarek commented on 2026-02-09T15:58:21Z Line #69. xphi_plot("2")
also do in a loop |
|
View / edit / reply to this conversation on ReviewNB jsitarek commented on 2026-02-09T15:58:22Z Line #4. def dNdx(x, E_p, particle): try to use evaluate_spectrum instead of making a dedicated function |
|
View / edit / reply to this conversation on ReviewNB jsitarek commented on 2026-02-09T15:58:23Z Line #121. dNdx_plot("6")
check in which place (for what parameters) those errors appear |
|
View / edit / reply to this conversation on ReviewNB jsitarek commented on 2026-02-09T15:58:23Z Line #30. gamma_max = 1e6*gamma_star better e.g. 30 * factor *gamma_star |
agnpy/photo_meson/photo_meson.py
Outdated
| blob, | ||
| target, | ||
| integrator=np.trapz | ||
| integrator=np.trapezoid |
There was a problem hiding this comment.
Angpy 0.5.0 still officially supports numpy >= 1.24; trapezoid was added in numpy 2.0.
So i think we should stick to np.trapz, which works with both versions, until we drop support for numpy 1.x
Photomeson_interactions.ipynbnotebook (reproduced Figs. 2–7 and 14–17 from from K&A 2008)PhotoMesonProductionclass inphoto_meson.py