radis icon indicating copy to clipboard operation
radis copied to clipboard

Bug report: Slit size depends on the wave range that it is applied on

Open saradelahaie opened this issue 1 year ago • 8 comments

🐛 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. image

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

saradelahaie avatar Jul 19 '23 08:07 saradelahaie

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

erwanp avatar Aug 01 '23 14:08 erwanp

@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).

minouHub avatar Aug 04 '23 09:08 minouHub

Labeled "Good first issue" since Erwan provided a method to solve the problem

minouHub avatar Mar 30 '24 20:03 minouHub

i wanna take a stab at this

tactipus avatar Mar 30 '24 23:03 tactipus

I'm looking at this now. Does this bug require knowledge of any advanced mathematics? I confess I only got up to Calc 2...

tactipus avatar Apr 04 '24 02:04 tactipus

If you can understand the steps described by Erwan, it means you're good enough at maths :)

minouHub avatar Apr 04 '24 06:04 minouHub

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.

tactipus avatar May 09 '24 02:05 tactipus

In the example, the slit_size is a float. For instance, you can set it to slit_size=1

minouHub avatar May 17 '24 16:05 minouHub