@@ -3246,9 +3246,12 @@ static Function PSQ_DS_NegativefISlopePassingCriteria(WAVE numericalValues, WAVE
3246
3246
return 0
3247
3247
End
3248
3248
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
3249
3252
static Function PSQ_DS_AddDAScaleFillinBetweenPosAndNegSlope ( string device, variable sweepNo, variable headstage, [ variable fromRhSuAd] )
3250
3253
3251
- variable emptySCI, numFitSlopes, i , numEntries
3254
+ variable emptySCI, numFitSlopes, idx
3252
3255
string type, msg
3253
3256
variable centerDASCale = NaN
3254
3257
@@ -3264,16 +3267,23 @@ static Function PSQ_DS_AddDAScaleFillinBetweenPosAndNegSlope(string device, vari
3264
3267
[ WAVE negSlopePassed, emptySCI] = PSQ_DS_GetLabnotebookData ( numericalValues, textualValues, sweepNo, headstage, PSQ_DS_FI_NEG_SLOPE_PASS, fromRhSuAd = fromRhSuAd)
3265
3268
[ WAVE DAScale, emptySCI] = PSQ_DS_GetLabnotebookData ( numericalValues, textualValues, sweepNo, headstage, PSQ_DS_DASCALE, fromRhSuAd = fromRhSuAd)
3266
3269
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)
3269
3279
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 )
3273
3283
endif
3274
3284
3275
3285
#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 )
3277
3287
DEBUGPRINT ( msg)
3278
3288
#endif
3279
3289
@@ -3283,7 +3293,7 @@ static Function PSQ_DS_AddDAScaleFillinBetweenPosAndNegSlope(string device, vari
3283
3293
return 1
3284
3294
endif
3285
3295
3286
- if ( IsFinite ( GetRowIndex ( DASCale , val = centerDAScale)))
3296
+ if ( IsFinite ( GetRowIndex ( DAScaleSorted , val = centerDAScale)))
3287
3297
// already measured, do nothing
3288
3298
return 1
3289
3299
endif
0 commit comments