Skip to content

Commit 6568ba9

Browse files
Timothee Chabatkwrobot
authored andcommitted
Merge topic 'correct-tablefft-properties'
8019104 TableFFT: add backward compatibility for new properties edfe3c6 TableFFT: Update testing and baseline 4987d4e Make 'Frequency' a first-class citizen array for charts 76e28af TableFFT: expose correct API for proxy Acked-by: Kitware Robot <[email protected]> Acked-by: Mathieu Westphal <[email protected]> Acked-by: Tiffany Chhim <[email protected]> Merge-request: !6045
2 parents af2fbde + 8019104 commit 6568ba9

File tree

9 files changed

+165
-54
lines changed

9 files changed

+165
-54
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
183e7d3a8d12b137501347a604682898b8c702ee65f531bd309955eecee4715aebeca91c7dcf7b29c68804376187c2223b777c4c7e4a5f50676e57d5c2a5c356
1+
19b1416d47a2e25c28e35e773f1b444dfd7763a2e16f287992383b3b657af89d74e67e750415217a6f713c343e0ec35a0e508691c58707d56645a4b42182632a
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
da0cc9e935afbea212c2795bcb7b292c77376b497edfd1ef335b480a42f755684ee7a8a11e9cf509a2045b37e499717482208916d37571145cee483a55f55c77
1+
3c3b63fa16bad315c21d8a4d2d7aca11e13057752f3e35497db874533e185621a73b724f04957b990891b7a36aee69e4750160712707a0271ee706e6699d609f

Clients/ParaView/Testing/XML/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,6 @@ if(PARAVIEW_USE_PYTHON)
14691469
SelectionLinkScripting.xml
14701470
SelectPointsTrace.xml
14711471
SplitViewTrace.xml
1472-
TestTableFFT.xml
14731472
TraceMultiViews.xml
14741473
)
14751474
set(SelectCellsTrace_DISABLE_CRS TRUE)
@@ -1525,7 +1524,9 @@ if(PARAVIEW_USE_PYTHON)
15251524

15261525
list(APPEND TESTS_WITH_INLINE_COMPARES
15271526
FindDataTrace.xml
1528-
FindDataQueries.xml)
1527+
FindDataQueries.xml
1528+
TestTableFFT.xml # needs programmable filter + numpy
1529+
)
15291530

