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

Calrification on the MBACK function #483

Closed Littl3Bug closed 3 months ago

Littl3Bug commented 6 months ago

Hello, I am trying to normalize some HERFD-XANES data with the MBACK function using larch 0.9.74 version but when I plot the f2 and fpp I notice that the f2 it is not a smooth function but is rather a segmentation of linear functions. In my python code I'm simply accepting the default values of the MBACK for pre-edge and post edge values as following:

mback(x_larch, y_larch, group=data, z=58, edge= 'L3', order= 1) (example for Ce L3 edge data)

I attach two examples of Ce L3 edge data and for Pt L3 data. CeO2 mback PtO2

newville commented 6 months ago

@Littl3Bug Yes, the f2 array will be the tabulated values from Chantler, which are a bit sparse for XAFS data (for Ce, there are 12 energy tabulated points between 5600 and 5800 eV), and those are (currently) linearly interpolated onto the energy array of the data. So, that curve may look segmented.

I don't think it is causing any trouble though... The mback method (or, at least Larch's version of the mback method) gives no weight to the region between "pre2" and "norm1" when it tries to match the data to f2.

Littl3Bug commented 6 months ago

@newville Thanks for the clarification over the shape of the f2, now I understand. I will change the the title of this issue in something more appropriate. ;)

Cheers

Littl3Bug commented 6 months ago

Hello @newville I'm sorry to reopen the issue, but I have a still a doubt on the normalization with larch mback method. Today I looked in more details the normalization of my PtO2 data of the Pt L3 edges and I'm not understanding what the mback is doing when it returns the normalized data (data.norm) since the pre-edge region gets modified such to have a slightly positive/negative slope. Below I show some normalization trials both leaving the mback default setting or setting manually the pre1 and pre2 values).

Normalization with default values mback(x_larch, y_larch, group=data, z=78, edge= 'L3', order= 1 ) PtO2 PtO2 mback _norm PtO2 mback _norm_zoom Normalization with "manual" values mback(x_larch, y_larch, group=data, z=78, edge= 'L3', order= 1, pre1 = -60, pre2 =-20 ) PtO2 manual PtO2 manual mback _norm PtO2 manual mback _norm_zoom

I also tried to normalize the same data collected up to the EXAFS range (maybe the data range I was doing the normalization was to small). Still the normalized data have the same effect on the pre-edge region. Normalization with default values over a larger data range mback(x_larch, y_larch, group=data, z=78, edge= 'L3', order= 1 ) PtO2_large PtO2 mback _norm_large PtO2 mback _norm_large zoom

The data are HERFD thus the original pre-edge region is pretty flat... never the less the original slope get modified with mback. Is there any way I can visualize what function is subtracted to the experimental data?

Thanks for your feedback

newville commented 6 months ago

@Littl3Bug when using MBACK (it might be fair to ask of you: have you decided that this method is right for your data?), it will try to match your data to the tabulated values of f''(E) from Chantler.

Those tabulated data will have a definite overall slope over a large energy range (noticeable over 1 keV for sure).
The f''(E) values from Chantler will also be core-hole broadened, which at Pt L3 is sort of large (hence HERFD).

Try

e = linspace(11300, 11900, 301) 
newplot(e, f2_chantler('Pt', e), marker='o', linewidth=0.5, xlabel='E (eV)', ylabel='f2', title='Pt', label='f2')

to get image

But HERFD data will not have such a slope to it at all, and the Lorentzian broadening from the core hole is probably not wanted.

That is, I sort of think MBACK is not really appropriate for HERFD data. Or at least, not MBACK as it is implemented at the moment.
Maybe HERFD should just be normalized to a step function?

maurov commented 3 months ago

@Littl3Bug I fully agree with @newville that MBACK is not suited for normalizing HERFD data. Please, use the standard pre-/post-edge lines procedure for normalizing your data. This is not an issue with the MBACK algorithm and I will close it then.