Public Member Functions | Protected Member Functions | Protected Attributes
FKLoopTask Class Reference

#include <FKLoop.h>

Inheritance diagram for FKLoopTask:
QGpCoreTools::LoopTask QGpCoreTools::Thread HRFKLoopTask LinearFKPassiveLoopTask

List of all members.

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

Constructor & Destructor Documentation

References _process, and TRACE.

{
  TRACE;
  _process=0;
}

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;
}

Member Function Documentation

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]
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]

Reimplemented in HRFKLoopTask.

Referenced by exportMax().

{}
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]
void FKLoopTask::setGrid ( ) [virtual]
void FKLoopTask::setLoop ( const FKLoop l) [inline]
void FKLoopTask::setParameters ( const FKParameters param)

Member Data Documentation

const FKLoop* FKLoopTask::_loop [protected]
int FKLoopTask::_nStations [protected]

Referenced by getPower(), and setParameters().

double FKLoopTask::_nStations2 [protected]
const TimeRange* FKLoopTask::_win [protected]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines