FindLevels
FindLevels [/B=box /D=destWaveName /DEST=destWaveName /EDGE=e /M=minWidthX /N=maxLevels /P/Q /R=(startX,endX)/T=dx]waveName, level
The FindLevels operation searches the named wave to find one or more X values at which the specified Y level is crossed.
To find where the wave is equal to a given value, use FindValue instead.
Flags
| /B=box | Sets box size for sliding average. See the FindLevel operation. | ||||||
| /D=destWaveName | Specifies wave into which FindLevels is to store the level crossing values. If /D and /DEST are omitted, FindLevels creates a wave named W_FindLevels to store the level crossing values in. | ||||||
| /DEST=destWaveName | |||||||
| Same as /D. Both /D and /DEST create a real wave reference for the destination wave in a user function. See Automatic Creation of WAVE References for details. | |||||||
| /EDGE=e | Specifies searches for either increasing or decreasing level crossing | ||||||
| |||||||
| /M=minWidthX | Sets the minimum X distance between level crossings. This determines where FindLevels searches for the next crossing after it has found a level crossing. The search starts minWidthX X units beyond the crossing. The default value for minWidthX is 0. | ||||||
| /N=maxLevels | Sets a maximum number of crossings that FindLevels is to find. The default value for maxLevels is the number of points in the specified range of waveName. | ||||||
| /P | Computes crossings in terms of points. See the FindLevel operation. | ||||||
| /Q | Doesn't print to history and doesn't abort if no levels are found. See the FindLevel operation. | ||||||
| /R=(startX,endX ) | Specifies X range. See the FindLevel operation. | ||||||
| /R=[startP,endP ] | Specifies point range. See the FindLevel operation. | ||||||
| /T=dx | Searches for two level crossings. dx must be less than minWidthX, so you must also specify /M if you use /T. (FindLevels limits dx so that second search start isn't beyond where the first search for next edge will be.) See FindLevel for more about /T. | ||||||
Details
The algorithm for finding a level crossing is the same one used by the FindLevel operation.
If FindLevels finds maxLevels crossings or cannot find another level crossing, it stops searching.
FindLevels sets the following variables:
| V_flag |
| ||||||
| V_LevelsFound | Number of level crossings found. | ||||||
Example
Macro FindLevelsExample()
// Sample data
Make/O/N=1024 peaks;SetScale/P x,0,0.001,"" peaks // 1ms sampling
peaks=(exp(sawtooth(-(x-1)*300/pi)^3)-1)/(exp(1)-1)
SetRandomSeed 0; peaks += gnoise(0.05)
// locate rising and falling x crossings of y = 0.5
Variable minDX=20*deltax(peaks) // min 20 samples between crossings
Variable level = 0.5 // peaks y range nominally 0..1
FindLevels/Q/D=risingEdges/EDGE=1/M=(minDX) peaks, level
FindLevels/Q/D=fallingEdges/EDGE=2/M=(minDX) peaks, level
// Indicate found edges
Duplicate/O risingEdges, risingYs; risingYs = peaks(risingEdges[p])
Duplicate/O fallingEdges, fallingYs; fallingYs = peaks(fallingEdges[p])
// show level
Make/O/N=2 showLevel = level;CopyScales/I peaks, showLevel
Display /W=(35.25,41,856.5,249.5) peaks
AppendToGraph risingYs vs risingEdges
AppendToGraph fallingYs vs fallingEdges
AppendToGraph showLevel
ModifyGraph mode(risingYs)=8,mode(fallingYs)=8
ModifyGraph marker(risingYs)=17,marker(fallingYs)=23
ModifyGraph lStyle(showLevel)=1
ModifyGraph rgb(risingYs)=(19675,39321,1),rgb(fallingYs)=(0,0,0),rgb(showLevel)=(1,16019,65535)
Legend/C/N=text0/X=3.55/Y=1.90
End
See Also
FindLevel for details about the level crossing detection algorithm and the /B, /P, /Q, /R, and /T flag values.
The FindLevels operation is not multidimensional aware. See Multidimensional Waves, particularly Analysis on Multidimensional Waves for details.