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

Modelled data shift #478

Closed SiebevanderVeer closed 3 months ago

SiebevanderVeer commented 7 months ago

Hi all,

I see something odd while data fitting. After I do fit I get a plot where the model follows the data (work in progress of course), but as soon as I change the view of the data, e.g. turn off plotting each path, the modelled data shifts. See images below as an example.

I'm not 100% sure which of the two is the actual fitted model that larix provides the fit statistics and parameter values for.

Best,

Siebe

After fit After deselecting plot each path

newville commented 7 months ago

@SiebevanderVeer Hm, not sure... that does look strange. Can you post or send by email a Session File with this?

newville commented 7 months ago

@SiebevanderVeer Thanks for the project file -- I can reproduce these plots. It looks to me like things are mostly OK, and I'm wondering if maybe it just some confusion.

From the Fit results window, I get basically the same as what you get:

Fit Result "Plot Current Model" with "Plot Each Path" unchecked:

image

Fit Result "Plot Current Model" with "Plot Each Path" checked:

image

Those seem consistent to me, and what you see for "fit, with all the paths".

But then, if I go back to the Feffit Window and click "Plot Current Model" from there, I get

image

which looks a lot like your second plot. But this plot from the Feffit window that plot is with the model before fitting, without the refined parameters -- basically "Initial fit". Does that make sense and seem like maybe what is going on? Or are you getting your second plot from the "Feffit Results" window?

For me (with the latest version??), all of your fits labeled "Nov-17 ..." in the Feffit Results page show the peak amplitude of the model is slightly below the peak amplitude of the data, as in your plot with all the paths.

It should be that from the "Feffit Results" window, you can click on "Update Model with these values" to make the refined values the new initial values in the main Feffit Window. But that is not done by default for each fit.

SiebevanderVeer commented 7 months ago

Ah, I see. You are correct, that is what I'm doing. I did not connect the dots that the main window uses those values for the plot.

Thanks a lot for clarifying this for me.

On Fri, Nov 17, 2023 at 10:21 PM Matt Newville @.***> wrote:

@SiebevanderVeer https://github.com/SiebevanderVeer Thanks for the project file -- I can reproduce these plots. It looks to me like things are mostly OK, and I'm wondering if maybe it just some confusion.

From the Fit results window, I get basically the same as what you get:

Fit Result "Plot Current Model" with "Plot Each Path" unchecked:

[image: image] https://user-images.githubusercontent.com/304251/283932695-98886904-a254-4556-b7c1-edf356b39227.png

Fit Result "Plot Current Model" with "Plot Each Path" checked:

[image: image] https://user-images.githubusercontent.com/304251/283932846-3ad774f2-241c-4ce5-bf7d-2feb9dd6651e.png

Those seem consistent to me, and what you see for "fit, with all the paths".

But then, if I go back to the Feffit Window and click "Plot Current Model" from there, I get

[image: image] https://user-images.githubusercontent.com/304251/283933054-da054ec6-8cd0-4000-81c8-b4fb37db707e.png

which looks a lot like your second plot. But this plot from the Feffit window that plot is with the model before fitting, without the refined parameters -- basically "Initial fit". Does that make sense and seem like maybe what is going on? Or are you getting your second plot from the "Feffit Results" window?

For me (with the latest version??), all of your fits labeled "Nov-17 ..." in the Feffit Results page show the peak amplitude of the model is slightly below the peak amplitude of the data, as in your plot with all the paths.

It should be that from the "Feffit Results" window, you can click on "Update Model with these values" to make the refined values the new initial values in the main Feffit Window. But that is not done by default for each fit.

— Reply to this email directly, view it on GitHub https://github.com/xraypy/xraylarch/issues/478#issuecomment-1817122007, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6GPKO6BPC6UJVVZWHBXKZTYE7IMBAVCNFSM6AAAAAA7PQMD6WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJXGEZDEMBQG4 . You are receiving this because you were mentioned.Message ID: @.***>