3.7.5.5 CurveCurve-obj
LabTalk Object Type:
- External Object
The curve object provides for the following math operations on a data plot:
- Smoothing
- Integration
- Derivation
It also provides for baseline operations and peak selection.
See the common properties and methods of external objects.
Properties:
Common Curve Object Properties
Property
|
Access
|
Description
|
curve.baselinePts
|
Read/write numeric
|
Number of points used in baseline creation.
|
curve.data$
|
Read/write string
|
Name of the Y column in the worksheet to perform the operations on. This property must be set before performing an operation.
|
curve.derivDeg
|
Read/write numeric
|
Degree of differentiation: 0, 1, or 2.
|
curve.i1
|
Read/write numeric
|
Starting row index number of the selected range.
|
curve.i2
|
Read/write numeric
|
Ending row index number of the selected range. When i1 > 0, i2 must be specified.
|
curve.plotName$
|
Read/write string
|
The name of the graph containing the data to be acted on by the curve object. This property does not require setting.
|
curve.show
|
Read/write numeric
|
Display the integration area: 0 = do not show, 1 = show.
|
curve.smoothPts
|
Read/write numeric
|
Total number of points to be smoothed including point (must be odd and >= 3).
|
curve.x0
|
Read only numeric
|
Value of X at i1.
|
curve.x1
|
Read only numeric
|
Value of X at i2.
|
curve.y0
|
Read only numeric
|
Value of Y at i1.
|
curve.y1
|
Read only numeric
|
Value of Y at i2.
|
curve.ymax
|
Read only numeric
|
Maximum value of the active dataset with respect to the baseline.
|
curve.ymax0
|
Read only numeric
|
Maximum value of the active dataset with respect to zero.
|
curve.ymax0i
|
Read only numeric
|
Row index number for ymax0.
|
curve.ymax0x
|
Read only numeric
|
Value of X corresponding to ymax0.
|
curve.ymaxi
|
Read only numeric
|
Row index number for ymax
|
curve.ymaxx
|
Read only numeric
|
Value of X corresponding to ymax.
|
curve.ymin
|
Read only numeric
|
Minimum value of the active dataset with respect to the baseline.
|
curve.ymini
|
Read only numeric
|
Row index number for ymin.
|
curve.yminx
|
Read only numeric
|
Value of X corresponding to ymin.
|
Curve Object Properties Specific to Math Operations
Property
|
Access
|
Description
|
curve.base$
|
Read/write string
|
Name of the worksheet column that is used as a baseline. For integration, you must set this property. Set it to an existing dataset (curve.base$ = wks_colName;) or specify the following: (curve.base$ = "";). When curve.base$ is set to "", then the curve.integrate() method integrates from y = 0.
|
curve.integrate.area
|
Read/write numeric
|
Integral.
|
curve.polyDeg
|
Read/write numeric
|
The degree of the underlying polynomial used for smoothing. Values can range from 1 to 9.
|
curve.res
|
Read only numeric
|
Tolerance for deviation in X axis values. This value is fixed at 5%.
|
curve.result$
|
Read/write string
|
Name of the (existing) dataset that stores the results. This property must be set before performing the math operation.
|
curve.smoothLeftPts
|
Read/write numeric
|
The number of points on the right of the data point being smoothed when using curve.sgsmooth(). This property combined with curve.smoothRightPts make up the smoothing window and can not exceed 100 points. The window can be asymmetric about a particular data point - i.e., the number of points to the left of the point of interest can be different from the number to the right.
|
curve.smoothRightPts
|
Read/write numeric
|
The number of points on the right of the data point being smoothed when using curve.sgsmooth(). This property combined with curve.smoothLeftPts make up the smoothing window and can not exceed 100 points. The window can be asymmetric about a particular data point - i.e., the number of points to the left of the point of interest can be different from the number to the right.
|
curve.x$
|
Read/write string
|
Name of the X column to use for the math operation.
|
Curve Object Properties Specific to Baseline Operations and Peak Selection
Property
|
Access
|
Description
|
curve.areas$
|
Read/write string
|
Worksheet column used for storing areas between base points.
|
curve.basex$
|
Read/write string
|
Worksheet column used for storing X coordinate for the base points.
|
curve.basey$
|
Read/write string
|
Worksheet column used for storing Y coordinate for the base points.
|
curve.centers$
|
Read/write string
|
Worksheet column used for storing the center points.
|
curve.halfWidths$
|
Read/write string
|
Worksheet column used for storing the half-widths.
|
curve.heights$
|
Read/write string
|
Worksheet column used for storing the heights.
|
curve.integrate.area
|
Read only numeric
|
Area under a single peak.
|
curve.integrate.center
|
Read only numeric
|
Center point of a single peak.
|
curve.integrate.halfwidth
|
Read only numeric
|
Half-width for a single peak.
|
curve.integrate.height
|
Read only numeric
|
Height of a single peak.
|
curve.markerIndex$
|
Read only string
|
Worksheet column used for storing the selected baseline points.
|
curve.maxPeakRange
(You must also set curve.minPeakRange and curve.minHeight.
|
Read/write numeric
|
The value of this property is used for peak picking only if curve.pickPeaks.simple = 0.
Set this property to be the percentage of the total number of points in curve.data$ that the peak must not exceed in order to be recognized as a peak.
|
curve.minDer
|
Read/write numeric
|
Minimum value of the first derivative below which a point is accepted.
|
curve.minHeight
(You must also set curve.minPeakRange and curve.maxPeakRange.)
|
Read/write numeric
|
The value of this property is used for peak picking only if curve.pickPeaks.simple = 0.
Set this property to be the percentage of the total amplitude (difference between min and max values) of curve.data$ that a peak must have, to be considered a peak. This property enables you to exclude noise when determining peaks.
|
curve.minPeakRange
(You must also set curve.maxPeakRange and curve.minHeight.)
|
Read/write numeric
|
The value of this property is used for peak picking only if curve.pickPeaks.simple = 0.
Set this property to be the percentage of the total number of points in curve.data$ that the peak must have in order to be recognized as a peak.
|
curve.peakDirection$
|
Read/write string
|
Holds the name of the dataset that will have either a P (for positive) or an N (for negative) in the Peaks worksheet. The indexes of the peaks will be loaded in curve.peakIndex$.
|
curve.peakIndex$
|
Read/write string
|
Worksheet column used for storing the index for the peak points.
|
curve.pickPeaks.minHeight
(You must also set curve.pickPeaks.rectHeight and curve.pickPeaks.rectWidth.)
|
Read/write numeric
|
The value of this property is used for peak picking only if curve.pickPeaks.simple = 1.
Set this property to be the percentage of the total amplitude (difference between min and max values) of curve.data$ that a peak must have, to be considered a peak. This property enables you to exclude noise when determining peaks.
|
curve.pickPeaks.rectHeight
(You must also set curve.pickPeaks.minHeight and curve.pickPeaks.rectWidth.)
|
Read/write numeric
|
The value of this property is used for peak picking only if curve.pickPeaks.simple = 1. When curve.pickPeaks.simple = 1, the curve.pickPeaks() method uses a search rectangle for peak picking. Curve.pickPeaks.rectHeight determines the height of the search rectangle. Set this property to be the percentage of the difference between the maximum and minimum values in curve.data$.
|
curve.pickPeaks.rectWidth
(You must also set curve.pickPeaks.rectHeight and curve.pickPeaks.minHeight.)
|
Read/write numeric
|
The value of this property is used for peak picking only if curve.pickPeaks.simple = 1. When curve.pickPeaks.simple = 1, the curve.pickPeaks() method uses a search rectangle for peak picking. Curve.pickPeaks.rectWidth determines the width of the search rectangle.
Set this property to be the percentage of the total range of values in curve.data$.
|
curve.pickPeaks.simple
|
Read/write numeric
|
Set this property to 1 if curve.data$ does not have a definable baseline. If curve.data$ has a definable baseline (even if irregular), then set curve.pickPeaks.simple = 0.
|
Methods:
Curve Object Methods Specific to Math Operations
Method
|
Description
|
curve.adjave()
|
Smoothing using the adjacent averaging method. The result is stored in curve.result$.
|
curve.deriv()
|
Differentiate. The result is stored in curve.result$.
|
curve.FFTSmooth()
|
Smoothing using the Fourier transform method. The result is stored in curve.result$.
|
curve.integrate()
|
Integrate. The result is stored in curve.result$.
|
curve.SGDeriv()
|
Differentiate using the Savitzky-Golay method. The result is stored in curve.result$.
|
curve.SGSmooth()
|
Smoothing using the Savitzky-Golay method. The result is stored in curve.result$.
|
Curve Object Methods Specific to Baseline Operations and Peak Selection
Method
|
Description
|
curve.baseline()
|
Find all points that make a baseline.
|
curve.mrkIntegrate()
|
Get the first baseline points on either side of the peak.
|
curve.pickPeaks()
|
Get all the peak points. The search method depends on property settings. See curve.pickPeaks.simple, curve.maxPeakRange, curve.minHeight, curve.minPeakRange, curve.pickPeaks.minHeight, curve.pickPeaks.rectHeight, curve.pickPeaks.rectWidth.
|
Examples:
Differentiation Using Savitzky-Golay Method
This script performs a differentiation using the Savitzky-Golay method:
//Create a new book and import the data
newbook;
string fpath$ = "Samples\Signal Processing\fftfilter1.dat";
string fname$ = system.path.program$ + fpath$;
impasc;
wks.addcol();
col(c)[L]$=Results;
//Assign datasets
curve.data$=%H_B;
curve.result$=%H_C;
curve.i1 = -1;
curve.smoothpts = 5;
curve.derivdeg = 1;
//Perform differentiation,
//fill Result column of original worksheet
curve.sgderiv();
Peak Integration from a Baseline
This script performs an integration from a baseline:
//Open a new worksheet
newbook;
//Import sample file;
string fpath$ = "Samples\Spectroscopy\Peaks with Base.DAT";
string fname$ = system.path.program$ + fpath$;
impasc;
//Create a column for results
wks.addcol();
col(D)[L]$=Results;
curve.data$ = %H_B;
curve.base$ = %H_C;
curve.result$ = %H_D;
//Perform integration,
//fill results column of original worksheet
curve.integrate();
//Send the total area to the script window
type "Area = $(curve.integrate.area)";
Example 3
This script finds peaks in the active data plot and adds the peak XY values and row index numbers to the original worksheet:
curve.reset(); //initialize
%W = %[%C,'_']; //get name of wks for active data in layer
%W!page.xlcolname = 0; //turn off Spreadsheet Cell Notation firstly;
%W!wks.addcol(Pkindex); //add column to store index value
%W!wks.addcol(Pkx); //add column to store x value
%W!wks.col$(%W!wks.ncols).type = 4; //set as X column
%W!wks.addcol(Pky); //add column to store y value
curve.data$ = %C; //dataset to find peak values
curve.peakIndex$ = %W_PkIndex;
curve.pickPeaks.rectHeight = .05;
curve.pickPeaks.rectWidth = .05;
curve.pickPeaks.minHeight = .05;
curve.pickPeaks(1); //pick peaks without a definable baseline
get %W_PkIndex -e end;
for (ii = 1; ii <= end; ii += 1)
{
%B = curve.data$; // %B is current active dataset
index = %W_pkindex[ii]; // get peak index
%W_Pkx[ii] = xvalue(index,%B); // Set corresponding x value
%W_Pky[ii] = %B[index]; // Set corresponding y value
}
Example 4
This example use curve.smoothLeftPts and curve.smoothRightPts to set the smoothing points.
//Create a new book and import the data
newbook;
string fpath$ = "Samples\Signal Processing\fftfilter1.dat";
string fname$ = system.path.program$ + fpath$;
impasc;
wks.addcol();
wks.addcol();
//smoothing points = 10
col(c)[c]$=10-point;
curve.data$=%h_B;
curve.result$=%h_c;
curve.smoothleftpts=2;
curve.smoothrightpts=3;
curve.smoothpts=curve.smoothleftpts + curve.smoothrightpts + 1;
curve.polyDeg = 2;
curve.derivdeg = 1;
curve.sgderiv();
|