15301531
# PythonAlgorithm plugin tests.
15311532
configure_file(

Clients/ParaView/Testing/XML/TestTableFFT.xml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,14 @@
55
<pqevent object="pqClientMainWindow/menubar/menuSources/Alphabetical" command="activate" arguments="ProgrammableSource" />
66
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/OutputDataSetType/ComboBox" command="activated" arguments="vtkTable" />
77
<!-- Create a table. Script is :
8-
obj = self.GetTableOutput()
9-
time = vtk.vtkDoubleArray()
10-
time.SetName("Time")
11-
data = vtk.vtkDoubleArray()
12-
data.SetName("Data")
13-
obj.AddColumn(time)
14-
obj.AddColumn(data)
15-
gc = vtk.vtkMultiProcessController.GetGlobalController()
16-
if gc.GetLocalProcessId() == 0:
17-
time.InsertNextValue(0.0)
18-
time.InsertNextValue(0.2)
19-
time.InsertNextValue(0.4)
20-
time.InsertNextValue(0.6)
21-
data.InsertNextValue(1.0)
22-
data.InsertNextValue(1.0)
23-
data.InsertNextValue(1.0)
24-
data.InsertNextValue(1.0)
8+
time = numpy.linspace(0, 1, 10000, endpoint=False)
9+
signal = numpy.sin(2 * numpy.pi * 1000 * time)
10+
output.RowData.append(time, "Time")
11+
output.RowData.append(signal, "Signal")
2512
-->
2613
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/Script/Script"
2714
command="set_string"
28-
arguments="obj = self.GetTableOutput()&#xA;time = vtk.vtkDoubleArray()&#xA;time.SetName(&quot;Time&quot;)&#xA;data = vtk.vtkDoubleArray()&#xA;data.SetName(&quot;Data&quot;)&#xA;obj.AddColumn(time)&#xA;obj.AddColumn(data)&#xA;gc = vtk.vtkMultiProcessController.GetGlobalController()&#xA;if gc.GetLocalProcessId() == 0:&#xA; time.InsertNextValue(0.0)&#xA; time.InsertNextValue(0.2)&#xA; time.InsertNextValue(0.4)&#xA; time.InsertNextValue(0.6)&#xA; data.InsertNextValue(1.0)&#xA; data.InsertNextValue(1.0)&#xA; data.InsertNextValue(1.0)&#xA; data.InsertNextValue(1.0)"/>
15+
arguments="time = numpy.linspace(0, 1, 10000, endpoint=False)&#xA;signal = numpy.sin(2 * numpy.pi * 1000 * time)&#xA;output.RowData.append(time, &quot;Time&quot;)&#xA;output.RowData.append(signal, &quot;Signal&quot;)"/>
2916
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
3017
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.1/Close" command="activate" arguments="" />
3118

@@ -36,7 +23,7 @@ if gc.GetLocalProcessId() == 0:
3623
<pqcompareview object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.2/CentralWidgetFrame/Viewport" baseline="$PARAVIEW_DATA_ROOT/Clients/ParaView/Testing/Data/Baseline/TableFFT1.png" width="400" height="400" />
3724

3825
<!-- Check optimize for real input otion -->
39-
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/OptimizeForRealInput/CheckBox" command="set_boolean" arguments="true" />
26+
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/OneSidedSpectrum/CheckBox" command="set_boolean" arguments="true" />
4027
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
4128
<pqcompareview object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.2/CentralWidgetFrame/Viewport" baseline="$PARAVIEW_DATA_ROOT/Clients/ParaView/Testing/Data/Baseline/TableFFT2.png" width="400" height="400" />
4229
</pqevents>

Remoting/Application/Resources/filters_filtersgeneral.xml

Lines changed: 72 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,8 +2647,19 @@
26472647
</Documentation>
26482648
</IntVectorProperty>
26492649

2650+
<DoubleVectorProperty name="DefaultSampleRate"
2651+
command="SetDefaultSampleRate"
2652+
number_of_elements="1"
2653+
default_values="10000">
2654+
<DoubleRangeDomain name="range" min="10" max="100000" />
2655+
<Documentation>
2656+
If the "Time" column is not found then this value will be used as the sample rate of the input.
2657+
</Documentation>
2658+
</DoubleVectorProperty>
2659+
26502660
<IntVectorProperty name="WindowingFunction"
26512661
command="SetWindowingFunction"
2662+
panel_visibility="advanced"
26522663
number_of_elements="1"
26532664
default_values="4">
26542665
<EnumerationDomain name="enum">
@@ -2660,14 +2671,13 @@
26602671
</EnumerationDomain>
26612672
<Documentation>
26622673
Specify the windowing function to apply on the input. This allows to better process
2663-
data that is not periodic. When NumberOfBlocks > 1, the windowing function is applied
2664-
to each block.
2674+
data that is not periodic. When Welch method is used, the window is applied to each frame.
26652675
</Documentation>
26662676
</IntVectorProperty>
26672677

2668-
<IntVectorProperty name="OptimizeForRealInput"
2669-
command="SetOptimizeForRealInput"
2670-
panel_visibility="advanced"
2678+
<IntVectorProperty name="OneSidedSpectrum"
2679+
command="SetReturnOnesided"
2680+
panel_visibility="default"
26712681
number_of_elements="1"
26722682
default_values="0">
26732683
<BooleanDomain name="bool" />
@@ -2684,59 +2694,92 @@
26842694
default_values="0">
26852695
<BooleanDomain name="bool" />
26862696
<Documentation>
2687-
Specify if the output should be normalized.
2697+
Specify if the output should be normalized. Only used if UseWelchMethod is false.
26882698
</Documentation>
2699+
<Hints>
2700+
<PropertyWidgetDecorator type="GenericDecorator"
2701+
mode="visibility"
2702+
property="AverageFft"
2703+
value="0" />
2704+
</Hints>
26892705
</IntVectorProperty>
26902706

2691-
<IntVectorProperty name="AverageFft"
2707+
<IntVectorProperty name="UseWelchMethod"
26922708
command="SetAverageFft"
2693-
label="Average FFT per block"
26942709
panel_visibility="advanced"
26952710
number_of_elements="1"
26962711
default_values="0">
26972712
<BooleanDomain name="bool" />
26982713
<Documentation>
2699-
Specify if the input should be split in multiple blocks to compute
2700-
an average fft across all blocks.
2714+
Specify if filter should use the Welch / periodogram method. If true the
2715+
input will be split in multiple segment to compute an average fft across
2716+
all segments / blocks. This can be faster for input with lots of samples
2717+
and also remove some noise.
27012718
</Documentation>
27022719
</IntVectorProperty>
27032720

2704-
<IntVectorProperty name="NumberOfBlock"
2705-
command="SetNumberOfBlock"
2721+
<IntVectorProperty name="BlockSize"
2722+
command="SetBlockSize"
27062723
panel_visibility="advanced"
27072724
number_of_elements="1"
2708-
default_values="2">
2725+
default_values="1024">
27092726
<Documentation>
2710-
Specify the number of blocks to use when computing the average fft over
2711-
the whole input sample array. If NumberOfBlock == 1, no average is done
2712-
and we only compute the fft on the first BlockSize samples of the input data.
2727+
Specify the number of samples to use for each block / segment in the Welch method.
2728+
This should be a power of 2 in order to achieve better performance.
27132729
</Documentation>
2730+
</IntVectorProperty>
27142731

2715-
<Hints>
2716-
<PropertyWidgetDecorator type="GenericDecorator"
2717-
mode="visibility"
2718-
property="AverageFft"
2719-
value="1" />
2720-
</Hints>
2732+
<IntVectorProperty name="BlockOverlap"
2733+
command="SetBlockOverlap"
2734+
panel_visibility="advanced"
2735+
number_of_elements="1"
2736+
default_values="-1">
2737+
<Documentation>
2738+
Specify the number of samples which will overlap between each block / segment.
2739+
If value is not in a valid range (ie inferior to 0 or superior to BlockSize) then the
2740+
value BlockSize / 2 will be used. Only used if UseWelchMethod is true.
2741+
</Documentation>
27212742
</IntVectorProperty>
27222743

2723-
<IntVectorProperty name="BlockSize"
2724-
command="SetBlockSize"
2744+
<IntVectorProperty name="ScalingMethod"
2745+
command="SetScalingMethod"
27252746
panel_visibility="advanced"
27262747
number_of_elements="1"
2727-
default_values="1024">
2748+
default_values="0">
2749+
<EnumerationDomain name="enum">
2750+
<Entry value="0" text="Density"/>
2751+
<Entry value="1" text="Spectrum"/>
2752+
</EnumerationDomain>
2753+
<Documentation>
2754+
Set what scaling should be used when applying the Welch method.
2755+
</Documentation>
2756+
</IntVectorProperty>
2757+
2758+
<IntVectorProperty name="Detrend"
2759+
command="SetDetrend"
2760+
panel_visibility="advanced"
2761+
number_of_elements="1"
2762+
default_values="0">
2763+
<BooleanDomain name="bool" />
27282764
<Documentation>
2729-
Specify the number of samples to use for each block. This should be a power of 2.
2730-
If not, the closest power of two will be used anyway.
2765+
Remove trend on each segment before applying the FFT. This is a constant
2766+
detrend where the mean of the signal is substracted to the signal.
2767+
Only used if UseWelchMethod is true.
27312768
</Documentation>
2769+
</IntVectorProperty>
27322770

2771+
<PropertyGroup label="Welch Method Parameters" panel_visibility="advanced" >
2772+
<Property name="BlockSize" />
2773+
<Property name="BlockOverlap" />
2774+
<Property name="ScalingMethod" />
2775+
<Property name="Detrend" />
27332776
<Hints>
27342777
<PropertyWidgetDecorator type="GenericDecorator"
27352778
mode="visibility"
2736-
property="AverageFft"
2779+
property="UseWelchMethod"
27372780
value="1" />
27382781
</Hints>
2739-
</IntVectorProperty>
2782+
</PropertyGroup>
27402783

27412784
<Hints>
27422785
<PipelineIcon name="XYChartView" />

Remoting/ServerManager/vtkSMStateVersionController.cxx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,39 @@ struct Process_5_10_to_5_11
14491449
}
14501450
};
14511451

