simHelpers

General-purpose simulation helpers.

These utilities are used by modules such as simIncludeGravBody and vizSupport. They are kept here so that importing those user-facing modules does not pull in the test-only pytest dependency that unitTestSupport transitively would introduce.

simHelpers.EigenVector3d2list(eig)[source]

convert Eigen vector3d to list

simHelpers.EigenVector3d2np(eig)[source]

convert Eigen vector3d to numpy

simHelpers.addTimeColumn(time, data)[source]

Add a time column to the data set

simHelpers.checkMethodKeyword(karglist, kwargs)[source]

Check that keyword arguments are in the allowed keyword list.

simHelpers.columnToRowList(set)[source]

Loop through a column list and return a row list.

simHelpers.decimalYearToDateTime(start)[source]

Convert a decimal year to a datetime.datetime object.

simHelpers.flattenList(matrix)[source]

Return a flattened list.

Parameters:

matrix – List of lists.

Returns:

Flattened list.

simHelpers.getLineColor(idx, maxNum)[source]

Pick a color from a scenario plotting color map.

simHelpers.getScenarioFigureFileName(figureName, path, extension='.svg')[source]

Return the documentation image path for a scenario figure.

simHelpers.np2EigenMatrix3d(mat)[source]

Convert a 3D NumPy matrix to an Eigen matrix.

simHelpers.np2EigenVectorXd(vec)[source]

Convert a NumPy vector to an Eigen vector.

simHelpers.npList2EigenXdVector(list)[source]

Convert a list of arrays to a list of Eigen values.

simHelpers.pullVectorSetFromData(inpMat)[source]

Extract vector data from a matrix whose first column is time data.

simHelpers.removeTimeFromData(dataList)[source]

Remove the time column from a data list.

simHelpers.samplingTime(simTime, baseTimeStep, numDataPoints)[source]

Return a sample time that approximates a target number of samples.

Parameters:
  • simTime – [ns] Total simulation duration.

  • baseTimeStep – [ns] Baseline sampling period.

  • numDataPoints – Nominal desired number of data points over the simulation duration.

Returns:

[ns] Sampling period.

simHelpers.saveFigurePDF(figureName, plt, path)[source]

Save a figure as a PDF.

simHelpers.saveScenarioFigure(figureName, plt, path, extension='.svg')[source]

Save a Python scenario result into the documentation image folder.

simHelpers.saveScenarioGraphvizFigure(figureName, simulationBase, path, extension='.svg', show_plots=False, **kwargs)[source]

Save a Graphviz message flow figure into the documentation image folder.

simHelpers.timeStringToGregorianUTCMsg(DateSpice, **kwargs)[source]

convert a general time/date string to a gregoarian UTC msg object

simHelpers.writeFigureLaTeX(figureName, caption, plt, format, path)[source]

Save a figure and associated TeX code snippet.

simHelpers.writeTableLaTeX(tableName, tableHeaders, caption, array, path)[source]

Take a list and return equivalent LaTeX table code.

simHelpers.writeTeXSnippet(snippetName, texSnippet, path)[source]

Write a LaTeX snippet to a file.