📄 data.h
字号:
/*------------------------------------------------------------------------------*
* File Name: Data.h *
* Creation: CPY 7/14/2001 *
* Purpose: Origin C header file for Origin basic Data types *
* Copyright (c) OriginLab Corp. 2002 - 2007 *
* All Rights Reserved *
* Modifications:
* LAS, 1/31/03 commented out NLSFCntrl related items;
* using NLSF = LabTalk.NLSF can be used instead
*
*------------------------------------------------------------------------------*/
#ifndef _DATA_H
#define _DATA_H
#include <common.h>
#ifndef _STRING_H
#include <string.h> // Most likely will need strings
#endif // _STRING_H
#include <OC_types.h> // Structures used in Origin internal functions
#ifndef _WKSHEET_H
#include <Wksheet.h>
#endif // _WKSHEET_H
#include <vector.h>
#include <MatrixData.h>
#include <curve.h>
/////////////////////////////////////////////////////////
// The following functions are implemented in internal.c.
/////////////////////////////////////////////////////////
/** >Statistics
Get the maximum value of a data set.
Example:
// Assumes Data1_A exists and contains data
Dataset dsA("Data1_A");
double dMax = max(dsA);
printf("Maximum value of Data1_A is %g", dMax);
Parameters:
ds=Input Origin C Dataset object
Return:
Returns the maximum value of a data set.
SeeAlso:
min
*/
double max(Dataset &ds); // Get the maximum value of a data set.
/** >Statistics
Get the minimum value of a data set.
Example:
// Assumes Data1_A exists and contains data
Dataset dsA("Data1_A");
double dMin = min(dsA);
printf("Minimum value of Data1_A is %g", dMin);
Parameters:
ds=Input Origin C Dataset object
Return:
Returns the minimum value of a data set.
SeeAlso:
max
*/
double min(Dataset &ds); // Get the minimum value of a data set.
/** >Analysis
Get the value of X at the minimum Y value of a curve.
Example:
// Assumes Data1_A and Data1_B exist and contain data
Curve crv("Data1_A","Data1_B");
double dXatYmin = xatymin(crv);
printf("Value of X at minimum Y is %g", dXatYmin);
Parameters:
crv=Input Origin C Curve object
Return:
Returns the value of X at the minimum Y value of a curve.
SeeAlso:
xatymax, yatxmin, yatxmax, xaty50
*/
double xatymin(Curve &crv); // Get the value of X at the minimum Y value of a curve.
/** >Analysis
Get the value of X at the maximum Y value of a curve.
Example:
// Assumes Data1_A and Data1_B exist and contain data
Curve crv("Data1_A","Data1_B");
double dXatYmax = xatymax(crv);
printf("Value of X at maximum Y is %g", dXatYmax);
Parameters:
crv=Input Origin C Curve object
Return:
Returns the value of X at the maximum Y value of a curve.
SeeAlso:
xatymin, yatxmin, yatxmax, xaty50
*/
double xatymax(Curve &crv); // Get the value of X at the maximum Y value of a curve.
/** >Analysis
Get the value of Y at the maximum X value of a curve.
Example:
// Assumes Data1_A and Data1_B exist and contain data
Curve crv("Data1_A","Data1_B");
double dYatXmax = yatxmax(crv);
printf("Value of Y at maximum X is %g", dYatXmax);
Parameters:
crv=Input Origin C Curve object
Return:
Returns the value of Y at the maximum X value of a curve.
SeeAlso:
xatymin, yatxmin, xatymax, xaty50
*/
double yatxmax(Curve &crv); // Get the value of Y at the maximum X value of a curve.
/** >Analysis
Get the 25th percentile of a data set.
Example:
// Assumes Data1_A exists and contains data
Dataset dsA("Data1_A");
double dP25 = y25(dsA);
printf("25th Percentile of Data1_A is %g", dP25);
Parameters:
ds=Input Origin C Dataset object
Return:
Returns the 25th percentile of a data set.
SeeAlso:
y50, y75
*/
double y25(Dataset &ds); // Get the 25th percentile of a data set.
/** >Analysis
Get the 50th percentile of a data set.
Example:
// Assumes Data1_A exists and contains data
Dataset dsA("Data1_A");
double dP50 = y50(dsA);
printf("50th Percentile of Data1_A is %g", dP50);
Parameters:
ds=Input Origin C Dataset object
Return:
Returns the 50th percentile of a data set.
SeeAlso:
y25, y75
*/
double y50(Dataset &ds); // Get the 50th percentile of a data set.
/** >Analysis
Get the 75th percentile of a data set.
Example:
// Assumes Data1_A exists and contains data
Dataset dsA("Data1_A");
double dP75 = y75(dsA);
printf("75th Percentile of Data1_A is %g", dP75);
Parameters:
ds=Input Origin C Dataset object
Return:
Returns the 75th percentile of a data set.
SeeAlso:
y25, y50
*/
double y75(Dataset &ds); // Get the 75th percentile of a data set.
/** >Analysis
Get the value of X at the 50th percentile Y value of a curve.
Example:
// Assumes Data1_A and Data1_B exist and contain data
Curve crv("Data1_A","Data1_B");
double dXatY50 = xaty50(crv);
printf("Value of X at 50th Percentile of Y is %g", dXatY50);
Parameters:
crv=Input Origin C Curve object
Return:
Returns the value of X at the 50th percentile Y value of a curve.
SeeAlso:
xatymin, xatymax, yatxmin, yatxmax
*/
double xaty50(Curve &crv); // Get the value of X at the 50th percentile Y value of a curve.
/** >Analysis
Get the peak width of a curve at half the maximum Y value.
Example:
// Assumes Data1_A and Data1_B exist and contain data
Curve crv("Data1_A","Data1_B");
double dWx = fwhm(crv);
printf("Peak width at half maximum Y is %g", dWx);
Parameters:
crv=Input Origin C Curve object
dYoffset=Y offset subtracted from curve
Return:
Returns the peak width of a curve at half the maximum Y value.
SeeAlso:
area
*/
double fwhm(Curve &crv, double dYoffset = 0); // Get the peak width of a curve at half the maximum Y value.
/** >Analysis
Get the area under a curve.
Example:
// Assumes Data1_A and Data1_B exist and contain data
Curve crv("Data1_A","Data1_B");
double dA = area(crv);
printf("Area under curve is %g",dA);
Parameters:
crv=Input Origin C Curve object
dYoffset=Y offset subtracted from curve
Return:
Returns the area under a curve.
SeeAlso:
fwhm
*/
double area(Curve &crv, double dYoffset = 0); // Get the area under a curve.
/** >Analysis
Sort a curve in ascending order of X.
Example:
// Assumes Data1_A and Data1_B exist and contain data
Curve crv("Data1_A","Data1_B");
BOOL bErr = sort(crv);
Parameters:
crv=Input Origin C Curve object
Return:
Returns TRUE on success and FALSE on failure.
SeeAlso:
vectorbase::Sort
*/
BOOL sort(Curve &crv); // Sort a curve in ascending order of X.
/** >Analysis
Smooth a curve using Adjacent Averaging, FFT, or Savitzky-Golay.
Example:
// Assumes Data1_A and Data1_B exist and contain data
Curve crv("Data1_A","Data1_B");
BOOL bErr = smooth(crv);
Parameters:
crv=Input Origin C Curve object
imethod=Input method: Adjacent Averaging (default 0), FFT (1), or Savitzky-Golay (2)
ileftpts=Input left points (default is 3)
irightpts=Input right points (default is 3, Savitzky-Golay only)
ipolydeg=Input degree of polynomial (default is 2, Savitzky-Golay only)
Return:
Returns TRUE on success and FALSE on failure.
*/
BOOL smooth(Curve &crv, int imethod=0, int ileftpts = 3, int irightpts = 3, int ipolydeg = 2); // Smooth a curve using Adjacent Averaging, FFT, or Savitzky-Golay.
/** >Analysis
Fit a polynomial equation to a curve or curve segment and return the parameter coefficients. If specified,
only the Nth segment of M equal curve segments is fit.
Example:
// Assumes Data1_A and Data1_B exist and contain data
Curve crv("Data1_A","Data1_B");
double coeff[3];
fitpoly(crv, 2, &coeff, 1, 3); // Fit 2nd degree polynomial to first of 3 equal curve segments
Parameters:
crv=Input curve to fit
ipolyorder=Input degree of polynomial equation
coeff=Output array containing parameter coefficients
inumer=Input Nth segment of M equal curve segments (default 0 fits entire range as one segment)
idenom=Input number M of equal curve segments (default 0 fits entire range as one segment)
Return:
Returns TRUE on success and FALSE on failure.
SeeAlso:
fitpoly_range, initNLSF, fitNLSF
*/
BOOL fitpoly(Curve &crv, int ipolyorder, double *coeff, int inumer = 0, int idenom = 0); // Fit a polynomial equation to a curve or curve segment.
/** >Analysis
Initialize the Origin C NLSF control structure.
Sample Data:
2 10.54362
4 8.85013
6 7.51005
8 6.23363
10 5.31886
12 5.04538
14 5.47292
16 5.6315
18 5.09736
20 4.94923
22 5.10317
24 5.02472
Example:
// Assumes Sample Data are in Data1_A and Data1_B
NLSFCntrl control; // Declare NLSF control
initNLSF(control); // Initialize NLSF control
lstrcpy(control.szYdataName, "Data1_B"); // Set Y data to fit
lstrcpy(control.szFuncName, "ExpDec1"); // Set fit function
fitNLSF(control); // Use NLSF control to fit data
LT_execute("layer -a"); // Rescale graph to show all points
Parameters:
control=Input NLSF control structure (see system header file OC_types.h for elements and initial values)
Return:
Returns TRUE on success and FALSE on failure.
SeeAlso:
fitNLSF, fitpoly, fitpoly_range
*/
//BOOL initNLSF(NLSFCntrl &control); // Initialize the Origin C NLSF control structure.
/** >Analysis
Use the Origin C NLSF control structure to fit a data set.
Sample Data:
2 10.54362
4 8.85013
6 7.51005
8 6.23363
10 5.31886
12 5.04538
14 5.47292
16 5.6315
18 5.09736
20 4.94923
22 5.10317
24 5.02472
Example:
// Assumes Sample Data are in Data1_A and Data1_B
NLSFCntrl control; // Declare NLSF control
initNLSF(control); // Initialize NLSF control
lstrcpy(control.szYdataName, "Data1_B"); // Set Y data to fit
lstrcpy(control.szFuncName, "ExpDec1"); // Set fit function
fitNLSF(control); // Use NLSF control to fit data
LT_execute("layer -a"); // Rescale graph to show all points
Parameters:
control=Input NLSF control structure (see system header file OC_types.h for elements and initial values)
Return:
Returns TRUE on success and FALSE on failure.
SeeAlso:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -