------------------------------------------------------------------------------
| 207 | |
| 208 | //------------------------------------------------------------------------------ |
| 209 | void vtkTableFFT::Initialize(vtkTable* input) |
| 210 | { |
| 211 | // Find time array and compute sample rate |
| 212 | const std::size_t nsamples = input->GetNumberOfRows(); |
| 213 | vtkDataArray* timeArray = nullptr; |
| 214 | bool complexColumnFound = false; |
| 215 | for (vtkIdType col = 0; col < input->GetNumberOfColumns(); col++) |
| 216 | { |
| 217 | vtkAbstractArray* column = input->GetColumn(col); |
| 218 | |
| 219 | if (vtksys::SystemTools::Strucmp(column->GetName(), "time") == 0) |
| 220 | { |
| 221 | timeArray = vtkDataArray::SafeDownCast(input->GetColumn(col)); |
| 222 | } |
| 223 | |
| 224 | complexColumnFound |= (column->GetNumberOfComponents() == 2); |
| 225 | } |
| 226 | |
| 227 | if (this->ReturnOnesided && complexColumnFound) |
| 228 | { |
| 229 | vtkWarningMacro("ReturnOnesided is True but found columns with 2 components" |
| 230 | " (interpreted as imaginary data). Imaginary columns will be ignored."); |
| 231 | } |
| 232 | |
| 233 | if (timeArray && timeArray->GetNumberOfTuples() > 1) |
| 234 | { |
| 235 | double deltaT = timeArray->GetTuple1(1) - timeArray->GetTuple1(0); |
| 236 | this->Internals->SampleRate = 1.0 / deltaT; |
| 237 | } |
| 238 | else |
| 239 | { |
| 240 | this->Internals->SampleRate = this->DefaultSampleRate; |
| 241 | } |
| 242 | |
| 243 | // Check if we can average and compute the size of the windowing function |
| 244 | std::size_t nfft = nsamples; |
| 245 | if (this->AverageFft) |
| 246 | { |
| 247 | nfft = std::min(static_cast<std::size_t>(this->BlockSize), nsamples); |
| 248 | } |
| 249 | |
| 250 | // Generate windowing function |
| 251 | // We're caching the windowing function for more efficiency when applying this filter |
| 252 | // on different tables multiple times |
| 253 | if (this->Internals->WindowLastUpdated < this->Internals->WindowTimeStamp.GetMTime() || |
| 254 | nfft != this->Internals->Window.size()) |
| 255 | { |
| 256 | this->Internals->UpdateWindow(this->WindowingFunction, nfft); |
| 257 | this->Internals->WindowLastUpdated = this->Internals->WindowTimeStamp.GetMTime(); |
| 258 | } |
| 259 | |
| 260 | // Get output size |
| 261 | this->Internals->OutputSize = this->ReturnOnesided ? (nfft / 2) + 1 : nfft; |
| 262 | } |
| 263 | |
| 264 | //------------------------------------------------------------------------------ |
| 265 | vtkSmartPointer<vtkDataArray> vtkTableFFT::DoFFT(vtkDataArray* input) |