References QGpCoreTools::abs(), GeopsyCore::TimeRangeParameters::absoluteRange(), SciFigs::IrregularGrid2DPlot::boundingRect(), CONST_LOCK_SAMPLES, GeopsyCore::DoubleSignal::copySamplesFrom(), QGpCoreTools::SamplingParameters::count(), SciFigs::AxisWindow::deepUpdate(), GeopsyCore::DoubleSignal::deltaT(), TFAParameters::frequencySampling(), GeopsyCore::geopsyCore, SciFigs::GraphContentLayer::graph(), GeopsyCore::TimeRange::lengthSamples(), GeopsyCore::TimeRange::lengthSeconds(), GeopsyCore::DoubleSignal::morletWavelet(), MSG_ID, GeopsyCore::Signal::nameComponent(), TFAParameters::range(), GeopsyCore::DoubleSignal::setDeltaT(), GeopsyCore::MorletParameters::setFi(), SciFigs::IrregularGrid2DPlot::setGrid(), SciFigs::IrregularGrid2DPlot::setLinearPalette(), SciFigs::Axis::setRange(), SciFigs::GridPlot::setSmooth(), QGpCoreTools::IrregularGrid2D::setValue(), QGpCoreTools::IrregularGrid2D::setX(), QGpCoreTools::IrregularGrid2D::setY(), GeopsyCore::GeopsyCoreEngine::showMessage(), GeopsyCore::TimeRange::start(), GeopsyCore::Signal::t0(), QGpCoreTools::tr(), TRACE, TRACE_BUG, TRACE_BUG_INT, UNLOCK_SAMPLES, QGpCoreTools::SamplingParameters::value(), w, TFAParameters::wavelet(), QGpCoreTools::Rect::x1(), QGpCoreTools::Rect::x2(), SciFigs::AxisWindow::xAxis(), QGpCoreTools::Rect::y1(), QGpCoreTools::Rect::y2(), and SciFigs::AxisWindow::yAxis().
{
TRACE;
IrregularGrid2DPlot * plot =_gridLayers[ig];
int nFreq=param.frequencySampling().count();
TimeRange tw=param.range().absoluteRange(sig);
int nTime=tw.lengthSamples(sig->deltaT());
if(nTime<=0) {
Message::warning(MSG_ID, tr("Time Frequency Analysis"),
tr("Specified time range does not contain any signal (%1).").arg(sig->nameComponent()),
Message::ignore(), true);
return;
}
TRACE_BUG;
TRACE_BUG_INT(_gridLayers.count());
TRACE_BUG_INT(nFreq);
TRACE_BUG_INT(nTime);
if(nTime*nFreq*_gridLayers.count()>64*1024*1024) {
qWarning("Excessive memory consumption warning: nGraph=%i, nFreq=%i, nTime=%i\n", _gridLayers.count(), nFreq, nTime);
Message::warning(MSG_ID, tr("Time Frequency Analysis"),
tr("Time range is probably too large for signal %4 (%5=%6 samples). Given the number of signals (%1), "
"the number of frequency samples (%2), the maximum number of time samples is %3. "
"That corresponds to a total memory consumption of 512 Mb. Contact the developpers "
"if you think that this limit is obsolete according to current computer memories.")
.arg(_gridLayers.count())
.arg(nFreq)
.arg(round(64.0*1024*1024/_gridLayers.count()/nFreq))
.arg(sig->nameComponent())
.arg(Number::secondsToTime(tw.lengthSeconds(), Number::Weeks, 0))
.arg(nTime), Message::ignore(), true);
return;
}
DoubleSignal * sigProc=new DoubleSignal(nTime);
sigProc->setDeltaT(sig->deltaT());
sigProc->copySamplesFrom(sig, tw.start()-sig->t0(), 0.0, tw.lengthSeconds());
IrregularGrid2D grid(nTime, nFreq);
for(int iTime=0; iTime<nTime; iTime++ ) {
grid.setX(iTime, sig->t0()+iTime*sig->deltaT());
}
for(int iFreq=0; iFreq<nFreq; iFreq++ ) {
double f=param.frequencySampling().value(iFreq);
grid.setY(iFreq, f);
geopsyCore->showMessage(tr("Signal %1 : Morlet wavelet convolution at %2 Hz")
.arg(sig->nameComponent()).arg(f));
param.wavelet().setFi(f);
ComplexSignal * w=sigProc->morletWavelet(param.wavelet());
CONST_LOCK_SAMPLES(Complex, wSamples, w)
for(int iTime=0; iTime<nTime; iTime++ ) {
grid.setValue(iTime, iFreq, wSamples[iTime].abs());
}
UNLOCK_SAMPLES(w)
delete w;
}
plot->setSmooth(true);
plot->setGrid(grid);
plot->setLinearPalette(0.0);
Rect r=plot->boundingRect();
AxisWindow * w=plot->graph();
w->xAxis()->setRange(r.x1(), r.x2());
w->yAxis()->setRange(r.y1(), r.y2());
w->deepUpdate();
delete sigProc;
}