Skip to content

Commit 870749e

Browse files
committed
PSX_OperationKernel: Support multiple select statements
This removes the artificial restriction introduced in 83713dd (SF Implement new select operation, 2024-10-02). We now also check that ranges from the same sweep/channel/channelType/experiment combination don't intersect.
1 parent cfcbe8b commit 870749e

File tree

2 files changed

+45
-16
lines changed

2 files changed

+45
-16
lines changed

Packages/MIES/MIES_SweepFormula_PSX.ipf

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4727,23 +4727,15 @@ Function/WAVE PSX_OperationKernel(variable jsonId, string jsonPath, string graph
47274727
variable riseTau, decayTau, amp, dt, numPoints, numCombos, i, offset, idx
47284728
string parameterPath, key
47294729

4730-
WAVE/WAVE selectDataCompArray = SFH_GetArgumentSelect(jsonID, jsonPath, graph, SF_OP_PSX_KERNEL, 0)
4730+
WAVE/Z/WAVE selectDataCompArray = SFH_GetArgumentSelect(jsonID, jsonPath, graph, SF_OP_PSX_KERNEL, 0)
4731+
SFH_ASSERT(WaveExists(selectDataCompArray), "Could not gather sweep data from select statement")
47314732

47324733
riseTau = SFH_GetArgumentAsNumeric(jsonID, jsonPath, graph, SF_OP_PSX_KERNEL, 1, defValue = 1, checkFunc = IsStrictlyPositiveAndFinite)
47334734
decayTau = SFH_GetArgumentAsNumeric(jsonID, jsonPath, graph, SF_OP_PSX_KERNEL, 2, defValue = 15, checkFunc = IsStrictlyPositiveAndFinite)
47344735
amp = SFH_GetArgumentAsNumeric(jsonID, jsonPath, graph, SF_OP_PSX_KERNEL, 3, defValue = -5, checkFunc = IsFinite)
47354736

47364737
SFH_ASSERT(decayTau > riseTau, "decay tau must be strictly larger than the rise tau")
47374738

4738-
SFH_ASSERT(DimSize(selectDataCompArray, ROWS) == 1, "Only supports a single selection at the moment")
4739-
4740-
WAVE/WAVE selectDataComp = selectDataCompArray[0]
4741-
4742-
WAVE/Z selectData = selectDataComp[%SELECTION]
4743-
WAVE/WAVE range = selectDataComp[%RANGE]
4744-
4745-
SFH_ASSERT(WaveExists(selectData), "Could not gather sweep data from select statement")
4746-
47474739
WAVE/WAVE sweepDataRef = SFH_GetSweepsForFormula(graph, selectDataCompArray, SF_OP_PSX_KERNEL)
47484740

47494741
numCombos = DimSize(sweepDataRef, ROWS)
@@ -4754,8 +4746,21 @@ Function/WAVE PSX_OperationKernel(variable jsonId, string jsonPath, string graph
47544746
Make/FREE/T rawLabels = {"psxKernel", "psxKernelFFT", "sweepData"}
47554747
ASSERT(DimSize(rawLabels, ROWS) == PSX_KERNEL_OUTPUTWAVES_PER_ENTRY, "Mismatched rawLabels wave")
47564748

4749+
Make/FREE/N=(0) allResolvedRanges
4750+
Make/FREE/N=(0)/T allSelectHashes
4751+
47574752
for(i = 0; i < numCombos; i += 1)
4758-
WAVE sweepData = sweepDataRef[i]
4753+
WAVE/Z sweepData = sweepDataRef[i]
4754+
ASSERT(WaveExists(sweepData), "Can't handle invalid sweepData waves")
4755+
4756+
[WAVE singleSelectData, WAVE range] = SFH_ParseToSelectDataWaveAndRange(sweepData)
4757+
4758+
[WAVE resolvedRanges, WAVE/T epochRangeNames] = SFH_GetNumericRangeFromEpochFromSingleSelect(graph, singleSelectData, range)
4759+
4760+
if(!WaveExists(resolvedRanges))
4761+
continue
4762+
endif
4763+
47594764
numPoints = DimSize(sweepData, ROWS)
47604765
dt = DimDelta(sweepData, ROWS)
47614766

@@ -4770,6 +4775,8 @@ Function/WAVE PSX_OperationKernel(variable jsonId, string jsonPath, string graph
47704775
continue
47714776
endif
47724777

4778+
PSX_CollectResolvedRanges(graph, resolvedRanges, singleSelectData, allResolvedRanges, allSelectHashes)
4779+
47734780
Duplicate/FREE/T rawLabels, labels
47744781
labels[] = PSX_GenerateKey(rawLabels[p], idx)
47754782
SetDimensionLabels(output, TextWaveToList(labels, ";"), ROWS, startPos = idx * PSX_KERNEL_OUTPUTWAVES_PER_ENTRY)
@@ -4788,14 +4795,13 @@ Function/WAVE PSX_OperationKernel(variable jsonId, string jsonPath, string graph
47884795

47894796
SFH_ASSERT(numCombos > 0, "Could not create psxKernel")
47904797

4798+
PSX_CheckResolvedRangesWithSelectHashes(allResolvedRanges, allSelectHashes)
4799+
47914800
Redimension/N=(PSX_KERNEL_OUTPUTWAVES_PER_ENTRY * numCombos) output
47924801

47934802
parameterPath = SF_META_USER_GROUP + PSX_JWN_PARAMETERS + "/" + SF_OP_PSX_KERNEL
47944803

4795-
WAVE rangeClean = ZapNullRefs(range)
4796-
47974804
JWN_CreatePath(output, parameterPath)
4798-
JWN_SetWaveInWaveNote(output, parameterPath + "/range", rangeClean) // not the same as SF_META_RANGE
47994805
JWN_SetNumberInWaveNote(output, parameterPath + "/riseTau", riseTau)
48004806
JWN_SetNumberInWaveNote(output, parameterPath + "/decayTau", decayTau)
48014807
JWN_SetNumberInWaveNote(output, parameterPath + "/amp", amp)

Packages/tests/Basic/UTF_SweepFormula_PSX.ipf

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ static Function TestOperationPSXKernel()
13161316
CHECK_GE_VAR(jsonID, 0)
13171317
WAVE/Z params = JSON_GetKeys(jsonID, SF_META_USER_GROUP + "Parameters/" + SF_OP_PSX_KERNEL)
13181318
CHECK_WAVE(params, TEXT_WAVE)
1319-
CHECK_EQUAL_VAR(DimSize(params, ROWS), 4)
1319+
CHECK_EQUAL_VAR(DimSize(params, ROWS), 3)
13201320
JSON_Release(jsonID)
13211321

13221322
// offset for sweep data is 50 due to the range above
@@ -1327,6 +1327,15 @@ static Function TestOperationPSXKernel()
13271327
CheckDimensionScaleHelper(dataWref[4], 0, 0.01)
13281328
CheckDimensionScaleHelper(dataWref[5], 50, 0.2)
13291329

1330+
str = "psxKernel([select(selRange([50, 150]), selchannels(AD6), selsweeps(0), selvis(all)), select(selRange([50, 150]), selchannels(AD6), selsweeps(2), selvis(all))], 1, 15, -5)"
1331+
WAVE/WAVE dataWref = SF_ExecuteFormula(str, win, useVariables = 0)
1332+
CHECK_WAVE(dataWref, WAVE_WAVE)
1333+
CHECK_EQUAL_VAR(DimSize(dataWref, ROWS), 6)
1334+
1335+
actual = MIES_CA#CA_WaveCRCs(dataWref, includeWaveScalingAndUnits = 1)
1336+
// same hashes as above with only a single select
1337+
CHECK_EQUAL_STR(expected, actual)
1338+
13301339
// three waves from first range, none from second
13311340
Make/FREE/T/N=(3, 1, 1) epochKeys
13321341
epochKeys[0][0][0] = EPOCHS_ENTRY_KEY
@@ -1339,6 +1348,11 @@ static Function TestOperationPSXKernel()
13391348
epochsWave[0][EPOCH_COL_TAGS][DAC][XOP_CHANNEL_TYPE_DAC] = "ShortName=E0;stuff"
13401349
epochsWave[0][EPOCH_COL_TREELEVEL][DAC][XOP_CHANNEL_TYPE_DAC] = "0"
13411350

1351+
epochsWave[1][EPOCH_COL_STARTTIME][DAC][XOP_CHANNEL_TYPE_DAC] = "0.075"
1352+
epochsWave[1][EPOCH_COL_ENDTIME][DAC][XOP_CHANNEL_TYPE_DAC] = "0.175"
1353+
epochsWave[1][EPOCH_COL_TAGS][DAC][XOP_CHANNEL_TYPE_DAC] = "ShortName=E1;apples"
1354+
epochsWave[1][EPOCH_COL_TREELEVEL][DAC][XOP_CHANNEL_TYPE_DAC] = "1"
1355+
13421356
Make/FREE/T/N=(1, 1, LABNOTEBOOK_LAYER_COUNT) epochInfo = EP_EpochWaveToStr(epochsWave, DAC, XOP_CHANNEL_TYPE_DAC)
13431357
ED_AddEntriesToLabnotebook(epochInfo, epochKeys, 0, device, DATA_ACQUISITION_MODE)
13441358

@@ -1376,6 +1390,15 @@ static Function TestOperationPSXKernel()
13761390
catch
13771391
PASS()
13781392
endtry
1393+
1394+
// overlapping intervals in one select statement
1395+
str = "psxKernel(select(selrange([E0, E1]), selchannels(AD6), selsweeps([0]), selvis(all)), 1, 15, -5)"
1396+
try
1397+
WAVE/WAVE dataWref = SF_ExecuteFormula(str, win, useVariables = 0)
1398+
FAIL()
1399+
catch
1400+
PASS()
1401+
endtry
13791402
End
13801403

13811404
static Function CheckDimensionScaleHelper(WAVE wv, variable refOffset, variable refPerPoint)
@@ -1456,7 +1479,7 @@ static Function TestOperationPSX([STRUCT IUTF_mData &m])
14561479
CHECK_GE_VAR(jsonID, 0)
14571480
WAVE/Z params = JSON_GetKeys(jsonID, SF_META_USER_GROUP + "Parameters/" + SF_OP_PSX_KERNEL)
14581481
CHECK_WAVE(params, TEXT_WAVE)
1459-
CHECK_EQUAL_VAR(DimSize(params, ROWS), 4)
1482+
CHECK_EQUAL_VAR(DimSize(params, ROWS), 3)
14601483

14611484
WAVE/Z params = JSON_GetKeys(jsonID, SF_META_USER_GROUP + "Parameters/" + SF_OP_PSX)
14621485
CHECK_WAVE(params, TEXT_WAVE)

0 commit comments

Comments
 (0)