On 12/12/2012 8:03 PM, Matt Newville wrote:
Hi Matthew, Bruce, All,
Sorry for not being able to join this discussion earlier. I agree that having glitch-free data is preferred. But I also think it's OK to simply remove diffraction peaks from XAFS data -- you're just asserting that you know those values are not good measurements of mu(E). I don't see it as all that different from removing obvious outliers from fluorescence channels from a multi-element detector -- though that has the appeal of keeping good measurements at a particular energy.
That's kind of my point. The standard methods, which require uniform tabulation, cause you to fill gaps in data by interpolation. Effectively, you're claiming knowledge of data for which you don't have knowledge. Better to use a method which preserves agnosticism about the bad data. The method I described for deglitching with reference scalers tries to preserve what information you do have by allowing you to ignore some channels. That only works if there are 'good' channels to serve as references.
I'm not sure that "slow FT" versus "discrete FT" is that important here, though perhaps I'm missing your meaning. My vies is that The EXAFS signal is band-limited (finite k range due to F(k) and 1/k, and finite R range due to F(k), lambda(k), and 1/R^2), so that sampling on reasonably fine grids is going to preserve all the information that is really there.
Again, FFT requires a uniform tabulation of data in k-space, which is generally secured by interpolation. Traditionally, this has been histogram interpolation, which tries to take into account the possibility of having multiple data points within one of the new intervals in k. That method, however, has to 'make up' data when there isn't any in one or more intervals. Actually, there are three possible tiers of speed. There's FFT, there's discrete FT done the slow way by computing the sums as they appear in the textbook (possibly good if you want a funny grid in R space), and then there's what I propose.
I do think that having richer window functions and spectral weightings would be very useful. You could view chi(k) data with glitches ias wanting a window function that had a very small value (possibly zero: remove this point) exactly at the glitch, but had a large value (~1) at nearby k-values.
Another (and possibly best) approach is to assign an uncertainty to each k value of chi. At the glitch, the uncertainty needs to go way up, so that not matching that point does not harm the overall fit.
A window function which went to 0 in the glitch region is tantamount to an assertion that chi(k)=0 there, which is generally not so and is probably a lot worse than the error you make by even the lamest interpolation through the glitch. The uncertainty makes more sense, except that if you filter data, the noise spreads out in a correlated manner over adjacent regions. Also, the tacit assumption of an uncertainty-based method is that the noise is uncorrelated within the high-uncertainty region. That said, I can imagine that this is one of those methods that works better than it has any right to. Now, in my proposed system, how would you fit filtered (q-space) data? The first step is to do the very slow FT (VSFT) on the input data with no interpolation. This leads to a set of sines and cosines which replicate the data. I would then apply the window and do the back-summation of all those sines and cosines at the given points. This will undoubtedly introduce some artifacts near the edges of the deleted regions simply due to our ignorance of what the data really do in there. Next, in each fit iteration, I would evaluate the model function at each point, then do the VSFT and filtering exactly as had been done on the data, which causes the fit to have the same artifacts. Since the VSFT and filter operations are linear, it should be possible to pre-compute a kernel which relates the values of unfiltered data to those of filtered data. This would be a matrix of size Np*Np with Np=# of points. Using the kernel instead of evaluating gazillions of trig functions would be reasonably fast; I suspect that ifeffit does a similar trick. Similarly, fitting in R-space would be accomplished by computing the VSFT on data and model function. Yes, I know I talk a good game. Unfortunately, I'm too swamped to attempt implementation. Also, I'd have to reinvent a number of very well-engineered wheels to do it.
Larch has a separate Transform class used for each dataset in a fit - this includes the standard FT parameters and fit ranges. It is intended to be able to do this sort of advanced windowing (and in principle, advanced weighting too). Currently (I'd be ready for a release but am commissioning our new beamline and am hoping to post a windows installer by the end of the month) this has "the standard XAFS window functions", but one can create their own window functions (for k- and/or R-space) with suppressed points/regions, etc, and use them as well. I have to admit I haven't tried this, but it was definitely part of the intention, and should work. My hope is to extend this to include some wavelet-like weightings as well.
What is Larch? Is it a replacement for ifeffit? By 'class' do you mean object as in OOP? "And now for something completely different. The larch." - Monty Python mam