Fitting three spectra simultaneously with the same parameters

120 views
Skip to first unread message

Simon Kohn

unread,
Jul 31, 2019, 9:10:35 AM7/31/19
to fityk-users
Hello, I am new to fityk and I like a lot of things about it. I have mostly used the GUI but am exploring the use of the command line also. My operating system is Mac 10.12.6.

My problem is that I have three spectra (they are FTIR spectra of the same sample but with different polarisations). I need the position and width of each peak to be forced to be the same between the three spectra but allow the height to vary. It looks like I should be able to do this in the GUI using cmdR then clicking "all datasets" and unchecking "fit each dataset separately". It doesn't work though. I also tried typing fit@* in the command line, but again each spectrum is fitted with completely different parameters.

What am I doing wrong? Any help much appreciated.

Simon

Marcin Wojdyr

unread,
Jul 31, 2019, 7:01:32 PM7/31/19
to fityk...@googlegroups.com
Hi Simon,

Usually, the position and width of each peak is an independent parameter.
To use the same parameter for the position of the first function in
each dataset type:

@*: F[0].center = @0.F[0].center

And similarly, to set the width of each first function to the width of
the first function from the first dataset do:

@*: F[0].hwhm = @0.F[0].hwhm

Best wishes,
Marcin
> --
> http://groups.google.com/group/fityk-users
> ---
> You received this message because you are subscribed to the Google Groups "fityk-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fityk-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/fityk-users/172e9c3e-9e6d-47ee-8c1c-4fd8779f202d%40googlegroups.com.

Simon Kohn

unread,
Aug 1, 2019, 5:27:35 AM8/1/19
to fityk-users
Hi Marcin,

Thanks for the quick reply. As I said I am very new to Fityk so still trying to understand the approach. If I have 12 peaks (for example) do I have to write this separately for each function, so F[0]......F[11]? Also more fundamentally do I have to write a script with all these instructions, or if I type the rule into the command line will it remember the constraint each time I do a new fit of the datasets? Unfortunately I have been doing something wrong as typing your text into the command line has not had the desired effect.

Sorry about the very basic questions. I will keep trying.

Thanks,

Simon


On Thursday, August 1, 2019 at 12:01:32 AM UTC+1, Marcin Wojdyr wrote:
Hi Simon,

Usually, the position and width of each peak is an independent parameter.
To use the same parameter for the position of the first function in
each dataset type:

@*: F[0].center = @0.F[0].center

And similarly, to set the width of each first function to the width of
the first function from the first dataset do:

@*: F[0].hwhm = @0.F[0].hwhm

Best wishes,
Marcin


On Wed, 31 Jul 2019 at 15:10, Simon Kohn <gl...@bristol.ac.uk> wrote:
>
> Hello, I am new to fityk and I like a lot of things about it. I have mostly used the GUI but am exploring the use of the command line also. My operating system is Mac 10.12.6.
>
> My problem is that I have three spectra (they are FTIR spectra of the same sample but with different polarisations). I need the position and width of each peak to be forced to be the same between the three spectra but allow the height to vary. It looks like I should be able to do this in the GUI using cmdR then clicking "all datasets" and unchecking "fit each dataset separately". It doesn't work though. I also tried typing fit@* in the command line, but again each spectrum is fitted with completely different parameters.
>
> What am I doing wrong? Any help much appreciated.
>
> Simon
>
> --
> http://groups.google.com/group/fityk-users
> ---
> You received this message because you are subscribed to the Google Groups "fityk-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fityk...@googlegroups.com.

Marcin Wojdyr

unread,
Aug 6, 2019, 2:08:49 PM8/6/19
to fityk...@googlegroups.com
Hi Simon,

yes, you'd need to do it separately for each function.
The commands should work regardless if they are in a script file or
typed directly in the program.
Have you made it work? For example, if you type:
@1.F[0].center = @0.F[0].center
the first functions (first in the order in which they were added) in
the first two datasets should have the same position.

Marcin
> To unsubscribe from this group and stop receiving emails from it, send an email to fityk-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/fityk-users/fa25c1f7-ce3c-44b7-bd72-de552c76a7c5%40googlegroups.com.

Simon Kohn

unread,
Aug 8, 2019, 3:36:17 AM8/8/19
to fityk...@googlegroups.com
Hi Marcin,

Yes, I am getting somewhere now! My data are quite complicated, so it will take some time to perfect the fits, but I understand the principle now and it is definitely working. I think I was confused by the fact that the functions are listed as _1, _2, _3 etc in the table in the top right pane of the gui, but (in the example of two spectra being processed together), _1 and _2 are F[0], _3 and _4 are F[1], _5 and _6 are F[2] etc.

Many thanks for providing the software to the community and for your personalised help.

Simon
> To view this discussion on the web visit https://groups.google.com/d/msgid/fityk-users/CACaHzQX6OfVp3KnjBnnwxocn%3D%2Bmdw3Hxug_U%3DWJP%2BqV8%3Den38A%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages