Batch curve fitting - file sorting

Hello,

I have several files that I'd like to run through the Batch Curve Fitting procedure. These are spectral x and y data files, with the names as follows - xspec.1, yspec.1; xspec.2, yspec.2; ... and so on until a few hundred. The issue is that when I load them into the batch file converter, the order of the files changes. For example, if I filter the "y" files and load them, the order appears as follows - yspec.0, yspec.1, yspec.10, yspec.100, yspec.1, yspec.11, and so on. Spectrum number 10 follows number 1, instead of number 2, and of course when I run the fit the coefficients fall in the same order and it's painful to sort through.

Is there a way to automatically order the data into the procedure?

Unfortunately, the files are named so because of the source ascii files. I loaded these using a custom batch loadwave procedure in which I assigned the name of the loaded wave the same as the original filename, minus the ".asc".

It would work for me to rename the files so that they automatically get loaded into the right order in the batch curve fitting procedure, or somehow order them after loading them into the procedure.

Thanks

Rahul


I'm not familiar with the batch curve fitting procedure. You might try presorting your wave lists with SortList(listStr [, listSepStr [, options ]).
Hello Rahul,

Batch Curve Fit loads the waves in the order they appear in their data folder. Sadly the only way to re-order those waves is to move a wave out of the data folder, then move it back in - placing it at the end. You could change your custom batch loadwave to load in the desired order. Another option from inside Batch Curve Fit is to add them in the desired order. You can highlight consecutive chunks, then click "Add." I realize that might be a little painful, however.

You could, with some trepidation, try the following function. I whipped it up pretty quickly. It will sort waves in a data folder by simply taking them all out, sorting them in the order I think you want, then placing them back in. It worked in a simple test, but do save a back-up save of your experiment before trying it. Once you've sorted the waves in the data folder Batch Curve Fit should load them in the same order.

// Note: creates a temporary data folder named x____tempDF_____x
// It then deletes that data folder.  If you for some crazy reason have a DF with that
// name then change this temporary name!
Function sortWavesInDataFolder(dRef, baseName)
    DFREF dRef
    String baseName
   
    DFREF currDF = GetDataFolderDFR()
    SetDataFolder dRef
   
    NewDataFolder /O root:x____tempDF_____x
    DFREF tempDF = root:x____tempDF_____x
   
    String waveNames = WaveList(baseName+"*", ";", "")
   
    Variable nWaves = itemsInList(waveNames)
    Variable i
   
    String desiredWaveNames = ""
    String currWaveName

    for (i=0; i<nWaves; i+=1)
        desiredWaveNames += baseName+num2str(i)+";"
    endfor
   
    for (i=0; i<nWaves; i+=1)
        currWaveName = StringFromList(i, waveNames)
        MoveWave dRef:$currWaveName, tempDF
    endfor
   
    for (i=0; i<nWaves; i+=1)
        currWaveName = StringFromList(i, desiredWaveNames)
        MoveWave tempDF:$currWaveName, dRef
    endfor 
   
    setDataFolder currDF
   
    KillDataFolder tempDF
End


I called it with:

sortWavesInDataFolder(root:testData, "xspec.")

Hope this helps.

Nate Hyde
WaveMetrics
support@wavemetrics.com
Nate,

I tried the function but it seems like it's deleting all the waves. They disappear after I run the function.

Rahul
Quote:
I tried the function but it seems like it's deleting all the waves. They disappear after I run the function.


I'm not sure what is wrong with Nate's function. It definitely has some assumptions that are not stated in comments. Also it is too special-purpose for my test. I have written a more generic and better-documented function and posted it at http://www.igorexchange.com/node/6493