File MIES_SweepFormula.ipf

SF Sweep formula allows to do analysis on sweeps with a dedicated formula language

Functions

variable SF_BringBrowserToFront()
wave SF_GetNamedOperations()
wave SF_GetFormulaKeywords()
string SF_EscapeJsonPath(string str)

add escape characters to a path element

variable SF_FormulaWaveScaleTransfer(wave source, wave dest, variable dimSource, variable dimDest)

transfer the wave scaling from one wave to another

Note: wave scale transfer requires wave units for the first wave or second wave

Parameters:
  • source – Wave whos scaling should get transferred

  • dest – Wave that accepts the new scaling

  • dimSource – dimension of the source wave, if SF_TRANSFER_ALL_DIMS is used then all scales and units are transferred on the same dimensions, dimDest is ignored in that case, no unit check is applied in that case

  • dimDest – dimension of the destination wave

static std::tuple<WaveRefWave, SF_PlotMetaData> SF_GatherFormulaResults(string xFormula, string yFormula, string graph)
static string SF_FormatUnit(string unit)
static string SF_GetAnnotationPrefix(string dataType)
static string SF_GetTraceAnnotationText(SF_PlotMetaData *plotMetaData, wave data)
static string SF_GetMetaDataAnnotationText(SF_PlotMetaData *plotMetaData, wave data, string traceName)
static wave SF_GenerateTraceColors(wave colorGroups)
static wave SF_GetGroupColors(WaveRefWave formulaResults)

Return an Nx3 wave with one color triplett for each unique trace color group.

std::tuple<RGBColor> SF_GetTraceColor(string graph, string opStack, wave data, WaveOrNull traceGroupColors)
static std::tuple<WaveText, variable> SF_CreateTraceNames(variable numTraces, variable dataNum, SF_PlotMetaData *plotMetaData, wave data)

Generate numTraces trace names for the given input.

Generates the trace names required for a single formula in the plotter and therefore the trace names range from traceCnt to traceCnt + numTraces - 1.

Return values:
  • traces – generated trace names

  • traceCnt – total count of all traces (input and output)

static string SF_ShrinkLegend(string annotation)

Reduces a multi line legend to a single line if only the sweep number changes. Returns the original annotation if more changes or the legend text does not follow the exected format

static std::tuple<WaveText, WaveRefWave> SF_PreparePlotter(string winNameTemplate, string graph, variable winDisplayMode, variable numGraphs)
static variable SF_CommonWindowSetup(string win, string graph)
static variable SF_GatherAxisLabels(WaveRefWave formulaResults, string explicitLbl, string formulaLabel, WaveText axisLabels)
static string SF_CombineAxisLabels(WaveText axisLabels)
static variable SF_CheckNumTraces(string graph, variable numTraces)
static variable SF_CleanUpPlotWindowsOnFail(WaveText plotGraphs)
static variable SF_KillWorkingDF(string graph)
static wave GetSweepFormula(dfref dfr, variable graphNr, variable forAxis)

Return the X or Y wave for the sweep formula.

static wave SF_PrepareResultWaveForPlotting(dfref dfr, wave wvResult, variable dataCnt, variable forAxis)
static variable SF_FormulaPlotter(string graph, string formula, variable dmMode = defaultValue)

Plot the formula using the data from graph.

Parameters:
  • graph – graph to pass to SF_FormulaExecutor

  • formula – formula to plot

  • dmMode – [optional, default DM_SUBWINDOWS] display mode that defines how multiple sweepformula graphs are arranged

static variable SF_DeriveTraceDisplayMode(WaveOrNull wvX, wave wvY)
static variable SF_GetShowLegend(wave wv)
static variable SF_SplitPlotting(wave wv, variable dim, variable i, variable split)

utility function for SF_FormulaPlotter

split dimension dim of wave wv into slices of size split and get the starting index i

string SF_PreprocessInput(string formula)

Pre process code entered into the notebook.

  • unify line endings to CR

  • remove comments at line ending

  • cut off last CR from back conversion with TextWaveToList

variable SF_button_sweepFormula_check(WMButtonAction *ba)
static variable SF_ClearSFOutputState()
variable SF_DisplayOutputStateInGUI(string databrowser)
std::tuple<WaveText, string> SF_GetVariableAssignments(string preProcCode)
static string SF_CheckVariableAssignments(string preProcCode, variable jsonId)
static variable SF_CheckInputCode(string code, string graph)

Checks input code, sets globals for jsonId and error string.

variable SF_Update(string graph)
variable SF_IsActive(string win)

