Skip to content

Commit 82df058

Browse files
committed
PSQ_DS_AddDAScaleFillinBetweenPosAndNegSlope: Fix neg pos fillin
We need to search for a change of the f-I neg slope QC, so going from 0 to 1. Unfortunately FindSequence has a bug when reverse searching, so we need to workaround that.
1 parent 32d7507 commit 82df058

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf

+18-8
Original file line numberDiff line numberDiff line change
@@ -3246,9 +3246,12 @@ static Function PSQ_DS_NegativefISlopePassingCriteria(WAVE numericalValues, WAVE
32463246
return 0
32473247
End
32483248

3249+
/// @brief Add fillin value between the last positive f-I slope and the next negative f-I slope
3250+
///
3251+
/// @retval zero if a value could be added, one if not
32493252
static Function PSQ_DS_AddDAScaleFillinBetweenPosAndNegSlope(string device, variable sweepNo, variable headstage, [variable fromRhSuAd])
32503253

3251-
variable emptySCI, numFitSlopes, i, numEntries
3254+
variable emptySCI, numFitSlopes, idx
32523255
string type, msg
32533256
variable centerDASCale = NaN
32543257

@@ -3264,16 +3267,23 @@ static Function PSQ_DS_AddDAScaleFillinBetweenPosAndNegSlope(string device, vari
32643267
[WAVE negSlopePassed, emptySCI] = PSQ_DS_GetLabnotebookData(numericalValues, textualValues, sweepNo, headstage, PSQ_DS_FI_NEG_SLOPE_PASS, fromRhSuAd = fromRhSuAd)
32653268
[WAVE DAScale, emptySCI] = PSQ_DS_GetLabnotebookData(numericalValues, textualValues, sweepNo, headstage, PSQ_DS_DASCALE, fromRhSuAd = fromRhSuAd)
32663269

3267-
numEntries = DimSize(DAScale, ROWS)
3268-
ASSERT(numEntries == (DimSize(negSlopePassed, ROWS) + 1), "Non-matching negSlopePassedAll and DAScale waves")
3270+
InsertPoints/V=(NaN) 0, 1, negSlopePassed
3271+
3272+
ASSERT(DimSize(DAScale, ROWS) == DimSize(negSlopePassed, ROWS), "Non-matching negSlopePassed and DAScale waves")
3273+
3274+
[WAVE DAScaleSorted, WAVE negSlopePassedSorted] = SortKeyAndData(DAScale, negSlopePassed)
3275+
WaveClear DAScale, negSlopePassed
3276+
3277+
Make/FREE seq = {0, 1}
3278+
idx = FindSequenceReverseWrapper(seq, negSlopePassedSorted)
32693279

3270-
FindValue/R/V=(0) negSlopePassed
3271-
if(V_Value >= 0)
3272-
centerDAScale = round((DAScale[V_Value] + DAScale[V_Value + 1]) / 2)
3280+
if(idx >= 0)
3281+
// -1 because negSlopePassedSorted is calculated for two sweeps
3282+
centerDAScale = round((DAScaleSorted[idx - (idx == 0 ? 0 : 1)] + DAScaleSorted[idx]) / 2)
32733283
endif
32743284

32753285
#ifdef DEBUGGING_ENABLED
3276-
sprintf msg, "centerDAScale %g: DAScales=%s; fitSlopes=%s", centerDAScale, NumericWaveToList(DAScale, ", ", trailSep = 0), NumericWaveToList(negSlopePassed, ", ", trailSep = 0)
3286+
sprintf msg, "centerDAScale %g: idx=%g; DAScales=%s; negSlopePassed=%s", centerDAScale, idx, NumericWaveToList(DAScaleSorted, ", ", trailSep = 0), NumericWaveToList(negSlopePassedSorted, ", ", trailSep = 0)
32773287
DEBUGPRINT(msg)
32783288
#endif
32793289

@@ -3283,7 +3293,7 @@ static Function PSQ_DS_AddDAScaleFillinBetweenPosAndNegSlope(string device, vari
32833293
return 1
32843294
endif
32853295

3286-
if(IsFinite(GetRowIndex(DASCale, val = centerDAScale)))
3296+
if(IsFinite(GetRowIndex(DAScaleSorted, val = centerDAScale)))
32873297
// already measured, do nothing
32883298
return 1
32893299
endif

Packages/tests/HardwareAnalysisFunctions/UTF_PatchSeqDAScale_Adapt.ipf

-1
Original file line numberDiff line numberDiff line change
@@ -2658,7 +2658,6 @@ static Function PS_DS_AD15_REENTRY([string str])
26582658
Make/FREE/D maxSlopeRef = {0}
26592659
Make/FREE/D fiSlopeRef = {4.444444444444444e-11}
26602660
Make/FREE/D fiOffsetRef = {0.5555555555555558}
2661-
Make/FREE/T futureDAScalesRef = {"RegRhSuAd:10;"}
26622661

26632662
Make/FREE/D fiSlopesFromRhSuAdRef = {0, 0, 0}
26642663
Make/FREE/D fiOffsetsFromRhSuAdRef = {1, 1, 1}

0 commit comments

Comments
 (0)