Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion Packages/MIES/MIES_SweepFormula.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ static StrConstant SF_OP_RMS = "rms"
static StrConstant SF_OP_VARIANCE = "variance"
static StrConstant SF_OP_STDEV = "stdev"
static StrConstant SF_OP_DERIVATIVE = "derivative"
static StrConstant SF_OP_TABLE = "table"
static StrConstant SF_OP_INTEGRATE = "integrate"
static StrConstant SF_OP_TIME = "time"
static StrConstant SF_OP_XVALUES = "xvalues"
Expand Down Expand Up @@ -208,7 +209,7 @@ Function/WAVE SF_GetNamedOperations()
SF_OP_CHANNELS, SF_OP_DATA, SF_OP_LABNOTEBOOK, SF_OP_WAVE, SF_OP_FINDLEVEL, SF_OP_EPOCHS, SF_OP_TP, \
SF_OP_STORE, SF_OP_SELECT, SF_OP_POWERSPECTRUM, SF_OP_TPSS, SF_OP_TPBASE, SF_OP_TPINST, SF_OP_TPFIT, \
SF_OP_PSX, SF_OP_PSX_KERNEL, SF_OP_PSX_STATS, SF_OP_PSX_RISETIME, SF_OP_PSX_PREP, SF_OP_PSX_DECONV_FILTER, \
SF_OP_MERGE, SF_OP_FIT, SF_OP_FITLINE, SF_OP_DATASET}
SF_OP_MERGE, SF_OP_FIT, SF_OP_FITLINE, SF_OP_DATASET, SF_OP_TABLE}

return wt
End
Expand Down Expand Up @@ -1020,6 +1021,9 @@ static Function/WAVE SF_FormulaExecutor(string graph, variable jsonID, [string j
case SF_OP_DERIVATIVE:
WAVE out = SF_OperationDerivative(jsonId, jsonPath, graph)
break
case SF_OP_TABLE:
WAVE out = SF_OperationTable(jsonID, jsonPath, graph)
break
case SF_OP_INTEGRATE:
WAVE out = SF_OperationIntegrate(jsonId, jsonPath, graph)
break
Expand Down Expand Up @@ -1770,6 +1774,13 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode
WAVE wvX = dummy
endif

variable useTable = !!JWN_GetNumberFromWaveNote(wvY, "Table")

if(useTable)
Edit/HOST=$win/FG=(FL, FT, FR, FB) wvY.d
continue
endif

if(!WaveExists(wvX))
numTraces = yMxN
SF_CheckNumTraces(graph, numTraces)
Expand Down Expand Up @@ -3795,6 +3806,21 @@ static Function/WAVE SF_OperationDerivative(variable jsonId, string jsonPath, st
return SFH_GetOutputForExecutor(output, graph, SF_OP_DERIVATIVE, clear = input)
End

static Function/WAVE SF_OperationTable(variable jsonId, string jsonPath, string graph)

SFH_CheckArgumentCount(jsonId, jsonPath, SF_OP_TABLE, 1, maxArgs = 1)

WAVE/WAVE input = SF_ResolveDatasetFromJSON(jsonId, jsonPath, graph, 0)

WAVE/WAVE output = SFH_CreateSFRefWave(graph, SF_OP_DERIVATIVE, DimSize(input, ROWS))
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is creating a reference wave using SF_OP_DERIVATIVE constant instead of SF_OP_TABLE. This should be SF_OP_TABLE to maintain consistency with the operation being performed.

Suggested change
WAVE/WAVE output = SFH_CreateSFRefWave(graph, SF_OP_DERIVATIVE, DimSize(input, ROWS))
WAVE/WAVE output = SFH_CreateSFRefWave(graph, SF_OP_TABLE, DimSize(input, ROWS))

Copilot uses AI. Check for mistakes.


output[] = input[p]

JWN_SetNumberInWaveNote(input, "Table", 1)
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table flag is being set on the input wave instead of the output wave. This means the flag will be applied to the original data rather than the processed output, which could affect other operations that use the same input data. This should be applied to the output wave elements instead.

Suggested change
JWN_SetNumberInWaveNote(input, "Table", 1)
JWN_SetNumberInWaveNote(output, "Table", 1)

Copilot uses AI. Check for mistakes.


return SFH_GetOutputForExecutor(output, graph, SF_OP_TABLE)
End

static Function/WAVE SF_OperationDerivativeImpl(WAVE/Z input)

if(!WaveExists(input))
Expand Down