CurveFit and getting rid of W_sigma

I'm doing some curve fits while running live data acquisition.
Therefore I want the curve fits to be as fast as possible.

Can I somehow tell CurveFit to not create W_sigma? Or use a free wave for that?

My current invocation looks like:
    Make/FREE/D/N=2 coefWave
    variable V_FitOptions = 4
    variable V_FitError  = 0
    variable V_AbortCode = 0
        try
            CurveFit/Q/N=1/NTHR=1/M=0/W=2 line, kwCWave=coefWave, data[startRow,endRow][1][10]/X=data[startRow,endRow][0][3]/AD=0/AR=0; AbortOnRTE
        catch
                ....
         endtry


I know that not looking at W_sigma in a fit is usually not a clever thing to do ;)
I'm not the expert, but using a free wave for W_sigma might not actually speed things up -- the linear fit will still need the residual matrix to be calculated, so it might as well get saved.

Maybe you could instead speed things up by providing a better initial guess for the fit -- possibly using the previous W_coef wave?
Line fits don't use or need initial guesses, so that's not going to help here.

But you're also correct that the all the info needed to create the sigma wave is needed to do the fit, so the only saving would be in not creating the wave itself. If you are working in a datafolder with thousands of waves, that might, in fact, be slow. In order to create a new wave, Igor must first make sure you don't already have a wave called W_sigma. That requires walking a linked list of waves in the current data folder; if W_sigma is near the end of a list of thousands of waves, it can take a while.

So in the course of writing that description, I came up with a strategy that would work around it: pre-create a wave called W_sigma *before* you load your data waves into the current datafolder. That way Igor will find W_sigma right away and not have to walk very far.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Thanks John and jcor!

My main motivation was that without W_sigma the databrowser would not have to update after curve fitting.
I don't have thousands of waves in one folder.

I'm doing three of these line fits for every data channel.
Three line fits take, on my dev machine, 0.5ms. I have up to ~24 data channels.
So in the extreme case this takes up to 12ms.
Hmm... so the DataBrowser is updating during user function execution, even with CurveFit/N=1?

Can you do the timing with the DataBrowser closed?

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
johnweeks wrote:
Hmm... so the DataBrowser is updating during user function execution, even with CurveFit/N=1?


Sorry that was incorrect. I'm calling CurveFit from a background function and then only is the databrowser updating.
It is not updating during function execution.
If you could come up with an Igor experiment file with a good test case, I could run it here under Instruments (Apple's rather nice code profiler) to see where the time is being taken. The test case would need to run enough fits in a loop to make it take at least a couple of seconds.

Send it to support@wavemetrics.com.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com