Results Plot Functions

This group is for functions that make and edit Results plots. Plots are saved with the model and shown on the Plot tab of the Results viewer. Each plot holds curves that name the kinds of Result and the variables they plot.

AddResultsPlot()

Add a Results plot to the model.

CopyResultsPlot(plot_id)

Add a copy of a Results plot, with copies of its curves.

DeleteResultsPlot(plot_id)

Delete a Results plot and its curves.

DeleteAllResultsPlots()

Delete every Results plot.

WriteResultsPlotFile(plot_id, file_name)

Write a Results plot to a file of its own: its name, axes, style and curves, without any Results.

ReadResultsPlotFile(file_name)

Add the Results plot a file written by WriteResultsPlotFile holds.

GetAllResultsPlotIDs()

Get the IDs of every Results plot, in the order the Results viewer lists them.

SetActiveResultsPlot(plot_id)

Make a Results plot the active one, the plot the Results viewer shows.

GetActiveResultsPlot()

Get the ID of the active Results plot, the plot the Results viewer shows.

AddResultsCurve(plot_id)

Add an empty curve to a Results plot.

DeleteResultsCurve(curve_id)

Delete a curve from its Results plot.

GetResultsCurveIDs(plot_id)

Get the IDs of a Results plot's curves, in order.

SetResultsCurveSources(curve_id, names, ...)

Set the kinds of Result a curve plots.

GetResultsCurveSourceNames(curve_id)

Get the Results names of the kinds of Result a curve plots.

GetResultsCurveSourceCaseNames(curve_id)

Get the case names of the kinds of Result a curve plots, empty for a kind with no case name.

SetResultsCurveXVar(curve_id, label)

Set the variable a curve plots on the X axis, by its label from GetResultsPlotVarLabels.

GetResultsCurveXVar(curve_id)

Get the label of the variable a curve plots on the X axis.

SetResultsCurveYVars(curve_id, labels)

Set the variables a curve plots on the Y axis, by their labels from GetResultsPlotVarLabels.

GetResultsCurveYVars(curve_id)

Get the labels of the variables a curve plots on the Y axis.

GetResultsCurveResultIDs(curve_id)

Get the IDs of the Results a curve plots now: the runs its Run Parm picks of each of its kinds of Result, oldest first.

SetResultsCurveChosenIDs(curve_id, results_ids)

Choose the Results a curve plots when its Run Parm is RESULTS_RUN_CHOSEN.

GetResultsCurveChosenIDs(curve_id)

Get the IDs of the Results of a curve's kinds that it plots when its Run Parm is RESULTS_RUN_CHOSEN.

GetResultsPlotVarLabels(results_id[, ...])

Get the labels of the variables in a Result that a curve can plot.

GetResultsPlotVarData(results_id, label[, ...])

Get the values of a variable in a Result, as a curve plots them.

Details

openvsp.AddResultsPlot()[source]

Add a Results plot to the model. The plot starts with one empty curve and becomes the active plot. A plot’s axes and style are Parms in group “ResultsPlot” (XMin, XMax, YMin, YMax and their XMinManual etc. flags, XLog, YLog, ShowLines, ShowPoints and Legend, see RESULTS_PLOT_LEGEND), and its name is set with SetContainerName.

plot_id = AddResultsPlot()

assert len( GetAllResultsPlotIDs() ) == 1, "AddResultsPlot"
assert len( GetResultsCurveIDs( plot_id ) ) == 1, "AddResultsPlot did not add a curve"
assert GetActiveResultsPlot() == plot_id, "AddResultsPlot did not make the plot active"

# The axes are Parms.
SetParmVal( FindParm( plot_id, "YLog", "ResultsPlot" ), 1.0 )
SetParmVal( FindParm( plot_id, "Legend", "ResultsPlot" ), RESULTS_LEGEND_UPPER_LEFT )

SetContainerName( plot_id, "Lift Curve" )

See also: CopyResultsPlot, DeleteResultsPlot, AddResultsCurve, SetContainerName :rtype: string :return: string ID of the new plot

openvsp.CopyResultsPlot(plot_id)[source]

Add a copy of a Results plot, with copies of its curves. The copy becomes the active plot.

plot_id = AddResultsPlot()
SetParmVal( FindParm( plot_id, "XLog", "ResultsPlot" ), 1.0 )

