xraypy / xraylarch

Larch: Applications and Python Library for Data Analysis of X-ray Absorption Spectroscopy (XAS, XANES, XAFS, EXAFS), X-ray Fluorescence (XRF) Spectroscopy and Imaging, and more.
https://xraypy.github.io/xraylarch
Other
127 stars 62 forks source link

Issue using diffkk to obtain mixing coefficients of inequivalent sites in DAFS data #426

Open Ayrtonb1 opened 1 year ago

Ayrtonb1 commented 1 year ago

Hi there,

I have been using DiffKK in Python for DAFS data plotting. I am using the DAFS signal as an input for DiffKK, that is the variation in intensity of a given diffraction peak as a function of energy at an edge.

I can get good data for diffraction peaks where there is only contribution from one site. However, I am wondering if DiffKK has the ability to calculate mixing coefficients in the cases where the diffraction peaks contain contributions from both inequivalent sites, so as to work out their relative contribution and subsequently separate them? I have perused the manual however I cannot see any mention of mixing coefficients, and so I thought I would bring up this query here. Apologies for my confusion here. Many thanks in advance for your time and assistance.

newville commented 1 year ago

@Ayrtonb1 No, diffkk doesn't do that separation of signals from inequivalent sites. Diffkk really only does the forward transform from mu(E) with fine-structure effects to f'(E) with equivalent fine-structure.

I think what you would want to do is an iterative approach: assert that either f' or f'' dominates the intensity for a reflection (and this can typically be predicted pretty well) so that some f'(E) can be approximated from the intensity. Then transform that to f''(E), verify that it is positive, and use that to mix with f'(E) to then predict the intensity(E). You might have to iterate a few times.

I have to admit it has been years since I have thought about this in detail, and I do not have code to do this. It would probably be a worthwhile addition to the codebase but I don't think I have the capacity to to that in the immediate future. I think I also no longer have usable DAFS data. If you have any code to do this and/or datasets, maybe we could get that into larch at some point?

Ayrtonb1 commented 1 year ago

Hi there Matt, Thank you for getting back to me so quickly.

Yes indeed, I think you are absolutely correct with what you suggest here, and that is what I have been trying to achieve. The exact method I am attempting proceeds as follows:

Currently, I use the lmfit package to generate a best fit to my experimental DAFS signal, to obtain fitting parameters as described by Julie Cross in their 1996 thesis. I then use these parameters and the atomic f'a/f"a to generate a better guess for f', and then I conduct a Kramers-Kronig transform to obtain f". The first iteration works well, and the data is aligned with the Cromer-Liberman values. However, crucially, when I try to run a second iteration of this method, the fit to my experimental data is not improved as I would expect, instead it massively overestimates the fine structure, and I cannot figure out why.

Would you happen to have any ideas on how to solving this issue? I can share a Git repository containing my code for you to see? I have DAFS datasets of 5 or 6 different samples at this point, and I'm sure if I can figure this out it would be a good addition to Larch. I know that Julie Cross used a program called KKFIT for this exact purpose, but I cannot find any repository of this program, or anything resembling it. I don't know whether this is something you may know where I may gain access to such a script, or even have access to it yourself? I understand that Julie Cross helped with the generation of DIFFKK, and I have tried to contact her regarding this on multiple occasions, sadly to no avail.

Also, I have been reading the 1998 paper relating to DIFFKK, and also section 13.9.1 of the LARCH manual in more detail to understand DIFFKKs intended purpose. It is worth noting that using DIFFKK and just applying it to my DAFS signals (I.E. with my DAFS signal substituted as the mew(E) XAFS input) of the well-documented Fe3O4 provides the exact results I would expect, after normalisation in ATHENA, as compared with FDMNES/FEFF simulations. Is it possible that DIFFKK can in fact be used in this way?

Apologies for such a lengthy query. I understand that you may have not given thought to this matter in a considerably long time. I am happy to clarify or elaborate on any of the above as far as possible. If you would rather discuss via e-mail (and are willing to do so), my email is ayrton.burgess.20@ucl.ac.uk. Thank you very much again, and enjoy your weekend.

maurov commented 1 year ago

@Ayrtonb1 any news on this? Are you willing to share your code and include it in Larch? I think the Larch community would be interested in refreshing some work on DAFS and related techniques requiring f'/f'' transform. Please, let us know if you want to contribute on this topic.