FAIRmat-NFDI / nexus_definitions

Definitions of the NeXus Standard File Structure and Contents
https://manual.nexusformat.org/
Other
5 stars 8 forks source link

Description of peak fitting (e.g., in XPS) #170

Open lukaspie opened 4 months ago

lukaspie commented 4 months ago

Resolves #158.

domna commented 4 months ago

I agree with the points @rettigl suggested. I think it would be nice to have specialisations of NXpeak (or NXpeak_fit), e.g., NXgaussian_fit, NXlorentz_fit, which supply a specific fixed set of parameters but I would also supply a general NXcurve_fit, which allows to use a formula. Gaussian and Lorentz lineshapes could also be reflected in it, but it requires a bit more effort from the user. This is what I opted to use in NXdispersive_material to describe dispersion curves with the option the specialise it later (https://fairmat-nfdi.github.io/nexus_definitions/classes/contributed_definitions/NXdispersion_function.html#nxdispersion-function). I also build a grammar for the function notation (see https://fairmat-nfdi.github.io/nexus_definitions/ellipsometry-structure.html#dispersive-material). The specialised lineshape could also be a formula notation with a literal specifying the actual formula. That way a reader wouldn't actually need to know the different peak lineshapes but could directly parse the formula and use that (I wrote a small formula parser for the dispersive material: https://github.com/PyEllips/formula-dispersion). We could also build a similar grammar for the xps peak fitting. I'm also part of a NIAC task force to design formula notation inside the NeXus format in which we will finalise a more rigid notation until September.

One small additional question: What happens if multiple peaks are supplied? Are they simply summed up?

lukaspie commented 4 months ago

Thanks for everybody's comments.

Based on your ideas, I suggest the following structure: we have an NXfit base class (extending NXobject) that can contain

This is then meant to be used for a peak fit in one region. For the XPS example, this could be used to describe the fitting of one measured C 1s spectrum.

Then, the peak_fitting process in NXxps does not actually have to be an NXpeak_model, but can rather be a regular NXprocess containing multiple instances of NXfit (for multiple measured regions) and some more XPS-related information like calculated atomic concentrations, and so on. What do you think?

lukaspie commented 4 months ago

After implementing the structure outlined above, I have started working on a more rigorous description of the fit functions and its parameters. A draft can be found in NXfit_function and classes within.

Now, peaks and backgrounds have a data(NXdata) field, containing the independent variable as well as the final, fitted intensity, and a function(NXfit_function) describing their functional form. Then, NXfit contains:

lukaspie commented 2 months ago

@rettigl @domna could you please have a look again here? I would like to merge this soon-ish.

As a reminder, this PR both has NXxps as an extending AppDef for NXmpes as well as the description of a general NXfit.