Initialization, File Operation
Construction
An Result1D object can be created within the built-in basic editor as follows:
dim objName1 as object
set objName1 = Result1D(GetProjectPath("ResultsDSTask") + "AC1\Components\P1\Data\P1\aAC Voltage")
dim objName2 as object
set objName2 = Result1DFromData("AC2", "P1", "P1", "AC Voltage", "linear")
From an external progam:
dim app As Object
set app = CreateObject("CSTStudio.Application")
dim ds As Object
set ds = app.OpenFile("E:\Test\Project.cst")
dim objName1 as object
set objName1 = ds.Result1D(ds.GetProjectPath("ResultsDSTask") + "AC1\Components\P1\Data\P1\aAC Voltage")
dim objName2 as object
set objName2 = ds.Result1DFromData("AC2", "P1", "P1", "AC Voltage", "linear")
Initialize ( long n )
Initializes an empty Result1D object with the specified dimension n.
Load ( name sObjectName )
Loads a 1D result. sObjectName is the signal file name extension for the signal to be loaded.
dim app As Object
set app = CreateObject("CSTStudio.Application")
dim ds As Object
set ds = app.NewDS
dim res as object
set res = ds.Result1D("")
res.Load("E:\Test\Project\Result\DS\Tasks\AC1\Components\P1\Data\P1\aAC Voltage")
LoadPlainFile ( filename sObjectName )
Loads an external 1D result stored in the file sObjectName. If the file name sObjectName starts with a '^' the project name will automatically be added such that the corresponding signal of the current project will be loaded.
sObjectName may be a signal file of any source. It may have an arbitrary header, followed by the signal data organized in two columns.
Save ( name sObjectName )
Saves the object with the given filename. Note, that like in the LoadPlainFile method, the project name is added if the first character is a '^'. If the filename is blank the data is saved with name of the previous loaded file.
AddToTree ( name sTreePath )
Inserts the Result1D object into the tree at the folder specified by sTreePath.
Copy Result1D Object
Returns a copy of the object.
Add / Subtract ( Result1D Object oObject )
Adds / subtracts the components in oObject to/from the calling object's components. The result will be stored in the calling object. Before calling this method please make sure that the calling object and oObject contain compatible data (same number of samples, same values of the independent variable).
ScalarMult ( double dFactor )
Scales the Result1D Object with the given factor.
ComponentMult / ComponentDiv ( Result1D Object oObject )
Multiplies / divides the components in oObject with/by the calling object's components. The result will be stored in the calling object. Before calling this method please make sure that the calling object and oObject contain compatible data (same number of samples, same values of the independent variable).
ApplyTimeWindow ( double smoothness )
Applies a squared cosine windowing function to the result. Set smoothness to a value from 0 to 100 to specify when the cosine shape starts. At a value of 100, t0 equals to zero and at a value of zero, t0 equals to tmax, which means that it is identical to a rectangular window.
ApplyLowPass ( double fmax )
Filters the result using a low pass filter with the cut-off-frequency fmax.
ResampleTo ( double min, double max, long nSamples )
Resample the result to a given number of samples between a minimum and maximum value. The new data samples are calculated by a linear interpolation of the original data samples.
MakeCompatibleTo ( Result1D Object oObject )
Re-samples the result in the calling object to make it compatible to the sampling of oObject. The new data samples are calculated by a linear interpolation of the original data samples.
ScalarProd ( Result1D Object oObject ) double
Performs a scalar product between two Result1D objects. The result will be returned as a double value.
GetGlobalMaximum / GetGlobalMinimum long
Returns the index of the overall maximum / minimum of the y-values.
GetMaximumInRange / GetMinimumInRange ( double x1, double x2 ) long
Returns the index to the maximum / minimum y-value that can be found between x1 and x2.
GetMaximumInIndexRange / GetMinimumInIndexRange ( long i1, long i2 ) long
Returns the index to the maximum / minimum y-value that can be found between two x-values referenced by the indices i1 and i2.
GetFirstMaximum / GetFirstMinimum ( double yLimit ) long
GetNextMaximum / GetNextMinimum ( double yLimit ) long
Returns the index to the first / next maximum / minimum y-value. The parameter yLimit defines a minimum difference between the found local maximum/minimum y-value and the previous and next local minimum/maximum y-value. If no further maximum/minimum could be found the returned index will be –1.
GetMeanValue double
Returns the mean value of the Result1D object's y-values.
GetSigma double
Returns the deviation of the Result1D object's y-values.
GetIntegral double
Returns the integral of the Result1D object.
GetNorm double
Returns the square root mean norm of the Result1D object.
GetX / GetY ( long index ) double
SetX / SetY ( long index, double dValue )
Sets / returns the x/y-value at the specified index in the Result1D object.
SetXY ( long index, double xValue, double yValue )
Sets the x- and y-value at the specified index in the Result1D object.
SetXYDouble ( long index, double xValue, double yValue )
GetXYDouble ( long index, double_ref xValue, double_ref yValue )
Sets / returns the x- and y-value at the specified index in the Result1D object.
Note, that these methods in contrast to .SetXY do only accept double parameters and no expressions.
AppendXY ( double xValue, double yValue )
Appends a new pair of values to the end of the result object.
GetClosestIndexFromX ( double dValue ) long
Returns the index of the x-value stored in the Result1D object that is closest to the specified value.
Title / Xlabel / Ylabel ( string name )
Defines the title / x-axis label / y-axis label of the result.
GetTitle / GetXlabel / GetYlabel string
Returns the title / x-axis label / y-axis label of the result. This function works only for user added tree result objects.
Xunit / Yunit ( string unit )
Defines the abscissa's / ordinate's unit (for display).
GetXunit / GetYunit string
Returns the abscissa's / ordinate's unit.
Xscale / Yscale ( double scale )
Defines the abscissa's / ordinate's scale factor.
GetXscale / GetYscale double
Returns the abscissa's / ordinate's scale factor.
Type ( enum key )
Defines the type of the Result1D object.
enum key |
meaning |
"magnitude" |
Magnitude |
"db" |
Magnitude in dB |
"phase" |
Phase in degrees |
"real" |
Real part |
"imaginary" |
Imaginary part |
"realsig" |
Real time domain signal |
GetN long
Returns the total number of value pairs stored in the Result1D object.
NOTE: The behavior of the "Result1D" object depends on the context it is used. If you use it in CST DESIGN ENVIRONMENT, the .AddToTree command will place the curves into the result tree of CST DS. However, if for example used from within CST MICROWAVE STUDIO, the curves will be placed into the result tree of CST MWS. To have the curves placed into CST DS you need to construct the result object as "DS.Result1D("")".
This example shows how to access all values of S-Parameter phase.
With Result1DFromdata ("S-Parameters1", "Design", "S-Parameters", "S1,1", "phase") ' Connect to phase of S11
nn = .GetN ' Get number of frq-points
For ii = 0 To nn-1
vx = .GetX(ii) ' here: frequency
vy = .GetY(ii) ' here: according phase
Next ii
End With
The second example creates two Result1D objects. One from the current project and one from an external project. The difference of the last values from the two objects is output in a message box.
Dim ThisResult As Object 'object for the current project result
Dim ExtResult As Object 'object for the external project result
Set ThisResult = Result1DFromdata ("AC1", "P1", "P1", "AC Voltage", "linear")
Set ExtResult = Result1D("")
ExtResult.LoadPlainFile("E:\Projects\External Project\Result\DS\Tasks\AC1\Components\P1\Data\P1\aAC Voltage.sig")
Dim d As Double
d = ThisResult.GetY(ThisResult.GetN-1) - ExtResult.GetY(ExtResult.GetN-1)
MsgBox Str$(d)
The last example calculates the real part of S11 at a certain frequency (here 0.65 GHz).
Dim a11 As Object
Dim p11 As Object
Set a11 = Result1DFromdata ("S-Parameters1", "Design", "S-Parameters", "S1,1", "linear")
Set p11 = Result1DFromdata ("S-Parameters1", "Design", "S-Parameters", "S1,1", "phase")
Dim n As Integer
Dim frq As Double
frq=0.65
n=a11.GetClosestIndexFromX(frq)
phase = Pi/180.0 * p11.GetY(n)
ampli = a11.GetY(n)
real = ampli * cos(phase)