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

Examples: aligning and merging datasets with Python #480

Open lnaglecocco opened 7 months ago

lnaglecocco commented 7 months ago

Hi,

I have seen that there are some very nice Python examples for using larch within the examples/Jupyter folder.

I am unsure the best practice for when we have several datasets collected sequentially (each with reference data) and wish to align and merge them. As far as I can tell, there is not currently an example of this amongst the examples. This is straightforward with XAS Viewer but in Python I am unsure how best to do this, and it would be nice to see what is considered the best way to code this, from the developer of xraylarch, in a way similar to the other example notebooks.

I wondered if at some point somebody could code an example in a Jupyter notebook and add it to the examples/Jupyter folder? This would be very helpful for me and possibly also for others

newville commented 7 months ago

@lnaglecocco Yeah, "auto-align one mu(E) spectrum to another" (or many spectra to one) is one of the few cases of an algorithm being "in the GUI" and not exposed as a separate function.

On the one hand, this would be fairly easy to move to Python code.

On the other, this is also something that can go spectacularly wrong without much warning and really benefits from visual inspection. All that is being found is an energy shift, which can be set in a number of different ways (including by hand). If you find you "need" an automated energy shift to every spectrum, then there may be something else wrong.

I think that, in general, having more examples in Jupyter would be great.

And, just to be clear, you can align and merge from the Larix GUI, save that session, and read that session (including aligned and merged groups) into Python.