copy_id = CopyResultsPlot( plot_id )

assert copy_id != plot_id and len( GetAllResultsPlotIDs() ) == 2, "CopyResultsPlot"
assert GetParmVal( FindParm( copy_id, "XLog", "ResultsPlot" ) ) == 1.0, "CopyResultsPlot lost a Parm"
assert len( GetResultsCurveIDs( copy_id ) ) == 1, "CopyResultsPlot lost the curve"

See also: AddResultsPlot :param [in]: plot_id string Results plot ID :rtype: string :return: string ID of the copy

openvsp.DeleteResultsPlot(plot_id)[source]

Delete a Results plot and its curves.

plot_id = AddResultsPlot()

DeleteResultsPlot( plot_id )

assert len( GetAllResultsPlotIDs() ) == 0, "DeleteResultsPlot"
assert GetActiveResultsPlot() == "", "DeleteResultsPlot left it active"

See also: AddResultsPlot, DeleteAllResultsPlots :param [in]: plot_id string Results plot ID

openvsp.DeleteAllResultsPlots()[source]

Delete every Results plot.

AddResultsPlot()
AddResultsPlot()

DeleteAllResultsPlots()

assert len( GetAllResultsPlotIDs() ) == 0, "DeleteAllResultsPlots"

See also: DeleteResultsPlot

openvsp.WriteResultsPlotFile(plot_id, file_name)[source]

Write a Results plot to a file of its own: its name, axes, style and curves, without any Results. The curves name kinds of Result and variables, not particular Results, so ReadResultsPlotFile can bring the plot into another model, where it plots that model’s Results of the same kinds.

plot_id = AddResultsPlot()
SetContainerName( plot_id, "Drag Polar" )
SetParmVal( FindParm( plot_id, "YLog", "ResultsPlot" ), 1.0 )

WriteResultsPlotFile( plot_id, "DragPolar.vspplot" )

See also: ReadResultsPlotFile :param [in]: plot_id string Results plot ID :param [in]: file_name string File name, by convention ending in .vspplot

openvsp.ReadResultsPlotFile(file_name)[source]

Add the Results plot a file written by WriteResultsPlotFile holds. The plot goes after the others and becomes the active plot; a name already taken gets a number added. Its curves plot the Results of the kinds they name that the model has, and stay empty until it has some.

plot_id = AddResultsPlot()
SetContainerName( plot_id, "Drag Polar" )
SetParmVal( FindParm( plot_id, "YLog", "ResultsPlot" ), 1.0 )
WriteResultsPlotFile( plot_id, "DragPolar.vspplot" )

VSPRenew()

read_id = ReadResultsPlotFile( "DragPolar.vspplot" )

assert GetActiveResultsPlot() == read_id, "ReadResultsPlotFile"
assert GetContainerName( read_id ) == "Drag Polar", "ReadResultsPlotFile lost the name"
assert GetParmVal( FindParm( read_id, "YLog", "ResultsPlot" ) ) == 1.0, "ReadResultsPlotFile lost a Parm"

See also: WriteResultsPlotFile :param [in]: file_name string File name :rtype: string :return: string ID of the new plot

openvsp.GetAllResultsPlotIDs()[source]

Get the IDs of every Results plot, in the order the Results viewer lists them.

first_id = AddResultsPlot()
second_id = AddResultsPlot()

plot_ids = GetAllResultsPlotIDs()

assert list( plot_ids ) == [ first_id, second_id ], "GetAllResultsPlotIDs"

See also: AddResultsPlot :rtype: std::vector< std::string,std::allocator< std::string > > :return: vector<string> Results plot IDs

openvsp.SetActiveResultsPlot(plot_id)[source]

Make a Results plot the active one, the plot the Results viewer shows.

first_id = AddResultsPlot()
second_id = AddResultsPlot()

SetActiveResultsPlot( first_id )

assert GetActiveResultsPlot() == first_id, "SetActiveResultsPlot"

See also: GetActiveResultsPlot :param [in]: plot_id string Results plot ID

openvsp.GetActiveResultsPlot()[source]

Get the ID of the active Results plot, the plot the Results viewer shows.

assert GetActiveResultsPlot() == "", "GetActiveResultsPlot with no plots"

