Constrains in a 25-peak fitting: how to share a fitting parameter

Hello,

After vainly trying to find a solution to my problem by myself, I create this post to see whether there is an easy solution for it (sorry in case it has been already posted, I did not find it). Here the question goes:

I am using the fantastic multi peak fit program, running on a Igor version 6.36. Basically, I have to fit 25 lorenztian, positive peaks, equally spaced along the horizontal axis. From the physical point of view, these peaks MUST share the same HWHM (whatever it is, unknown before the fitting) and I should retrieve it after the fitting.

So in order to impose that condition I checked the box "Apply constrains" and in the "Inter-Peak Constrains" field I typed:
P0K1P0K1;P0K1P1K1;P0K1P2K1;P0K1P3K1;P0K1P4K1;P0K1P5K1;P0K1P6K1;P0K1P7K1;P0K1P8K1;P0K1P9K1;P0K1P10K1;P0K1P11K1;P0K1P12K1;P0K1P13K1;P0K1P14K1;P0K1P15K1;P0K1P16K1;P0K1P17K1;P0K1P18K1;P0K1P19K1;P0K1P20K1;P0K1P21K1;P0K1P22K1;P0K1P23K1;P0K1P24K1

which it is the way the condition "=" is imposed between parameters (as far as I read in the Igor Manual).

In total, that string is 529 characters. Problem is, before doing the fit, when I press enter in the "Inter-Peak Constrains" field and I recheck that ALL the constrains are still there, somehow, the previous constrains are cut in the following manner:

P0K1P0K1;P0K1P1K1;P0K1P2K1;P0K1P3K1;P0K1P4K1;P0K1P5K1;P0K1P6K1;P0K1P7K1;P0K1P8K1;P0K1P9K1;P0K1P10K1;P0K1P11K1;P0K1
So that, apparently, the text length of the "Inter-Peak Constrains" field is suspiciously limited to 255 characters :)

Please, could you help me to find an easier way to force the sharing of a common, certain parameter (HWHM in this case) in a multi-peak fit?

Thank you very much in any case.
Sorry, I noticed a few errors in my post, when I wrote: P0K1P1K1;...P0K1P24K1 the greater than (>) and less than (<) symbol disappeared, sorry for the typo. Part of the initial message was also cut, after the second list of "Inter-Peak Constrains" it was written the following:
***
So that, apparently, the text length of the "Inter-Peak Constrains" field is suspiciously limited to 255 characters :)

Please, could you help me to find an easier way to force the sharing of a common, certain parameter (HWHM in this case) in a multi-peak fit?

Thank you very much in any case.
***

Today, I realized that the "interPeakConstraints" string has a size of 255 characters, what deletes my constrains from the peak 11 constrain and on. Still, I would like to have a longer string that could keep all the constrain information, or any other better solution...

Thanks in advance!
carlosanton wrote:

So that, apparently, the text length of the "Inter-Peak Constrains" field is suspiciously limited to 255 characters :)


Apparently the maximum length of the string containing the constrains is 400 characters. I am trying to find any alternative way to proceed. Any help is very welcomed. Thanks.
I suggest that you could write your own peak fitting function with only one half-width parameter. I have not done this for a while, but as far as I recall, something perhaps like this should work ...

Function NLorentzPeaks(ww,xx)
    wave ww
    variable xx
   
    // ww[0] - number of peaks, N
    // ww[1] - half-width of all peaks
    // ww[2 - (N+2)] - amplitudes of each peak
    // ww[(N+3) - (2N+3)] - positions of each peak
   
    variable ic, npeaks, hw, sumpeaks = 0
    npeaks = ww[0]
    hw = ww[1]
   
    for (ic=0; ic<npeaks; ic+=1)
        // add the next peak with its height, position, and half-width
        sumpeaks += MyLorentzFunction(ww[2 + ic],ww[npeaks + 3 + ic],hw)
    endfor
   
    return sumpeaks
end


--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
You are totally right, that was the second option I was avoiding and that I will have to go for...
I just wondered whether it was possible to hack the multipeak fit package to impose longer constraints. But I think is time for me to do some programming :)

Thank you very much for your comment!

jjweimer wrote:
I suggest that you could write your own peak fitting function with only one half-width parameter. I have not done this for a while, but as far as I recall, something perhaps like this should work ...

Function NLorentzPeaks(ww,xx)
    wave ww
    variable xx
   
    // ww[0] - number of peaks, N
    // ww[1] - half-width of all peaks
    // ww[2 - (N+2)] - amplitudes of each peak
    // ww[(N+3) - (2N+3)] - positions of each peak
   
    variable ic, npeaks, hw, sumpeaks = 0
    npeaks = ww[0]
    hw = ww[1]
   
    for (ic=0; ic<npeaks; ic+=1)
        // add the next peak with its height, position, and half-width
        sumpeaks += MyLorentzFunction(ww[2 + ic],ww[npeaks + 3 + ic],hw)
    endfor
   
    return sumpeaks
end


--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville