Skip to content

Commit dc98aba

Browse files
committed
SF: bugfix for avg operation with group mode
The avg operation in group mode does a wavenote and meta data transfer. This transfer works only if the number of datasets in the output waves are equal to the number of datasets of the input waves. (If there would be less input than output waves, there would be no data for some output waves) The group mode did transfer always from the first group. If the first group contained less datasets than the group with the greatest number of datasets then the transfer failed. As the result of the group averaging always has the same number of datasets as the greatest group the wave note and meta data transfer is now done from the greatest input group. Since: 272c26b (SF: operation avg add mode to average over groups of data, 2025-11-12)
1 parent 6f8f5e7 commit dc98aba

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Packages/MIES/MIES_SweepFormula_Operations.ipf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,6 @@ Function/WAVE SFO_OperationAvg(STRUCT SF_ExecutionData &exd)
517517
elseif(!CmpStr(mode, SF_OP_AVG_GROUPS))
518518
WAVE/WAVE dataFromEachGroup = SFH_GetDatasetArrayAsResolvedWaverefs(exd, 0, resolveSelect = 1)
519519
WAVE/WAVE averagedGroup = SFO_OperationAvgImplSweepGroups(dataFromEachGroup, exd.graph, opShort)
520-
SFH_TransferFormulaDataWaveNoteAndMeta(dataFromEachGroup[0], averagedGroup, opShort, SF_DATATYPE_AVG)
521520

522521
return SFH_GetOutputForExecutor(averagedGroup, exd.graph, opShort)
523522
else
@@ -527,15 +526,17 @@ End
527526

528527
static Function/WAVE SFO_OperationAvgImplSweepGroups(WAVE/WAVE sweepsFromEachSelection, string graph, string opShort)
529528

530-
variable numData, numMaxSweeps, numGroups, i, j
529+
variable numData, numMaxSweeps, numGroups, i, j, maxIdx
531530
STRUCT RGBColor s
532531

533532
[s] = GetTraceColorForAverage()
534533
Make/FREE/W/U traceColor = {s.red, s.green, s.blue}
535534

536535
numGroups = DimSize(sweepsFromEachSelection, ROWS)
537536
Make/FREE/D/N=(numGroups) sweepCnts = DimSize(sweepsFromEachSelection[p], ROWS)
538-
numMaxSweeps = WaveMax(sweepCnts)
537+
WaveStats/Q/M=1 sweepCnts
538+
numMaxSweeps = V_max
539+
maxIdx = V_maxRowLoc
539540
WAVE/WAVE output = SFH_CreateSFRefWave(graph, opShort, numMaxSweeps)
540541
for(i = 0; i < numMaxSweeps; i += 1)
541542
Make/FREE/WAVE/N=(numGroups) avgSet
@@ -553,6 +554,7 @@ static Function/WAVE SFO_OperationAvgImplSweepGroups(WAVE/WAVE sweepsFromEachSel
553554
JWN_SetNumberInWaveNote(output[i], SF_META_TRACETOFRONT, 1)
554555
JWN_SetNumberInWaveNote(output[i], SF_META_LINESTYLE, 0)
555556
endfor
557+
SFH_TransferFormulaDataWaveNoteAndMeta(sweepsFromEachSelection[maxIdx], output, opShort, SF_DATATYPE_AVG)
556558

557559
return output
558560
End

0 commit comments

Comments
 (0)