plot_id = AddResultsPlot()

assert GetActiveResultsPlot() == plot_id, "GetActiveResultsPlot"

See also: SetActiveResultsPlot :rtype: string :return: string Active Results plot ID, empty when there are no plots

openvsp.AddResultsCurve(plot_id)[source]

Add an empty curve to a Results plot. A curve plots kinds of Result, named with SetResultsCurveSources, and the variables named with SetResultsCurveXVar and SetResultsCurveYVars. How it plots them is set by Parms in group “ResultsCurve”: Mode (see RESULTS_PLOT_MODE), Element (see RESULTS_PLOT_ELEMENT), MatrixRows, and Run (0 for every run of each kind of Result, 1 for the newest, 2 for the one before it, and so on).

plot_id = AddResultsPlot()

curve_id = AddResultsCurve( plot_id )

assert len( GetResultsCurveIDs( plot_id ) ) == 2, "AddResultsCurve"

# Plot the newest run only, one point per Result.
SetParmVal( FindParm( curve_id, "Run", "ResultsCurve" ), 1.0 )
SetParmVal( FindParm( curve_id, "Mode", "ResultsCurve" ), RESULTS_PLOT_ACROSS_RESULTS )

See also: DeleteResultsCurve, GetResultsCurveIDs, SetResultsCurveSources :param [in]: plot_id string Results plot ID :rtype: string :return: string ID of the new curve

openvsp.DeleteResultsCurve(curve_id)[source]

Delete a curve from its Results plot.

plot_id = AddResultsPlot()
curve_id = GetResultsCurveIDs( plot_id )[0]

DeleteResultsCurve( curve_id )

assert len( GetResultsCurveIDs( plot_id ) ) == 0, "DeleteResultsCurve"

See also: AddResultsCurve :param [in]: curve_id string Results curve ID

openvsp.GetResultsCurveIDs(plot_id)[source]

Get the IDs of a Results plot’s curves, in order.

plot_id = AddResultsPlot()
curve_id = AddResultsCurve( plot_id )

curve_ids = GetResultsCurveIDs( plot_id )

assert len( curve_ids ) == 2 and curve_ids[1] == curve_id, "GetResultsCurveIDs"

See also: AddResultsCurve :param [in]: plot_id string Results plot ID :rtype: std::vector< std::string,std::allocator< std::string > > :return: vector<string> Results curve IDs

openvsp.SetResultsCurveSources(curve_id, names, case_names)[source]

Set the kinds of Result a curve plots. A kind is a Results name, such as “Test_Results”, and a case name, which is empty for Results that carry no Case_Name. The curve plots the Results of those kinds that exist when it is drawn, so it can name kinds that have not been made yet.

plot_id = AddResultsPlot()
curve_id = GetResultsCurveIDs( plot_id )[0]

SetResultsCurveSources( curve_id, [ "Test_Results" ], [ "" ] )

assert list( GetResultsCurveSourceNames( curve_id ) ) == [ "Test_Results" ], "SetResultsCurveSources"

See also: GetResultsCurveSourceNames, GetResultsCurveSourceCaseNames, GetResultsCurveResultIDs :param [in]: curve_id string Results curve ID :param [in]: names vector<string> Results name of each kind :param [in]: case_names vector<string> Case name of each kind, empty for none; as many as names

openvsp.GetResultsCurveSourceNames(curve_id)[source]

Get the Results names of the kinds of Result a curve plots.

plot_id = AddResultsPlot()
curve_id = GetResultsCurveIDs( plot_id )[0]

SetResultsCurveSources( curve_id, [ "Test_Results", "Other_Results" ], [ "", "Case A" ] )

assert list( GetResultsCurveSourceNames( curve_id ) ) == [ "Test_Results", "Other_Results" ], "GetResultsCurveSourceNames"

See also: SetResultsCurveSources, GetResultsCurveSourceCaseNames :param [in]: curve_id string Results curve ID :rtype: std::vector< std::string,std::allocator< std::string > > :return: vector<string> Results name of each kind

openvsp.GetResultsCurveSourceCaseNames(curve_id)[source]

Get the case names of the kinds of Result a curve plots, empty for a kind with no case name.

plot_id = AddResultsPlot()
curve_id = GetResultsCurveIDs( plot_id )[0]

