Quasars / orange-spectroscopy

Other
52 stars 58 forks source link

[WIP][FIX] irfft: ramp correction and apodization fix for asymmetric interferograms #641

Open stuart-cls opened 1 year ago

stuart-cls commented 1 year ago

Fixes an old error in the apodization function generation for asymmetric interferograms, found while adding a ramp correction to avoid double-counting in the symmetric section. Illustration of the issue:

new-apod-ramp

The above figure illustrates how the original apodization code was handling the taper to zero needed in asymmetric interferograms. While it does bring the amplitude to zero at the edge of the short side, it obviously badly violates the symmetry requirements. This would not have been obvious on the original symmetric test interferograms.

borondics commented 1 year ago

@stuart-cls I think the "original" (on your figure) asymmetric apodization was meant for SNOM IFGs and the intention was to have that shape, where not only the position of the ZPD is offset but also the apodization. In my understanding the reason for this is that the near field signal is contained only on one side of the ZPD and the other should be down-weighted. There is some literature on this: http://hdl.handle.net/10810/26669

NeaSpec does something very similar, but their calculations are proprietary.

However, I think there is some actual scientific discussion missing... @raul-freitas, @levandoskije, what do you think?

stuart-cls commented 1 year ago

@borondics I'm pretty sure this part of the code predates SNOM!

That said, I definitely don't want to break anything correct. I will simply note that for asymmetric interferograms in an FT-IR, downweighting the short side via shrinking the apodization window ("old") is not the same as downweighting the short side via the ramp ("new + ramp"), and the latter is the correct way.

I'll review the literature you sent, I'm also waiting on other feedback.

If you have any before / after data of what Neaspec is doing, please send it along: we can compare the two approaches. This is basically what I did for the Agilent imaging data to check for correctness.

raul-freitas commented 1 year ago

Hello @borondics and @stuart-cls. I will try to answer you soon with some old data. I will get back to this subject quite soon and I hope to have some direct feedback from the company, as we are processing raw interferograms (.gsf files). I remember playing a bit in the past and comparing my processing with Neaspec processing, I could not exactly reproduce (at least the high frequency features).

Maybe we can plan some synchronized activities soon. I have two new folks that will give some support to Orange-Quasar in here.

borondics commented 1 year ago

I was just browsing SciPy for something and realized that many (all?) of the apodization functions are implemented there. Since SciPy is a dependency, should we simply use those functions to decrease the code?

stuart-cls commented 1 year ago

@borondics I'm aware of those functions. Originally I wanted to keep the dependencies of irfft minimal for easy re-use in other projects. scipy is not so annoying to install anymore but I'd still rather keep that.

Dependencies aside, I looked at how those windows are implemented this time around and they don't work for either of the types of apodization we would like to do.

Which brings me to the summary of the current state of this PR: based on our discussions offline, the thesis above, and feedback from others, I think we will have to distinguish between interferometer types:

  1. Symmetric (Michelson-type) interferometer a. Fully symmetric interferogram ("Symmetric" in current GUI) b. Truncated symmetric interferogram ("Asymmetric" in current GUI)
  2. Asymmetric (s-SNOM type) interferometer

where type (1) will use this symmetric + ramp approach and type (2) will use the existing approach of different apodization functions for each wing.