@@ -1290,44 +1290,77 @@ static Function/S PSX_BuildSweepEquivValue(variable sweepNo, variable mapIndex)
12901290
12911291 return str
12921292End
1293+
12931294/// @brief Generate the equivalence classes of selectData
12941295///
12951296/// All selections which have the same channel number and type are in one equivalence class.
12961297///
12971298/// The returned 2D wave has row labels from PSX_BuildSweepEquivKey() for the
12981299/// channel type/number and the sweep numbers in the columns.
1299- static Function/ WAVE PSX_GenerateSweepEquiv ( WAVE selectData )
1300+ static Function [WAVE/T sweepEquiv, WAVE/WAVE sweepEquivRanges] PSX_GenerateSweepEquiv ( WAVE /WAVE selectDataCompArray )
13001301
1301- variable numSelect , idx, i , nextFreeRow, maxCol
1302+ variable numSelectComp , numSelected , idx, i , j , nextFreeRow, maxCol, col , isSingleRange
13021303 string key
13031304
1304- numSelect = DimSize ( selectData, ROWS)
1305- ASSERT ( numSelect > 0, "Expected at least one entry in sweepData" )
1305+ ASSERT ( IsWaveRefWave ( selectDataCompArray) , "Expected a wave reference wave for selectDataCompArray" )
1306+
1307+ numSelectComp = DimSize ( selectDataCompArray, ROWS)
1308+ ASSERT ( numSelectComp > 0, "Expected at least one entry in selectDataCompArray" )
1309+
1310+ Make / N= ( MINIMUM_WAVE_SIZE, MINIMUM_WAVE_SIZE) / FREE=1/ T sweepEquiv
1311+ Make / N= ( MINIMUM_WAVE_SIZE, MINIMUM_WAVE_SIZE) / FREE=1/ WAVE sweepEquivRanges
13061312
1307- Make / N= ( numSelect, numSelect) / FREE=1/ T sweepEquiv
1313+ for ( i = 0; i < numSelectComp; i += 1 )
1314+ WAVE /WAVE selectDataComp = selectDataCompArray[ i ]
1315+ ASSERT ( IsWaveRefWave ( selectDataComp) , "Expected a wave reference wave for selectDataComp" )
13081316
1309- for ( i = 0; i < numSelect ; i += 1 )
1310- key = PSX_BuildSweepEquivKey ( selectData [ i ][ % CHANNELTYPE ] , selectData [ i ][ % CHANNELNUMBER ])
1311- idx = FindDimLabel ( sweepEquiv , ROWS , key )
1317+ WAVE selectData = selectDataComp [ % SELECTION ]
1318+ WAVE /WAVE range = selectDataComp [ % RANGE ]
1319+ ASSERT ( IsWaveRefWave ( range ) , "Range must be a wave reference wave" )
13121320
1313- if ( idx == -2 )
1314- SetDimLabel ROWS , nextFreeRow , $ key , sweepEquiv
1315- idx = nextFreeRow
1316- nextFreeRow += 1
1321+ isSingleRange = DimSize ( range , ROWS ) == 1
1322+
1323+ if ( ! isSingleRange )
1324+ SFH_ASSERT ( DimSize ( range , ROWS ) == numSelected , "Number of ranges is not equal number of selections." )
13171325 endif
13181326
1319- FindValue / TXOP=4/ TEXT= "" / RMD= [ idx][] sweepEquiv
1320- ASSERT ( V_col >= 0, "Not enough space" )
1321- maxCol = max ( maxCol, V_col)
1327+ numSelected = DimSize ( selectData, ROWS)
1328+ for ( j = 0; j < numSelected; j += 1 )
1329+ key = PSX_BuildSweepEquivKey ( selectData[ j][ % CHANNELTYPE] , selectData[ j][ % CHANNELNUMBER])
1330+ idx = FindDimLabel ( sweepEquiv, ROWS, key)
1331+
1332+ if ( idx == -2 )
1333+ EnsureLargeEnoughWave ( sweepEquiv, dimension = ROWS, indexShouldExist = nextFreeRow)
1334+
1335+ SetDimLabel ROWS, nextFreeRow, $ key, sweepEquiv
1336+ idx = nextFreeRow
1337+ nextFreeRow += 1
1338+ endif
1339+
1340+ FindValue / TXOP=4/ TEXT= "" / RMD= [ idx][] sweepEquiv
1341+ if ( V_col >= 0 )
1342+ col = V_col
1343+ else
1344+ col = DimSize ( sweepEquiv, COLS)
1345+ EnsureLargeEnoughWave ( sweepEquiv, dimension = COLS, indexShouldExist = col)
1346+ endif
13221347
1323- sweepEquiv[ idx][ V_col] = PSX_BuildSweepEquivValue ( selectData[ i ][ % SWEEP] , selectData[ i ][ % SWEEPMAPINDEX])
1348+ maxCol = max ( maxCol, col)
1349+ sweepEquiv[ idx][ col] = PSX_BuildSweepEquivValue ( selectData[ j][ % SWEEP] , selectData[ j][ % SWEEPMAPINDEX])
1350+
1351+ EnsureLargeEnoughWave ( sweepEquivRanges, dimension = ROWS, indexShouldExist = idx)
1352+ EnsureLargeEnoughWave ( sweepEquivRanges, dimension = COLS, indexShouldExist = col)
1353+
1354+ WAVE /Z setRange = range[ isSingleRange ? 0 : i ]
1355+ sweepEquivRanges[ idx][ col] = setRange
1356+ endfor
13241357 endfor
13251358
13261359 ASSERT ( nextFreeRow > 0, "Could not build sweep equivalence classes" )
13271360
1328- Redimension / N= ( nextFreeRow, maxCol + 1 ) sweepEquiv
1361+ Redimension / N= ( nextFreeRow, maxCol + 1 ) sweepEquiv, sweepEquivRanges
13291362
1330- return sweepEquiv
1363+ return [ sweepEquiv, sweepEquivRanges ]
13311364End
13321365
13331366/// @brief Check that the 2xN wave allResolvedRanges has only
@@ -1344,29 +1377,21 @@ static Function PSX_CheckResolvedRanges(WAVE allResolvedRanges)
13441377End
13451378
13461379/// @brief Helper function of the `psxStats` operation
1347- static Function/WAVE PSX_OperationStatsImpl ( string graph, string id, WAVE /WAVE ranges, WAVE selectData , string prop, string stateAsStr, string postProc)
1380+ static Function/WAVE PSX_OperationStatsImpl ( string graph, string id, WAVE /WAVE selectDataCompArray , string prop, string stateAsStr, string postProc)
13481381
13491382 string propLabelAxis, comboKey
13501383 variable numEquivChannelNumberTypes, numEquivSweeps, i , j, k, index, sweepNo, chanNr, chanType
1351- variable state, numRanges, lowerBoundary, upperBoundary, temp, err, mapIndex, singleRange
1384+ variable state, numRanges, lowerBoundary, upperBoundary, temp, err, mapIndex
13521385 variable refMarker, idx
13531386
13541387 WAVE /WAVE output = SFH_CreateSFRefWave ( graph, SF_OP_PSX_STATS, MINIMUM_WAVE_SIZE)
13551388
13561389 // create equivalence classes where chanNr/chanType are the same and only the sweep number differs
1357- WAVE selectDataEquiv = PSX_GenerateSweepEquiv ( selectData )
1390+ [ WAVE /T selectDataEquiv, WAVE /WAVE selectDataEquivRanges ] = PSX_GenerateSweepEquiv ( selectDataCompArray )
13581391
13591392 numEquivChannelNumberTypes = DimSize ( selectDataEquiv, ROWS)
13601393 numEquivSweeps = DimSize ( selectDataEquiv, COLS)
13611394
1362- numRanges = DimSize ( ranges, ROWS)
1363- SFH_ASSERT ( numRanges > 0, "Expected at least one range" )
1364- singleRange = ( numRanges == 1 )
1365-
1366- if ( ! singleRange)
1367- SFH_ASSERT ( DimSize ( selectDataEquiv, COLS) == numRanges, "The number of sweeps and ranges differ" )
1368- endif
1369-
13701395 WAVE /Z eventContainerFromResults = PSX_GetEventContainerFromResults ( id)
13711396 WAVE /Z eventContainer = PSX_GetEventContainer ( graph, requestID = id)
13721397
@@ -1389,9 +1414,9 @@ static Function/WAVE PSX_OperationStatsImpl(string graph, string id, WAVE/WAVE r
13891414 singleSelectData[ 0 ][ % CHANNELTYPE] = chanType
13901415 singleSelectData[ 0 ][ % SWEEPMAPINDEX] = mapIndex
13911416
1392- WAVE rangesForSweep = ranges [ singleRange ? 0 : j]
1417+ WAVE ranges = selectDataEquivRanges [ i ][ j]
13931418
1394- [ WAVE resolvedRanges, WAVE /T epochRangeNames] = SFH_GetNumericRangeFromEpochFromSingleSelect ( graph, singleSelectData, rangesForSweep )
1419+ [ WAVE resolvedRanges, WAVE /T epochRangeNames] = SFH_GetNumericRangeFromEpochFromSingleSelect ( graph, singleSelectData, ranges )
13951420
13961421 if ( ! WaveExists ( resolvedRanges))
13971422 continue
@@ -4875,21 +4900,14 @@ Function/WAVE PSX_OperationStats(variable jsonId, string jsonPath, string graph)
48754900 WAVE /Z/ WAVE selectDataCompArray = SFH_GetArgumentSelect ( jsonID, jsonPath, graph, SF_OP_PSX_STATS, 1 )
48764901 SFH_Assert ( WaveExists ( selectDataCompArray) , "Missing select data" )
48774902
4878- SFH_ASSERT ( DimSize ( selectDataCompArray, ROWS) == 1, "Only supports a single selection at the moment" )
4879-
4880- WAVE /WAVE selectDataComp = selectDataCompArray[ 0 ]
4881-
4882- WAVE /Z selectData = selectDataComp[ % SELECTION]
4883- WAVE /WAVE range = selectDataComp[ % RANGE]
4884-
48854903 WAVE allProps = PSX_GetAllStatsProperties ()
48864904 prop = SFH_GetArgumentAsText ( jsonID, jsonPath, graph, SF_OP_PSX_STATS, 2, allowedValues = allProps)
48874905 Make / FREE/ T allStates = { "accept" , "reject" , "undetermined" , "all" , "every" }
48884906 stateAsStr = SFH_GetArgumentAsText ( jsonID, jsonPath, graph, SF_OP_PSX_STATS, 3, allowedValues = allStates)
48894907 Make / FREE/ T allPostProc = { "nothing" , "stats" , "count" , "hist" , "log10" , "nonfinite" }
48904908 postProc = SFH_GetArgumentAsText ( jsonID, jsonPath, graph, SF_OP_PSX_STATS, 4, defValue = "nothing" , allowedValues = allPostProc)
48914909
4892- WAVE /WAVE output = PSX_OperationStatsImpl ( graph, id, range , selectData , prop, stateAsStr, postProc)
4910+ WAVE /WAVE output = PSX_OperationStatsImpl ( graph, id, selectDataCompArray , prop, stateAsStr, postProc)
48934911
48944912 JWN_SetStringInWaveNote ( output, SF_META_OPSTACK, AddListItem ( SF_OP_PSX_STATS, "" ))
48954913
0 commit comments