radis
radis copied to clipboard
Bug report: Slit size depends on the wave range that it is applied on
🐛 Describe the bug
When I apply a slit by giving its FWHM in nm, I get a slit size that changes depending on the used wave range.
from radis import calc_spectrum
for w_min in [900, 1600]:
s = calc_spectrum(w_min * u.nm, 2500 * u.nm,
molecule=molecule,
isotope='1',
pressure=1.01325, # bar
Tgas=T,
path_length=1 * u.cm, # cm
mole_fraction=1,
databank='hitran'
)
s.apply_slit(slit_size, unit="nm")
s.take('radiance').plot(nfig=1)
plt.show()
💡 Possible solutions
It seems that the problem is solved when translating the slit size to cm-1 (but then, it's not constant over the wave range in cm-1).
🎲 Radis version
0.14
💻 Operating system
Windows
Possible fixes :
Method 1 :
- Interpolate the spectrum from the calculated waverange (here: cm-1) to the slit waverange (here : wavelengths)
- Apply sit
- Interpolate back to the first waverange
We'll induce small interpolation errors.
Method 2:
- divide the spectrum in ranges where the slit expressed in cm-1 is approximately constant
- apply slit on each range, merge
Method 1 sounds easier
@saradelahaie I hope this issue is not hindering your progress. Let me know if this is the case. Otherwise I'll come back later on this issue (and secretly hope someone will apply Erwan's fix).
Labeled "Good first issue" since Erwan provided a method to solve the problem
i wanna take a stab at this
I'm looking at this now. Does this bug require knowledge of any advanced mathematics? I confess I only got up to Calc 2...
If you can understand the steps described by Erwan, it means you're good enough at maths :)
would you kindly explain the "slit_size" variable? cuz the docstring states that there are different ways to handle the "slit_size" parameter depending on the data type.
In the example, the slit_size is a float. For instance, you can set it to slit_size=1