SetResultsCurveSources( curve_id, [ "Test_Results", "Other_Results" ], [ "", "Case A" ] )

assert list( GetResultsCurveSourceCaseNames( curve_id ) ) == [ "", "Case A" ], "GetResultsCurveSourceCaseNames"

See also: SetResultsCurveSources, GetResultsCurveSourceNames :param [in]: curve_id string Results curve ID :rtype: std::vector< std::string,std::allocator< std::string > > :return: vector<string> Case name of each kind

openvsp.SetResultsCurveXVar(curve_id, label)[source]

Set the variable a curve plots on the X axis, by its label from GetResultsPlotVarLabels. An empty label plots against the point index, or against the Results’ order when the curve plots across Results.

plot_id = AddResultsPlot()
curve_id = GetResultsCurveIDs( plot_id )[0]

SetResultsCurveXVar( curve_id, "Test_Double" )

assert GetResultsCurveXVar( curve_id ) == "Test_Double", "SetResultsCurveXVar"

See also: GetResultsCurveXVar, SetResultsCurveYVars, GetResultsPlotVarLabels :param [in]: curve_id string Results curve ID :param [in]: label string Variable label, empty for the point index or Results order

openvsp.GetResultsCurveXVar(curve_id)[source]

Get the label of the variable a curve plots on the X axis.

plot_id = AddResultsPlot()
curve_id = GetResultsCurveIDs( plot_id )[0]

assert GetResultsCurveXVar( curve_id ) == "", "GetResultsCurveXVar of a new curve"

See also: SetResultsCurveXVar :param [in]: curve_id string Results curve ID :rtype: string :return: string Variable label, empty for the point index or Results order

openvsp.SetResultsCurveYVars(curve_id, labels)[source]

Set the variables a curve plots on the Y axis, by their labels from GetResultsPlotVarLabels. Each makes its own series.

plot_id = AddResultsPlot()
curve_id = GetResultsCurveIDs( plot_id )[0]

SetResultsCurveYVars( curve_id, [ "Test_Vec3d.x", "Test_Vec3d.y" ] )

assert len( GetResultsCurveYVars( curve_id ) ) == 2, "SetResultsCurveYVars"

See also: GetResultsCurveYVars, SetResultsCurveXVar, GetResultsPlotVarLabels :param [in]: curve_id string Results curve ID :param [in]: labels vector<string> Variable labels

openvsp.GetResultsCurveYVars(curve_id)[source]

Get the labels of the variables a curve plots on the Y axis.

plot_id = AddResultsPlot()
curve_id = GetResultsCurveIDs( plot_id )[0]

SetResultsCurveYVars( curve_id, [ "Test_Double_Vec" ] )

assert list( GetResultsCurveYVars( curve_id ) ) == [ "Test_Double_Vec" ], "GetResultsCurveYVars"

See also: SetResultsCurveYVars :param [in]: curve_id string Results curve ID :rtype: std::vector< std::string,std::allocator< std::string > > :return: vector<string> Variable labels

openvsp.GetResultsCurveResultIDs(curve_id)[source]

Get the IDs of the Results a curve plots now: the runs its Run Parm picks of each of its kinds of Result, oldest first.

WriteTestResults()      # Two runs of Test_Results

plot_id = AddResultsPlot()
curve_id = GetResultsCurveIDs( plot_id )[0]

SetResultsCurveSources( curve_id, [ "Test_Results" ], [ "" ] )

# Every run.
assert len( GetResultsCurveResultIDs( curve_id ) ) == 2, "GetResultsCurveResultIDs every run"

# The newest run.
SetParmVal( FindParm( curve_id, "Run", "ResultsCurve" ), 1.0 )

ids = GetResultsCurveResultIDs( curve_id )

assert list( ids ) == [ FindLatestResultsID( "Test_Results" ) ], "GetResultsCurveResultIDs newest run"

See also: SetResultsCurveSources :param [in]: curve_id string Results curve ID :rtype: std::vector< std::string,std::allocator< std::string > > :return: vector<string> Results IDs

openvsp.SetResultsCurveChosenIDs(curve_id, results_ids)[source]

Choose the Results a curve plots when its Run Parm is RESULTS_RUN_CHOSEN. Of its kinds of Result, the curve leaves out those not chosen; Results made later are plotted until they are left out too. The choice is not saved with the model, as Results are not.

