Access to interpolation functions
In This Topic
Access to interpolation functions
For characteristic lines, it is possible to access the interpolation functions of the component from EbsScript, i.e. to determine the value of the characteristic line at one point. Additionally, the type and the attributes for the interpolation can be queried.
For characteristics, there is an EbsScript type „ebscharline” with the following properties:
- getSize: integer; read and write; number of points of characteristic
- size : like getSize
- param : real; read and write; curve parameter of characteristic
- x : array of real; read and write by [{index}]; x-values of characteristic (1-based)
- y : array of real; read and write by [{index}]; y-values of characteristic (1-based)
- interpolate : method, return type real, call by interpolate({x:real}); interpolates at the point x
- interpolationtype : interpolationtypeenum; read and write; method of interpolation (see dialog for characteristic)
- interpolationorder : integer; read and write; order of interpolation (see dialog for characteristic)
- extrapolationorder : integer; read and write; order of extrapolation (see dialog for characteristic)
- splineborderstype : splineborderstypeenum; read and write; method of spline-interpolation (see dialog for characteristic)
- splineborderleft : real; read and write; left spline value (see dialog for characteristic)
- splineborderright : real; read and write; right spline value (see dialog for characteristic)
- id : String; read only; Id of characteristic
- description : String; read only; description of characteristic
Example:
begin
println ("Motor.CQ3NCV.interpolate(5000):",Motor.CQ3NCV.interpolate(5000));
println ("Motor.CQ3NCV.interpolationtype:",Motor.CQ3NCV.interpolationtype);
println ("Motor.CQ3NCV.interpolationorder:",Motor.CQ3NCV.interpolationorder);
println ("Motor.CQ3NCV.extrapolationorder:",Motor.CQ3NCV.extrapolationorder);
println ("Motor.CQ3NCV.splineborderstype:",Motor.CQ3NCV.splineborderstype);
println ("Motor.CQ3NCV.splineborderleft:",Motor.CQ3NCV.splineborderleft);
println ("Motor.CQ3NCV.splineborderright:",Motor.CQ3NCV.splineborderright);
end;
The function "interpolate” yields the y-value of the characteristic line for the x-value given as argument. The interpolationtype is
In the case of interpolationtype=1, interpolationorder and extrapolationorder contain the respective orders for interpolation and extrapolation.
In the case of interpolationtype=2, splineborderstype specifies how the boundary conditions for the spline interpolation are to be set:
For splineborderstype=1 or 2, splineborderleft and splineborderright contain the appropriate limit values.
It is also possible to change these attributes in the EbsScript.
The function "interpolate"; can also be used for characteristic fields (matrices).
For matrices, there is an EbsScript type „ ebsmatrix” with the following properties:
- sizeX : integer; read and write; number of elements in x-direction / number of rows in matrix dialog
- sizeY : integer; read and write; number of elements in y- direction / number of columns in matrix dialog
- data : method, return type real, call by data({index_x,index_y:integer}); data in cell (index_x,index_y) (1-based)
return type depends on defined data type: real, string, VARIANT, whole number (Integral)
- interpolate : method, return type real, call by interpolate({x,y:real}); interpolates at (x,y)
- interpolation2dtype : interpolation2dtypeenum; read and write; method of interpolation (see matrix dialog)
- id : String; read only; Id of matrix
- description : String; read only; description of matrix
- extrapolation2dtype : etrapolation2dtypeenum; read and write; method of extrapolation (see matrix dialog)
- extrapolation2dspecifiedvalue : real; read and write; value for extrapolation (see matrix dialog)
- hasheaderX : boolean; read only; header for x-values (in row 1)
- hasheaderY : boolean; read only; header for y-values (in column 1)
- headersizeX : integer; read and write; number of elements in x-direction (WITHOUT (optional) y-header row)
- headersizeY : integer; read and write; number of elements in y- direction (WITHOUT (optional) x-header column)
- headerX : method, call by data({index}); Header-x-values (1-based) (only valid if hasheaderX == True)
return type depends on defined data type: real, string, VARIANT, whole number (Integral)
- headerY : method, call by data({index}); Header-y-values (1-based) (only valid if hasheaderY == True)
return type depends on defined data type: real, string, VARIANT, whole number (Integral)
- headerData : method, call by data({index_x,index_y:integer}); data in cell (index_x,index_y) (1-based) (WITHOUT (optional) x-header column and y-header row)
return type depends on defined data type: real, string, VARIANT, whole number (Integral)
Example:
begin
println ("Motor.MXT2.interpolate(10,6000):",Motor.MXT2.interpolate(10,6000));
println ("Motor.MXT2.sizex:",Motor.MXT2.sizex);
println ("Motor.MXT2.sizey:",Motor.MXT2.sizey);
println ("Motor.MXT2.data(1,3)",Motor.MXT2.data(1,3));
println ("Motor.MXT2.interpolation2dtype:",Motor.MXT2.interpolation2dtype);
end;
In this case, "interpolate" needs two arguments (x- und y-value) and yields the value of the characteristic field at the respective position. With the first argument (x) an interpolation of the lines is carried out, with the second (y) an interpolation of the columns.
The function sizex yields the number of the lines (including headline with the y-values).
The function sizey yields the number of the columns (including the left column with the x-values).
The function data (i,j) yields the value in line i and column j.
The function interpolation2dtype yields the interpolation type:
-
0 for bilinear interpolation
-
1 for bi cubic interpolation
-
2 for "nearest-neighbour" interpolation