checks if SweepFormula (SF) is active.

std::tuple<string, string> SF_GetCode(string win)

Return the sweep formula code in raw and with all necessary preprocesssing.

variable SF_button_sweepFormula_display(WMButtonAction *ba)
variable SF_TabProc_Formula(WMTabControlAction *tca)
variable SF_SetSweepXAxisTickLabels(wave output, WaveOrNull selectDataPlainOrArray)
static wave SF_SplitCodeToGraphs(string code)
static std::tuple<string, string> SF_SplitGraphsToFormula(string graphCode)
static string SF_GetFormulaWinNameTemplate(string mainWindow)
variable SF_button_sweepFormula_tofront(WMButtonAction *ba)
wave SF_GetAllOldCodeForGUI(string win)
static wave SF_GetAllOldCode()
variable SF_PopMenuProc_OldCode(WMPopupAction *pa)
static std::tuple<RGBColor> SF_GetErrorColorsFromSeverity(variable severity)
variable SF_SetOutputState(string error, variable severity)
variable SF_SetFormula(string databrowser, string formula)
static variable SF_ConvertAllReturnDataToPermanent(WaveRefWave output, string win, string opShort)
wave SF_GetArgumentTop(SF_ExecutionData *exd, string opShort)

Executes the complete arguments of the JSON and parses the resulting data to a waveRef type.

Deprecated:

: executing all arguments e.g. as array in the executor poses issues as soon as data types get mixed. e.g. operation(0, A, [1, 2, 3]) fails as [0, A, [1, 2, 3]] can not be converted to an Igor wave. Thus, it is strongly recommended to parse each argument separately.

static wave SF_CreatePlotFormulaDataWave()
static variable SF_CollectTraceData(variable *index, WaveRefWave graphData, string traceName, WaveOrNull wx, wave wy)
static std::tuple<string, string> SF_SplitVariableAssignment(string line)
dfref SF_GetBrowserDF(string graph)
wave SF_ResolveDatasetFromJSON(SF_ExecutionData *exd, variable argNum, variable copy = defaultValue)

Executes the part of the argument part of the JSON and parses the resulting data to a waveRef type.

wave SF_ResolveDataset(wave input)
string SF_GetDefaultFormula()
static variable SF_FormulaPlotterExtendResultsIfCompatible(WaveRefWave formulaResults)

This function extends formulaResults if possible. For each result from a Y formula it is attempted to move datasets from inside an array outside in the form [dataset(1, 2), dataset(3, 4)] -> dataset([1, 3], [3, 4]) because the plotter can iterate over datasets only at the outermost occurrence. As result the inside elements may be plottable after this transformation. algorithm details: Each Y formula result is ‘repackaged’ in an array and attempted to be transformed Case 1: On a failed transformation the initial array is returned. Case 2: On a successful transformation a dataset with one or more elements is returned Regarding the plotter the array of case 1 is treated as a single dataset. All the results from case 1 and case 2 are gathered in a waveref wave collectY. The X formula results are associated multiple times for case 2 if multiple datasets were returned and are gathered in a waveref wave collectX that grows identical to collectY. The formulaResults wave gets modified to store the new transformed results.

variable TraceValueDisplayHook(WMTooltipHookStruct *s)

Variables

static const string SF_SWEEPFORMULA_REGEXP = "^(.+?)(?:\\bvs\\b(.+))?$"

Regular expression which extracts both formulas from $a vs $b

static const string SF_SWEEPFORMULA_GRAPHS_REGEXP = "^(.+?)(?:\\r[ \t]*and[ \t]*\\r(.*))?$"

Regular expression which extracts formulas pairs from $a vs $b\rand\r$c vs $d\rand\r...

static const string SF_SWEEPFORMULA_WITH_REGEXP = "^(.+?)(?:\\r[ \t]*with[ \t]*\\r(.*))?$"

Regular expression which extracts y-formulas from $a\rwith\r$b\rwith\r$c\r...

static const double SF_MAX_NUMPOINTS_FOR_MARKERS = 1000
static const string SF_CHAR_COMMENT = "#"
static const string SF_CHAR_CR = "\r"
static const string SF_CHAR_NEWLINE = "\n"
static const string SF_PLOTTER_GUIDENAME = "HOR"
static const string SF_XLABEL_USER = ""
static const double SF_NUMTRACES_ERROR_THRESHOLD = 10000
static const double SF_NUMTRACES_WARN_THRESHOLD = 1000
static const double SF_SWEEPFORMULA_AXIS_X = 0
static const double SF_SWEEPFORMULA_AXIS_Y = 1