1452+
struct Process_5_11_to_5_12
1453+
{
1454+
bool operator()(xml_document& document) { return ConvertTableFFT(document); }
1455+
1456+
static bool ConvertTableFFT(xml_document& document)
1457+
{
1458+
pugi::xpath_node_set xpath_set =
1459+
document.select_nodes("//ServerManagerState/Proxy[@group='filters' and @type='TableFFT']");
1460+
1461+
for (auto xpath_node : xpath_set)
1462+
{
1463+
auto node = xpath_node.node();
1464+
1465+
if (auto averageNode = node.find_child_by_attribute("name", "AverageFft"))
1466+
{
1467+
averageNode.attribute("name").set_value("UseWelchMethod");
1468+
}
1469+
1470+
if (auto optimizeNode = node.find_child_by_attribute("name", "OptimizeForRealInput"))
1471+
{
1472+
optimizeNode.attribute("name").set_value("OneSidedSpectrum");
1473+
}
1474+
1475+
if (auto nblockNode = node.find_child_by_attribute("name", "NumberOfBlock"))
1476+
{
1477+
node.remove_child(nblockNode);
1478+
}
1479+
}
1480+
1481+
return true;
1482+
}
1483+
};
1484+
14521485
} // end of namespace
14531486

14541487
vtkStandardNewMacro(vtkSMStateVersionController);
@@ -1563,6 +1596,13 @@ bool vtkSMStateVersionController::Process(vtkPVXMLElement* parent, vtkSMSession*
15631596
version = vtkSMVersion(5, 11, 0);
15641597
}
15651598

