Skip to content

Commit

Permalink
FindRange: Fix querying data from NaN sweep
Browse files Browse the repository at this point in the history
When we look for data in the NaN sweep, these are the labnotebook entries
before the very first sweep and don't care about the entry source type
(UNKNOWN_MODE) we did not find anything.

The reason is that we are searching from the back for a continous range of
entries with the given source type and sweep number.

But if we have empty entries at the back of the labnotebook, which is very
likely, we always only search in these. But as these are empty rows, we
don't find anything.

For finite sweep numbers this is an optimization at the FindIndizes call
only.

The check for non-finite endRow is needed as we don't upgrade labnotebooks
from the analysis browser.
  • Loading branch information
t-b committed Oct 25, 2024
1 parent 6535eba commit 99ce799
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Packages/MIES/MIES_MiesUtilities_Logbook.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1368,18 +1368,30 @@ threadsafe static Function FindRange(wv, col, val, entrySourceType, first, last)
variable col, val, entrySourceType
variable &first, &last

variable numRows, i, j, sourceTypeCol, firstRow, lastRow, isNumeric, index
variable numRows, i, j, sourceTypeCol, firstRow, lastRow, isNumeric, index, startRow, endRow

first = NaN
last = NaN
isNumeric = IsNumericWave(wv)

startRow = 0
endRow = GetNumberFromWaveNote(wv, NOTE_INDEX) - 1

if(IsNaN(endRow))
endRow = DimSize(wv, ROWS) - 1
endif

if(endRow < 0)
// empty labnotebook
return NaN
endif

// still correct without startLayer/endLayer coordinates
// as we always have sweepNumber/etc. in the first layer
if(IsNaN(val) && isNumeric)
WAVE/Z indizesSetting = FindIndizes(wv, col = col, prop = PROP_EMPTY)
WAVE/Z indizesSetting = FindIndizes(wv, col = col, prop = PROP_EMPTY, startRow = startRow, endRow = endRow)
else
WAVE/Z indizesSetting = FindIndizes(wv, col = col, var = val)
WAVE/Z indizesSetting = FindIndizes(wv, col = col, var = val, startRow = startRow, endRow = endRow)
endif

if(!WaveExists(indizesSetting))
Expand Down
4 changes: 4 additions & 0 deletions Packages/tests/Basic/UTF_Labnotebook.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ Function GetLastSettingFindsNaNSweep()

Make/D/FREE settingsRef = {10.0010900497437, 10.001935005188, NaN, NaN, NaN, NaN, NaN, NaN, NaN}
CHECK_EQUAL_WAVES(settings, settingsRef, mode = WAVE_DATA, tol = 1e-13)

// and also with unknown mode
WAVE/Z settings = GetLastSetting(numericalValues, NaN, "TP Steady State Resistance", UNKNOWN_MODE)
CHECK_EQUAL_WAVES(settings, settingsRef, mode = WAVE_DATA, tol = 1e-13)
End

static Function GetLastSettingFindsWithinNonConsecutiveSweepOrder()
Expand Down

0 comments on commit 99ce799

Please sign in to comment.