Use wave subranges in user function input?
Dave_S
Is it possible to use a wave subrange as input to a user function? A simple example might be:
FUNCTION SubRangePlot(WaveToPlot)
Wave WaveToPlot
Display WaveToPlot
END
Wave WaveToPlot
Display WaveToPlot
END
Then on the command line, issue something like:
SubRangePlot( MyWave[0,10][2] )
When I try this, I get a "Syntax Error: expected right parenthesis" with the cursor highlighting the first open bracket in the command.
I know, for instance, the built-in command Display allows this -- is it possible to do something similar with a user function?
Specifically, I'm working with 2D data sets where the dependent variable (wavelength) is in rows, and each column corresponds to a new measurement location. I've already written a wrapper routine for CurveFit to parse apart a given image, but now I'd like to store the appropriate error bars and fitting weights in subsequent layers of the data sets (i.e. DataSet[2][4][[0] = raw data point, DataSet[2][4][1] = standard error for data point, DataSet[2][4][2] = fitting weight for this data point).
Ideally, I'd like to be able to say something like:
MyCurveFitWrapper( YData = DataSet[][][0], ErrorBars = DataSet[][][1], Weights = DataSet[][][2] )
I suppose I could write another wrapper routine to break apart the 3D wave, but at some point I might want to change around the order, etc of the input array's layers, columns, etc. If there's a way to use subranges as input it'd make life easier.
Thanks in advance
The good news is that Display, CurveFit and FuncFit all take in waves with subranges, so you shouldn't have to "break apart" your waves. But you will have to pass around separate variables that tell what part of a wave to use.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 15, 2015 at 04:32 pm - Permalink