This tutorial demonstrates using labtalk for peak analysis.
- Import the data file Waterfall.dat under <Origin EXE folder>\Samples\Graphing folder with the associated import filter into the workbook Waterfall.
// Create a newbook and name it Waterfall (both long and short name)
newbook name:="Waterfall" option:=lsname;
// Define the file name and filter name
string fname$ = system.path.program$ + "Samples\Graphing\Waterfall.dat";
string filtername$ = "waterfall.oif";
// Use the impfile x-function to import the specified file with the import filter
impfile fname:=fname$ filtername:=filtername$ location:=data orng:=[Waterfall]1!;
- Use a loop and the subtract_line X-Function to subtract a simple baseline of end points connection.
//Create new sheet named as SubtractedData
newsheet name:=SubtractedData;
//Define the newly created worksheet(current active) as a range variable
range sdwk = !;
//Active the "Waterfall" worksheet by its name
page.active$ = "Waterfall";
//Define an integer to hold the number of columns in Waterfall sheet
int nc = wks.nCols;
//Find out the columns for excitation wavelength = 600, 610, 620, 630 ect
//Use the loop and subtract_line x-function to subtract baseline
//The first and last data points are found and connected linearly
//This line will be subtracted as baseline from source data
//Subtracted data will be named by excitation wavelength of source data
int nexc;
loop(ii, 2, nc)
{
range ry = [Waterfall]Waterfall!col($(ii));
int nWave = %(ry[D1]$);
if (mod(nWave, 10)==0)
{
nexc = nexc + 1;
range rx = [Waterfall]Waterfall!col(1);
range rr = [Waterfall]SubtractedData!(1,$(nexc));
subtract_line iy:=ry
x1:=rx[1] /* Specifies the X value of the first point*/
y1:=ry[1] /* Specifies the Y value of the first point*/
x2:=rx[$(wks.maxRows)] /* Specifies the X value of the last point*/
y2:=ry[$(wks.maxRows)] /* Specifies the Y value of the last point*/
oy:=rr;
//Rename the column long names in SubtractedData sheet
//Use the User Defined Parameter Wavelength in Waterfall sheet
rr[L]$ = ry[D1]$;
//add a new column for next loop
wks.addcol();
}
else
{
continue;
}
}
-
Create new sheet for summary report
// Create new sheet for summary report and define ranges
newsheet cols:=7 xy:="XYYYYYY" name:="Summary";
range rWaveLength = 1, rCntrInd = 2, rLtInd =3, rRtInd = 4;
range rArea = 5, rCntr = 6, rHt = 7, rFWHM = 8;
rWaveLength[L]$ = "WaveLength";
rCntrInd[L]$ = "Peak Center Index";
rLtInd[L]$ = "Peak Left Index";
rRtInd[L]$ = "Peak Right Index";
rArea[L]$ = "Peak Area";
rCntr[L]$ = "Peak Center";
rHt[L]$ = "Peak Height";
rFWHM[L]$ = "FWHM";
-
To calculate the quantities of the highest peak of the data, we should find the highest peak with the pkfind X-Function and then calculate the quantities of the peak with the integ1 X-Function
//active the SubtractedData sheet
page.active$="SubtractedData";
//add columns for temp results of the finded peaks
loop(cc, 1, 2)
{
wks.addcol();
};
loop(ii, 2, nexc)
{
//find the highest peak
range rData = col($(ii));
range pcenter= $(nexc+1), pleft= $(nexc+2), pright= $(nexc+3);
pkfind rData filter:=num value:= 1 ocenter:=pcenter oleft:=pleft oright:=pright; //find a highest peak
//copy the result from the temp columns to summary sheet
wrcopy iw:=SubtractedData ow:=Summary c1:=nexc+1 c2:=nexc+3 r1:=1 r2:=1 dc1:=2 dr1:= ii-1;
//compute the quantities of the highest peak with integ1
int n1 = pleft[1]; //specify the peak left index
int n2 = pright[1]; //specify the peak right index
range rint = rData[$(n1):$(n2)]; // range of data to be integrated
double aa, cc, hh, fw;
integ1 iy:=rint area:=aa x0:=cc y0:=hh dx:=fw oy:=<optional>;
//put the quantities to summary sheet
rArea[$(ii-1)] = aa;
rCntr[$(ii-1)] = cc;
rHt[$(ii-1)] = hh;
rFWHM[$(ii-1)] =fw;
//copy the longname of calculated data to summary sheet
rWaveLength[$(ii-1)] = %(rData[L]$);
}
-
Create a graph of the quantities as a function of excitation wavelength with the plotxy X-Function
//create a graph of the quantities as a function of excitation wavelength
plotxy iy:=(rWaveLength, rArea) plot:=202 ogl:=[<new>];
plotxy iy:=(rWaveLength, rHt) plot:=202 ogl:=[<new>];
plotxy iy:=(rWaveLength, rFWHM) plot:=202 ogl:=[<new>];