Strings, Waves, and Multipeak Fitting
deconite
I have a wave. It's a 1D wave. I am attempting to get the multipeak fitting to work in my code. Usually if I've got some minor menu based thing that I'd like to duplicate I just copy what the prompt puts into the command line, and it works. So if I'm confused about how some fit or some other thing works it's an easy clarification. The Multi-peak fitting prompt puts nothing into the command line.
I cannot figure out how to get MPF2_AutoMPFit to work on my wave. I've been working on this for a few hours, and I believe it should be simple.
This is my current iteration. If anyone asks me 'why do you have this here' it's because I've been swapping the order of these things around combinatorically in order to pass the full wave into the MPF2_AutoMPFit function. No matter what I do, whether I've not even tried to create a string as reference or what, I cannot get ANY data points into the wave MPF2 thinks its acting on. This is in a huge body of code. optdepthroi is a monochromatic photograph converted to double precision.
If everything below looks like garbage, I just want to know how to start with a single 1D wave and have MPF2_AutoMPFit analyze the thing. I haven't the faintest clue.
MatrixOP/o plottingsum = sumrows(optdepthroi^t)
duplicate/o plottingsum fouriersumcomplex
duplicate/o plottingsum fouriersumreal
duplicate/o plottingsum fouriersumcomplex
fft /DEST = fouriersum plottingsum
fouriersumreal = real(fouriersum)
fouriersumcomplex = imag(fouriersum)
duplicate/o plottingsum plottingsumxwave
string plottingsumref = "root:Flea2g:plottingsumref"
make $plottingsumref
wave plottingsum = $plottingsumref
string plottingsumxref = "root:Flea2g:plottingsumxref"
make $plottingsumxref
wave plottingsumxwave = $plottingsumxref
plottingsumxwave[] = dimoffset(plottingsumxwave,0)+p*dimdelta(plottingsumxwave,0)
MatrixOP/o plottingsum = sumrows(optdepthroi^t)
MPF2_AutoMPFit("CurrentMultiPeak", "Gauss", "MomPeak%d", "Constant", "Background", "plottingsumref", "plottingsumxref", 5)// [, noiseEst, smFact, noiseEstMult, smFactMult, minAutoFindFraction, constraints])
duplicate/o plottingsum fouriersumcomplex
duplicate/o plottingsum fouriersumreal
duplicate/o plottingsum fouriersumcomplex
fft /DEST = fouriersum plottingsum
fouriersumreal = real(fouriersum)
fouriersumcomplex = imag(fouriersum)
duplicate/o plottingsum plottingsumxwave
string plottingsumref = "root:Flea2g:plottingsumref"
make $plottingsumref
wave plottingsum = $plottingsumref
string plottingsumxref = "root:Flea2g:plottingsumxref"
make $plottingsumxref
wave plottingsumxwave = $plottingsumxref
plottingsumxwave[] = dimoffset(plottingsumxwave,0)+p*dimdelta(plottingsumxwave,0)
MatrixOP/o plottingsum = sumrows(optdepthroi^t)
MPF2_AutoMPFit("CurrentMultiPeak", "Gauss", "MomPeak%d", "Constant", "Background", "plottingsumref", "plottingsumxref", 5)// [, noiseEst, smFact, noiseEstMult, smFactMult, minAutoFindFraction, constraints])
Indeed. Multipeak Fit is kind of too complicated for that.
No, MPF2_AutoMPFit() is not simple!
The only thing I see that might be a problem is your lists of X and Y waves. If you are running in the root data folder (or any data folder other than root:Flea2g) you need a data folder path to the waves. So your Y wave list would be "root:Flea2g:plottingsumref;". It shouldn't really require the trailing semicolon, but it seems like a recall a bug that a "list" of one item at some point required the trailing list separator.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
April 21, 2017 at 01:44 pm - Permalink
I tried passing both root:Flea2g:plottingsumref and root:Flea2g:plottingsum to the y wave, and the corresponding pair of the xwave, and tried letting the function run with _calculated_ by using empty quotes as the ipf file prescribes, and I still seem to not be passing any data points to the function. I've tried it both with and without the semicolon. The background wave has one data point, and its value is zero. Not a single data point in the ywave I'm trying to pass is zero.
Plottingsum, plottingsumref, plottingsumxwave, and plottingsumxref all show up in the data browser as real waves with 374 rows.
Going through the ipf file and trying to find where things might go wrong, I note that no errors are thrown, such as MPF2_Err_NoDataSets.
The function creates the fit info for four peaks, which is the same number picked up if I go through the fitting routine in a windowed mode instead of command line, but the estimate coefficients are all 10^-6. The fit parameters are not. When I run through the thing in windowed mode I do not get the same fit parameters even though I believe I'm entering the same options. And the command line version never produces fit_plottingsum by any name, or res_plottingsum, or any of the strings that are output by the windowed version.
As you state the program itself is not simple, though I believe passing a wave to it should be. I'm going to continue to go through it and try to figure out where it stops functioning.
Is there any place where errors SHOULD display in the command line version? Or it it suppressed somehow? Is there a way to unsuppress the windowed version's command line output?
April 24, 2017 at 07:42 am - Permalink
Just inspecting your code (no Igor testing), it seems to me that when you call MPF2_AutoMPFit, the input should just be the string name plottingsumref instead of the string "plottingsumref". Same for plottingsumxref.
April 24, 2017 at 08:27 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
April 24, 2017 at 09:10 am - Permalink
April 25, 2017 at 12:23 pm - Permalink