Skip to content

Commit 9f58f41

Browse files
committed
PSX_Operation: Fix data gathering after failure
When PSX_OperationSweepGathering returns 1 as error code, we wrote the code so that idx is not incremented in this case. The idea in d359a7a (PSX_Operation: Handle partial results better, 2024-02-27) was that we don't want holes in the output wave. But the code was buggy as it, after an error, would reuse the same data again, and thus error out again, and therefore ignoring all data behind the first combination with an error. Fix that by introducing separate indizes for reading and writing.
1 parent 979d245 commit 9f58f41

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Packages/MIES/MIES_SweepFormula_PSX.ipf

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -982,14 +982,15 @@ static Function/WAVE PSX_CreateOverrideResults(variable numEvents, WAVE/T combos
982982
End
983983

984984
/// @return 0 on success, 1 otherwise
985-
static Function PSX_OperationSweepGathering(string graph, WAVE/WAVE psxKernelDataset, variable parameterJsonID, WAVE sweepFilter, WAVE deconvFilter, variable index, WAVE/WAVE output)
985+
static Function PSX_OperationSweepGathering(string graph, WAVE/WAVE psxKernelDataset, variable parameterJsonID, WAVE sweepFilter, WAVE deconvFilter, variable readIndex, variable writeIndex, WAVE/WAVE output)
986986

987987
string key, comboKey, psxParametersAnalyzePeaks, cacheKey
988+
variable realOrderSweep, realOrderDeconv
988989

989-
key = PSX_GenerateKey("psxKernelFFT", index)
990+
key = PSX_GenerateKey("psxKernelFFT", readIndex)
990991
WAVE psxKernelFFT = psxKernelDataset[%$key]
991992

992-
key = PSX_GenerateKey("sweepData", index)
993+
key = PSX_GenerateKey("sweepData", readIndex)
993994
WAVE sweepData = psxKernelDataset[%$key]
994995

995996
[WAVE selectData, WAVE range] = SFH_ParseToSelectDataWaveAndRange(sweepData)
@@ -1027,13 +1028,13 @@ static Function PSX_OperationSweepGathering(string graph, WAVE/WAVE psxKernelDat
10271028
endif
10281029
endif
10291030

1030-
key = PSX_GenerateKey("sweepData", index)
1031+
key = PSX_GenerateKey("sweepData", writeIndex)
10311032
output[%$key] = sweepData
10321033

1033-
key = PSX_GenerateKey("sweepDataOffFilt", index)
1034+
key = PSX_GenerateKey("sweepDataOffFilt", writeIndex)
10341035
output[%$key] = sweepDataOffFilt
10351036

1036-
key = PSX_GenerateKey("sweepDataOffFiltDeconv", index)
1037+
key = PSX_GenerateKey("sweepDataOffFiltDeconv", writeIndex)
10371038
output[%$key] = sweepDataOffFiltDeconv
10381039

10391040
return 0
@@ -4959,8 +4960,8 @@ End
49594960
// psx(id, [psxKernel(...), numSDs, psxSweepBPFilter(...), maxTauFactor, psxRiseTime(...), psxDeconvBPFilter(...)])
49604961
Function/WAVE PSX_Operation(variable jsonId, string jsonPath, string graph)
49614962

4962-
variable numberOfSDs, parameterJsonID, numCombos, i, addedData, kernelAmp
4963-
variable maxTauFactor, peakThresh, idx, success, kernelRiseTau, kernelDecayTau
4963+
variable numberOfSDs, parameterJsonID, numCombos, i, readIndex, writeIndex, addedData, kernelAmp
4964+
variable maxTauFactor, peakThresh, success, kernelRiseTau, kernelDecayTau
49644965
string parameterPath, id, psxParameters, dataUnit, path
49654966

49664967
id = SFH_GetArgumentAsText(jsonID, jsonPath, graph, SF_OP_PSX, 0, checkFunc = IsValidObjectName)
@@ -5017,11 +5018,12 @@ Function/WAVE PSX_Operation(variable jsonId, string jsonPath, string graph)
50175018
PSX_OperationSetDimensionLabels(output, numCombos, labels, labelsTemplate)
50185019

50195020
for(i = 0; i < numCombos; i += 1)
5020-
success = !PSX_OperationSweepGathering(graph, psxKernelDataset, parameterJsonID, sweepFilter, deconvFilter, idx, output)
5021-
idx += success
5021+
readIndex = i
5022+
success = !PSX_OperationSweepGathering(graph, psxKernelDataset, parameterJsonID, sweepFilter, deconvFilter, readIndex, writeIndex, output)
5023+
writeIndex += success
50225024
endfor
50235025

5024-
numCombos = idx
5026+
numCombos = writeIndex
50255027

50265028
if(numCombos == 0)
50275029
Abort

0 commit comments

Comments
 (0)