1599+
if (status && (version < vtkSMVersion(5, 12, 0)))
1600+
{
1601+
Process_5_11_to_5_12 converter;
1602+
status = converter(document);
1603+
version = vtkSMVersion(5, 12, 0);
1604+
}
1605+
15661606
if (status)
15671607
{
15681608
std::ostringstream stream2;

Remoting/Views/vtkSMChartSeriesListDomain.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ int vtkSMChartSeriesListDomain::ReadXMLAttributes(vtkSMProperty* prop, vtkPVXMLE
152152
const char** vtkSMChartSeriesListDomain::GetKnownSeriesNames()
153153
{
154154
static const char* strings_to_check[] = { "bin_extents", "Time", "time", "arc_length", "XArray",
155-
"x_array", nullptr };
155+
"x_array", "Frequency", nullptr };
156156
return strings_to_check;
157157
}
158158
//----------------------------------------------------------------------------

Remoting/Views/vtkSMChartSeriesSelectionDomain.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static void InitSeriesVisibilityDefaults()
5858
const char* defaults[] = { "^arc_length", "^bin_extents", "^FileId", "^GlobalElementId",
5959
"^GlobalNodeId", "^ObjectId", "^object_id", "^Pedigree.*", "^Points_.*", "^Time",
6060
"^vtkOriginal.*", "^ids$", "^ids .*", "^vtkValidPointMask", "^N .*", "^X$", "^X .*", "^Y$",
61-
"^Y .*", "^Z$", "^Z .*", "^vtkGhostType$", nullptr };
61+
"^Y .*", "^Z$", "^Z .*", "^vtkGhostType$", "^Frequency$", nullptr };
6262
for (int cc = 0; defaults[cc] != nullptr; cc++)
6363
{
6464
SeriesVisibilityDefaults.push_back(

Wrapping/Python/paraview/_backwardscompatibilityhelper.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,27 @@ def setattr(proxy, pname, value):
407407
raise NotSupportedException("'StaticMesh' is obsolete. Use 'MeshOverTime' property of " +
408408
proxy.SMProxy.GetXMLName() + " filter instead.")
409409

410+
# 5.11 -> 5.12 breaking changes on "TableFFT" properties
411+
# Renamed AverageFFTperblock into UseWelchMethod
412+
# Renamed OptimizeForRealInput into OneSidedSpectrum
413+
# Removed NumberOfBlock
414+
if proxy.SMProxy and proxy.SMProxy.GetXMLName() == "TableFFT":
415+
isOldVersion = paraview.compatibility.GetVersion() < (5, 12)
416+
if pname == "AverageFFTperblock":
417+
if isOldVersion:
418+
proxy.GetProperty("UseWelchMethod").SetData(value)
419+
raise Continue()
420+
else:
421+
raise NotSupportedException("'AverageFFTperblock' is obsolete. Use 'UseWelchMethod' property instead.")
422+
elif pname == "OptimizeForRealInput":
423+
if isOldVersion:
424+
proxy.GetProperty("OneSidedSpectrum").SetData(value)
425+
raise Continue()
426+
else:
427+
raise NotSupportedException("'OptimizeForRealInput' is obsolete. Use 'OneSidedSpectrum' property instead.")
428+
elif pname == "NumberOfBlock" and not isOldVersion:
429+
raise NotSupportedException("'NumberOfBlock' is obsolete. See 'BlockOverlap' property instead.")
430+
410431
if not hasattr(proxy, pname):
411432
raise AttributeError()
412433
proxy.__dict__[pname] = value
@@ -859,6 +880,25 @@ def getattr(proxy, pname):
859880
raise NotSupportedException(
860881
"Since ParaView 5.11, 'UseGeometryFilter' has been removed. ")
861882

883+
# 5.11 -> 5.12 breaking changes on "TableFFT" properties
884+
# Renamed AverageFFTperblock into UseWelchMethod
885+
# Renamed OptimizeForRealInput into OneSidedSpectrum
886+
# Removed NumberOfBlock
887+
if proxy.SMProxy and proxy.SMProxy.GetXMLName() == "TableFFT":
888+
isOldVersion = paraview.compatibility.GetVersion() < (5, 12)
889+
if pname == "AverageFFTperblock":
890+
if isOldVersion:
891+
return proxy.GetProperty("UseWelchMethod").GetData()
892+
else:
893+
raise NotSupportedException("'AverageFft' is obsolete. Use 'UseWelchMethod' property instead.")
894+
elif pname == "OptimizeForRealInput":
895+
if isOldVersion:
896+
return proxy.GetProperty("OneSidedSpectrum").GetData()
897+
else:
898+
raise NotSupportedException("'OptimizeForRealInput' is obsolete. Use 'OneSidedSpectrum' property instead.")
899+
elif pname == "NumberOfBlock" and not isOldVersion:
900+
raise NotSupportedException("'NumberOfBlock' is obsolete. See 'BlockOverlap' property instead.")
901+
862902
raise Continue()
863903

864904
# Depending on the compatibility version that has been set, older functionalities

0 commit comments

Comments
 (0)