SasView / sasview

Code for the SasView application.
BSD 3-Clause "New" or "Revised" License
52 stars 41 forks source link

Adding Peak sub-category to fitting page #2080

Open ldschmitt opened 2 years ago

ldschmitt commented 2 years ago

Is your feature request related to a problem? Please describe. I would like to be able to combine the following peak functions into a new sub-category for fitting:

Gaussian, Lorentzian, Voigt and Pseudo-Voigt

Describe the solution you'd like I would like a new sub-category put into the fitting page that contains Gaussian, Lorentzian, Voigt and Pseudo-Voigt functions as defined below:

Gaussian:

I(q)=A/(sqrt(2pi)B)exp^[(q-q0)^2/2B^2]+C

A=Scale B=sigma C=background

FWHM=2sqrt(2ln(2))B

Lorentzian:

I(q)=A/pi(0.5B)/([q-q0]^2+[0.5*B]^2)+C

A=Scale B=FWHM=gamma C=Background

Voigt: I(q;\sigma ,\gamma )\equiv \int _{-\infty }^{\infty }G(q';\sigma )L(q-q';\gamma )\,dq

Pseudo-Voigt a linear combination of Gaussian and Lorentzian

N(q)=NG(q)+(1-N)L(q)

C=Background should be linked between Gaussian and Lorentzian or pulled out to be on its own. Describe alternatives you've considered I considered leaving the peak functions in the shape-independent sub-category but I found that instead of FWHM which is accepted by the magnetism SANS community, most of them are using HWHM. Also the widths for the Gaussian and Lorentzian in the Voigt and Pseudo-Voigt needs to be independent to take into account resolution effects

Additional context None.

butlerpd commented 1 year ago

@ldschmitt I assume you are talking about 1D models? If so, note that the user already should have the ability to create whatever custom category they like for themselves and tag whatever models they want to be members of that category. Is this what you are asking for? I will admit however that that functionality has not been tested heavily yet so may be a bit buggy.

On the other hand if we think this is more something that should be a permanent category that rolls out with those functions that should be fairly straightforward to do I think? Again possibly a good first issue 😄

ldschmitt commented 1 year ago

I think this should be a permeant category. As more and more SAND (small-angle neutron diffraction) users start using SASview for magnetic SANS analysis. Yes you can use custom models but then that community would have to make each peak fitting function each time they have a new member/student join.

butlerpd commented 11 months ago

To be clear, allowing users to tag models they want in a custom category does not require every person to remake each fitting function. They would just have to assign the existing functions to their preferred category. That is also true if the function is just downloaded in the marketplace - they can also be assigned to any category desired. That said, if we start adding a number of peak functions a new universal peak category makes sense to me.

smk78 commented 11 months ago

I would support a separate 'peak' category. In which case, it would also be good to agree and implement a consistent naming convention.

At the moment we have the models broad_peak, gaussian_peak, but peaklorentz! So are we *_peak or peak\*? And then surely the last of these models should be lorentzian, not lorentz?

Then on the Marketplace we have sasfit_broad_peak (but which actually steals the same namespace as broad_peak) and peak_voigt (which is actually a pseudo Voigt).

However, addressing the names would presumably have some implications for backward compatibility with projects? On the other hand, we know 6.0.0 is going to break backward compatibility in other areas, so maybe now is the time to go for it?!