Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 67 commits into from
Sep 11, 2024

Conversation

lukaspie
Copy link
Collaborator

@lukaspie lukaspie commented Feb 13, 2024

  • Adds a general, multi-dimensional description of an NXfit.
  • Description of peaks, backgrounds, and their functional form.
  • Extends NXxps
    • Uses peak fitting model

Resolves #158.

@lukaspie lukaspie linked an issue Feb 13, 2024 that may be closed by this pull request
@lukaspie lukaspie mentioned this pull request Feb 13, 2024
Copy link
Collaborator

@mkuehbach mkuehbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make n-dimensional

contributed_definitions/nyaml/NXbackground.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXfit_region.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXpeak.yaml Show resolved Hide resolved
contributed_definitions/nyaml/NXpeak_model.yaml Outdated Show resolved Hide resolved
manual/source/mpes-structure.rst Outdated Show resolved Hide resolved
Copy link
Collaborator

@rettigl rettigl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intersting approach, but I find it a bit much XPS-specific. I suggest to create a more universal description of a curve fitting procedure (see specific suggestions)

contributed_definitions/nyaml/NXbackground.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXbackground.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXbackground.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXfit_region.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXfit_region.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXxps.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXxps.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXxps.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXxps.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXxps.yaml Outdated Show resolved Hide resolved
@domna
Copy link

domna commented Feb 15, 2024

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
Copy link
Collaborator Author

lukaspie commented Feb 15, 2024

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

  • a start and stop value for the region (could also simply be an array, not sure)
  • one or more of NXfit_background
  • one or more of NXpeak (could also be called NXfit_peak)
  • the fitting method
  • the fit envelope
  • the residual
  • figure-of-merit with attribute metric

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
Copy link
Collaborator Author

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:

  • one or more NXfit_background
  • one or more NXpeak
  • another fit_function -> this is to be used to describe the actual fit that is performed
  • a data(NXdata) with
    • the independent variable input
    • the dependent variable input
    • the fit envelope
    • the residual
  • one or more figure_of_merit_METRIC fields

@lukaspie lukaspie mentioned this pull request Feb 28, 2024
@lukaspie lukaspie changed the title Draft: Description of XPS peak fitting Draft: Description of peak fitting (e.g., in XPS) Mar 11, 2024
@lukaspie lukaspie changed the title Draft: Description of peak fitting (e.g., in XPS) Application definition for XPS, description of peak fitting (e.g., in XPS) Apr 10, 2024
@lukaspie lukaspie marked this pull request as ready for review April 10, 2024 13:42
@lukaspie
Copy link
Collaborator Author

@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.

Copy link
Collaborator

@rettigl rettigl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NXxps seems to be mostly fine, but the indended use of the NXfit base classes is at various places not clear to me. Do you have a working example of how to use this?

contributed_definitions/nyaml/NXfit.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXfit.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXfit.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXfit.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXfit_background.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXxps.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXxps.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXxps.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXxps.yaml Outdated Show resolved Hide resolved
contributed_definitions/nyaml/NXxps.yaml Outdated Show resolved Hide resolved
@lukaspie lukaspie changed the title Application definition for XPS, description of peak fitting (e.g., in XPS) Description of peak fitting (e.g., in XPS) Jun 19, 2024
@lukaspie lukaspie force-pushed the 158-xps-peak-fitting-in-nexus branch from 6bfa90f to eedcbf6 Compare July 5, 2024 09:13
Copy link
Collaborator

@mkuehbach mkuehbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has in my opinion already been developed and converged well enough to merge as a version to have something for the discussion with the NIAC @lukaspie
Aspects of what would be nice to have additionally we can always solve along the way.
Currently though NXpeak,

BUT merge conflicts need to be resolved

@lukaspie lukaspie force-pushed the 158-xps-peak-fitting-in-nexus branch from 12a5edc to 6ffb9d6 Compare August 30, 2024 14:31
@lukaspie lukaspie merged commit 5a3e07d into fairmat Sep 11, 2024
6 checks passed
@lukaspie lukaspie deleted the 158-xps-peak-fitting-in-nexus branch September 11, 2024 07:42
@lukaspie
Copy link
Collaborator Author

Merged, there may be small updates if an example is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XPS Peak fitting in NeXus
4 participants