Open R-Grau opened 6 months ago
Dear @R-Grau, Could you point to the exact lines in the code where this is a problem and / or post an example where you run into this issue? Thanks!
Dear @me-manu, Sorry if I did not explain myself enough, this is the first issue I make. when defining OpticalDepth in line 28 and in the comment in lines 43 and 44. After that, every time you define the variable EGeV.
class OptDepth(GridInterpolator):
"""
Class to calculate attenuation of gamma-rays due to interaction
with the EBL from EBL models.
"""
def __init__(self, z, EGeV, tau, kx=1, ky=1, **kwargs):
"""
Initiate Optical depth model class.
Parameters
----------
z: array-like
source redshift, m-dimensional
EGeV: array-like
Energies in GeV, n-dimensional
tau: array-like
n x m array with optical depth values
kx: int
order of interpolation spline along energy axis, default: 1
ky: int
order of interpolation spline along energy axis, default: 1
kwargs: dict
Additional kwargs passed to `~scipy.interpolate.RectBivariateSpline`
"""
Here is an example:
import numpy as np
from ebltable.tau_from_model import OptDepth
redshift = 0.2
energy_range = np.geomspace(0.2, 10, 15) # in TeV
energy_range_GeV = np.geomspace(200, 10000, 15) # in GeV
dominguez_model = OptDepth.readmodel(model="dominguez")
dominguez_tau = dominguez_model.opt_depth(redshift, energy_range)
dominguez_tau_GeV = dominguez_model.opt_depth(redshift, energy_range_GeV)
When comparing both dominguez_tau, the one with GeV units is wrong while the one using TeV units is the correct one. But as I said, in the notebook notebooks/example_tau.ipynb it already uses TeV units. The solution would only be changing the variable EGeV for ETeV and changing the comment in line 44.
Cheers
In the file tau_from_model.py in some comments and the name of the variable EGeV it tells the user to input the energies in GeV when the correct unit to use is TeV. I have not checked if this also happens in other files, but the notebook examples use TeV and they get the correct value, while if I use GeV I get wrong values.