#include <FKLoop.h>
Public Member Functions | |
| FKLoopTask () | |
| virtual void | setArray (const ArrayStations &array) |
| virtual void | setGrid () |
| void | setLoop (const FKLoop *l) |
| void | setParameters (const FKParameters *param) |
| ~FKLoopTask () | |
Protected Member Functions | |
| void | exportGrid (QString baseName, int iOmega, int iWin) |
| virtual void | exportMax () |
| void | exportResults (const Point2D &pos) |
| virtual void | getPower (const Point2D &pos, double &beampower, double &semblance) |
| virtual void | initGridValues () |
| virtual void | run (int index) |
Protected Attributes | |
| int | _currentComponent |
| FKGridSearch * | _grid [3] |
| const FKLoop * | _loop |
| int | _nStations |
| double | _nStations2 |
| FKArrayProcess * | _process |
| const TimeRange * | _win |
References _grid, _loop, _process, FKLoop::hasComponent(), ArrayCore::ArrayProcess::takeParameters(), and TRACE.
{
TRACE;
for(int iComp=0; iComp<3; iComp++) {
if(_loop->hasComponent(iComp)) {
delete _grid[iComp];
}
}
// Parameters are not owned by process
_process->takeParameters();
delete _process;
}
| void FKLoopTask::exportGrid | ( | QString | baseName, |
| int | iOmega, | ||
| int | iWin | ||
| ) | [protected] |
References _currentComponent, _grid, MSG_ID, QGpCoreTools::tr(), and TRACE.
Referenced by run().
{
TRACE;
IrregularGrid2D exportGrid;
exportGrid=* _grid[_currentComponent];
QString fileName=baseName.arg(iOmega,3,10,QChar('0')).arg(iWin,3,10,QChar('0'));
QFile f(fileName);
if(f.open(QIODevice::WriteOnly)) {
QTextStream s(&f);
s << exportGrid;
} else {
Message::warning(MSG_ID, tr( "Export FK grid values" ),
tr("Cannot write to file %1").arg(fileName), true);
}
}
| void FKLoopTask::exportMax | ( | ) | [protected, virtual] |
References _currentComponent, _grid, _process, _win, ArrayCore::FKParameters::absoluteThreshold(), exportResults(), ArrayCore::ArrayProcess::frequency(), ArrayCore::FKGridSearch::function(), initGridValues(), GeopsyCore::TimeRange::lengthSeconds(), QGpCoreTools::GridSearch::localMax(), QGpCoreTools::Function2Search::localMaxEnd(), ArrayCore::FKParameters::maximumPeakCount(), ArrayCore::FKArrayProcess::parameters(), ArrayCore::FKParameters::relativeThreshold(), ArrayCore::FK::setFrequencyBand(), and TRACE.
Referenced by run().
{
TRACE;
_grid[_currentComponent]->function()->setFrequencyBand(_process->frequency(), _win->lengthSeconds());
initGridValues();
const FKParameters * param=_process->parameters();
if(param->maximumPeakCount()>1) {
Function2MaximaIterator it=_grid[_currentComponent]->localMax(param->maximumPeakCount() ,
param->absoluteThreshold(),
param->relativeThreshold());
for( ;it!=_grid[_currentComponent]->localMaxEnd();++it) {
exportResults(it->pos());
}
} else {
if(_grid[_currentComponent]->globalMax()>param->absoluteThreshold()) {
exportResults(_grid[_currentComponent]->pos());
}
}
}
| void FKLoopTask::exportResults | ( | const Point2D & | pos | ) | [protected] |
References _currentComponent, _loop, _process, _win, QGpCoreTools::Point2D::azimuthTo(), ArrayCore::FrequencyBand::center(), QGpCoreTools::Point2D::distanceTo(), ArrayCore::ArrayProcess::frequency(), getPower(), FKLoop::lockOutput(), FKLoop::output(), GeopsyCore::TimeRange::start(), TRACE, and FKLoop::unlockOutput().
Referenced by exportMax().
{
TRACE;
Point2D origin(0, 0);
double slowness=origin.distanceTo(pos);
const FrequencyBand& fb=_process->frequency();
slowness/=2.0*M_PI*fb.center();
double mathang=origin.azimuthTo(pos);
double azimuth=Angle::mathToGeographic(mathang);
mathang=Angle::radiansToDegrees(mathang);
double beampower, semblance;
getPower(pos, beampower, semblance);
_loop->lockOutput(_currentComponent);
QTextStream * s=new QTextStream(_loop->output(_currentComponent));
(*s) << _win->start() << " "
<< fb.center() << " "
<< slowness*1000.0 << " "
<< azimuth << " "
<< mathang << " "
<< semblance << " "
<< beampower << "\n";
delete s;
_loop->unlockOutput(_currentComponent);
}
| void FKLoopTask::getPower | ( | const Point2D & | pos, |
| double & | beampower, | ||
| double & | semblance | ||
| ) | [protected, virtual] |
Reimplemented in HRFKLoopTask.
References _currentComponent, _grid, _nStations, _nStations2, _process, ArrayCore::FK::absolutePower(), ArrayCore::FrequencyBand::center(), ArrayCore::ArrayProcess::frequency(), ArrayCore::FKGridSearch::function(), TRACE, ArrayCore::FK::value(), ArrayCore::FrequencyBand::width(), QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().
Referenced by exportResults().
{
TRACE;
const FK * fk=_grid[_currentComponent]->function();
beampower=fk->value(pos.x(), pos.y());
semblance=beampower/fk->absolutePower(_currentComponent);
// Normalizations by number of stations or band width
const FrequencyBand& fb=_process->frequency();
double freqBandWidth=fb.width();
if(freqBandWidth > 0.0) {
beampower=10.0 * log10(beampower/(freqBandWidth * _nStations2) );
semblance /= _nStations;
} else {
beampower=10.0 * log10(beampower/(fb.center() * _nStations2) );
semblance /= _nStations;
}
}
| virtual void FKLoopTask::initGridValues | ( | ) | [inline, protected, virtual] |
| void FKLoopTask::run | ( | int | index | ) | [protected, virtual] |
Implements QGpCoreTools::LoopTask.
Reimplemented in LinearFKPassiveLoopTask.
References _currentComponent, _loop, _process, _win, FKLoop::addLog(), GeopsyCore::TimeRangeList::at(), GeopsyCore::TimeRangeList::count(), QGpCoreTools::LoopTask::endIndex(), ArrayCore::FKParameters::exportAllFKGrids(), exportGrid(), exportMax(), FKLoop::hasComponent(), ArrayCore::ArrayProcess::lockTimeWindow(), ArrayCore::FKArrayProcess::parameters(), ArrayCore::ArrayProcess::setFrequency(), QGpCoreTools::LoopTask::setProgressMaximum(), QGpCoreTools::LoopTask::setProgressValue(), QGpCoreTools::LoopTask::setStatus(), QGpCoreTools::LoopTask::terminated(), ArrayCore::ArrayProcess::timeRangeList(), TRACE, and ArrayCore::ArrayProcess::unlockTimeWindow().
{
TRACE;
// Revert the order: start with expensive high frequencies
// When the number of cores increases and tends to the number
// of frequencies, it is more efficient to start with with the
// most expensive frequencies.
index=endIndex()-index-1;
QString freqLog, freqStatus;
_process->setFrequency(index, &freqLog, &freqStatus);
setStatus(freqStatus);
_loop->addLog(freqLog);
// Loop over all time windows
const TimeRangeList& winList=*_process->timeRangeList();
int nWin=winList.count();
setProgressMaximum(nWin);
for(int iWin=0;iWin < nWin; iWin++ ) {
if(terminated()) break;
setProgressValue(iWin);
_win=&winList.at(iWin);
if( !_process->lockTimeWindow(_win) ) continue;
for(_currentComponent=0; _currentComponent<3; _currentComponent++) {
if(_loop->hasComponent(_currentComponent)) {
exportMax();
}
}
// Special option for research or debug only (accessible only from command line interface)
if(_process->parameters()->exportAllFKGrids()) {
if(_loop->hasComponent(0)) {
_currentComponent=0;
exportGrid("fkgrid_vertical_f%1_tw%2", index, iWin);
}
if(_loop->hasComponent(1)) {
_currentComponent=1;
exportGrid("fkgrid_radial_f%1_tw%2", index, iWin);
_currentComponent=2;
exportGrid("fkgrid_transverse_f%1_tw%2", index, iWin);
}
}
_process->unlockTimeWindow();
}
}
| void FKLoopTask::setArray | ( | const ArrayStations & | array | ) | [virtual] |
Reimplemented in HRFKLoopTask.
References _process, ArrayCore::ArrayProcess::setTimeRangeList(), and TRACE.
Referenced by FKLoop::newTask(), and LinearFKPassiveLoop::newTask().
{
TRACE;
_process=new FKArrayProcess(array);
_process->setTimeRangeList(new TimeWindowList);
}
| void FKLoopTask::setGrid | ( | ) | [virtual] |
Reimplemented in HRFKLoopTask.
References _grid, _loop, _process, ArrayCore::FKArrayProcess::function(), ArrayCore::FKGridSearch::function(), FKLoop::hasComponent(), ArrayCore::FKParameters::maximumSlowness(), ArrayCore::FKParameters::maximumWaveNumber(), ArrayCore::FKParameters::minimumWaveNumber(), ArrayCore::FKArrayProcess::parameters(), ArrayCore::FKGridSearch::setFunction(), ArrayCore::FKGridSearch::setGrid(), ArrayCore::FK::setMaximumSlowness(), and TRACE.
Referenced by FKLoop::newTask().
{
TRACE;
for(int iComp=0; iComp<3; iComp++) {
if(_loop->hasComponent(iComp)) {
_grid[iComp]=new FKGridSearch;
_grid[iComp]->setFunction(_process->function(iComp));
const FKParameters * param=_process->parameters();
_grid[iComp]->setGrid(param->minimumWaveNumber(), param->maximumWaveNumber());
_grid[iComp]->function()->setMaximumSlowness(param->maximumSlowness());
}
}
}
| void FKLoopTask::setLoop | ( | const FKLoop * | l | ) | [inline] |
References _loop.
Referenced by HRFKLoop::newTask(), FKLoop::newTask(), and LinearFKPassiveLoop::newTask().
{_loop=l;}
| void FKLoopTask::setParameters | ( | const FKParameters * | param | ) |
References _nStations, _nStations2, _process, ArrayCore::FKArrayProcess::setParameters(), ArrayCore::ArrayProcess::stations(), and TRACE.
Referenced by HRFKLoop::newTask(), FKLoop::newTask(), and LinearFKPassiveLoop::newTask().
{
TRACE;
// TODO: take return value into account
_process->setParameters(param, true);
_nStations=_process->stations().count();
_nStations2=_nStations;
_nStations2*=_nStations;
}
int FKLoopTask::_currentComponent [protected] |
FKGridSearch* FKLoopTask::_grid[3] [protected] |
const FKLoop* FKLoopTask::_loop [protected] |
Referenced by exportResults(), LinearFKPassiveLoopTask::run(), run(), HRFKLoopTask::setGrid(), setGrid(), setLoop(), and ~FKLoopTask().
int FKLoopTask::_nStations [protected] |
Referenced by getPower(), and setParameters().
double FKLoopTask::_nStations2 [protected] |
Referenced by HRFKLoopTask::getPower(), getPower(), and setParameters().
FKArrayProcess* FKLoopTask::_process [protected] |
Referenced by exportMax(), exportResults(), FKLoopTask(), HRFKLoopTask::getPower(), getPower(), HRFKLoopTask::initGridValues(), LinearFKPassiveLoopTask::run(), run(), HRFKLoopTask::setArray(), setArray(), LinearFKPassiveLoopTask::setGrid(), HRFKLoopTask::setGrid(), setGrid(), setParameters(), and ~FKLoopTask().
const TimeRange* FKLoopTask::_win [protected] |
Referenced by exportMax(), exportResults(), LinearFKPassiveLoopTask::run(), and run().