WriteTestResults()      # Two runs of Test_Results

plot_id = AddResultsPlot()
curve_id = GetResultsCurveIDs( plot_id )[0]

SetResultsCurveSources( curve_id, [ "Test_Results" ], [ "" ] )

# Plot the older run alone.
oldest = GetResultsCurveResultIDs( curve_id )[0]

SetParmVal( FindParm( curve_id, "Run", "ResultsCurve" ), RESULTS_RUN_CHOSEN )
SetResultsCurveChosenIDs( curve_id, [ oldest ] )

assert list( GetResultsCurveResultIDs( curve_id ) ) == [ oldest ], "SetResultsCurveChosenIDs"

See also: GetResultsCurveChosenIDs, GetResultsCurveResultIDs, RESULTS_PLOT_RUN :param [in]: curve_id string Results curve ID :param [in]: results_ids vector<string> IDs of the Results to plot

openvsp.GetResultsCurveChosenIDs(curve_id)[source]

Get the IDs of the Results of a curve’s kinds that it plots when its Run Parm is RESULTS_RUN_CHOSEN. Until some are left out with SetResultsCurveChosenIDs, every one is chosen.

WriteTestResults()

plot_id = AddResultsPlot()
curve_id = GetResultsCurveIDs( plot_id )[0]

SetResultsCurveSources( curve_id, [ "Test_Results" ], [ "" ] )

assert len( GetResultsCurveChosenIDs( curve_id ) ) == 2, "GetResultsCurveChosenIDs of a new curve"

SetResultsCurveChosenIDs( curve_id, [ FindLatestResultsID( "Test_Results" ) ] )

assert len( GetResultsCurveChosenIDs( curve_id ) ) == 1, "GetResultsCurveChosenIDs"

See also: SetResultsCurveChosenIDs :param [in]: curve_id string Results curve ID :rtype: std::vector< std::string,std::allocator< std::string > > :return: vector<string> IDs of the chosen Results

openvsp.GetResultsPlotVarLabels(results_id, matrix_rows=False)[source]

Get the labels of the variables in a Result that a curve can plot. A numeric vector is labeled with its data name, followed by #1, #2, … for a second or later entry of the same name. A vec3d vector gives .x, .y and .z components and its magnitude, |name|; a matrix gives its columns, name[:,j], or its rows, name[i,:].

WriteTestResults()

labels = GetResultsPlotVarLabels( FindLatestResultsID( "Test_Results" ) )

assert "Test_Double_Vec" in labels, "GetResultsPlotVarLabels vector"
assert "Test_Int#1" in labels, "GetResultsPlotVarLabels second entry"
assert "|Test_Vec3d|" in labels, "GetResultsPlotVarLabels magnitude"

# Strings are not plotted.
assert "Test_String" not in labels, "GetResultsPlotVarLabels string"

See also: GetResultsPlotVarData, SetResultsCurveXVar, SetResultsCurveYVars :param [in]: results_id string Results ID :param [in]: matrix_rows bool True to label a matrix’s rows rather than its columns :rtype: std::vector< std::string,std::allocator< std::string > > :return: vector<string> Variable labels

openvsp.GetResultsPlotVarData(results_id, label, matrix_rows=False)[source]

Get the values of a variable in a Result, as a curve plots them.

WriteTestResults()

res_id = FindLatestResultsID( "Test_Results" )

data = GetResultsPlotVarData( res_id, "Test_Double_Vec" )

# The newest run holds 0, 2, 4, 6, 8.
assert len( data ) == 5 and abs( data[4] - 8.0 ) < 1e-12, "GetResultsPlotVarData"

mag = GetResultsPlotVarData( res_id, "|Test_Vec3d|" )

# The newest run holds ( 1, 2, 4 ).
assert len( mag ) == 1 and abs( mag[0] * mag[0] - 21.0 ) < 1e-9, "GetResultsPlotVarData magnitude"

See also: GetResultsPlotVarLabels :param [in]: results_id string Results ID :param [in]: label string Variable label :param [in]: matrix_rows bool True when the label names a matrix row rather than a column :rtype: std::vector< double,std::allocator< double > > :return: vector<double> Values