All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Protected Member Functions | Protected Attributes
ArrayCore::FK Class Reference

FK map calculator. More...

#include <FK.h>

Inheritance diagram for ArrayCore::FK:
QGpCoreTools::AbstractFunction2 ArrayCore::FKHorizontal ArrayCore::HRFK ArrayCore::FKRadial ArrayCore::FKTransverse

List of all members.

Public Member Functions

double absolutePower (int iComp) const
 FK (QList< FKStationSignals * > array)
virtual void initGrid (int n)
virtual void initGrid (double kx, double ky, int index)
double maximumSlowness () const
void setFrequencyBand (const FrequencyBand &f, double windowLength)
void setMaximumSlowness (double slow)
void setMaximumWavenumber (double k)
virtual double value (double kx, double ky) const
virtual double value (double kx, double ky, int index) const
 ~FK ()

Protected Member Functions

double maximumK2 () const

Protected Attributes

QList< FKStationSignals * > _array
double _frequency
double * _gaussian
double * _gaussianPtr
int _iFreqMax
int _iFreqMin

Detailed Description

FK map calculator.

Compute the FK map for a given array of stations.


Constructor & Destructor Documentation

ArrayCore::FK::FK ( QList< FKStationSignals * >  array)

Description of constructor still missing

References _array, _gaussian, _gaussianPtr, _iFreqMax, _iFreqMin, and TRACE.

{
  TRACE;
  _array=array;
  _gaussian=0;
  _gaussianPtr=0;
  _iFreqMin=0;
  _iFreqMax=0;
  _squaredKmaxGrid=0.0;
  _squaredSlowMax=1e99;
  _squaredKmaxTotal=1e99;
}
ArrayCore::FK::~FK ( ) [inline]
{delete [] _gaussian;}

Member Function Documentation

double ArrayCore::FK::absolutePower ( int  iComp) const

References _array, _gaussianPtr, _iFreqMax, _iFreqMin, ArrayCore::FKStationSignals::absolutePower(), and ArrayCore::FKStationSignals::isSelected().

Referenced by FKLoopTask::getPower().

{
  QList<FKStationSignals *>::const_iterator it=_array.begin();
  double absPower=0;
  for( ; it!=_array.end(); ++it) {
    FKStationSignals * s=static_cast<FKStationSignals *>( *it);
    if(s->isSelected()) absPower += s->absolutePower(iComp, _iFreqMin, _iFreqMax, _gaussianPtr);
  }
  return absPower;
}
void ArrayCore::FK::initGrid ( int  n) [virtual]

Automatically called by GridSearch upon initialization

Reimplemented from QGpCoreTools::AbstractFunction2.

Reimplemented in ArrayCore::FKHorizontal.

References _array, ArrayCore::FKStationSignals::initPhaseShifts(), and ArrayCore::FKStationSignals::isSelected().

{
  // Init shift table
  for(QList<FKStationSignals *>::iterator it=_array.begin() ; it!=_array.end(); ++it) {
    FKStationSignals * s=static_cast<FKStationSignals *>( *it);
    if(s->isSelected()) s->initPhaseShifts(n);
  }
}
void ArrayCore::FK::initGrid ( double  x,
double  y,
int  index 
) [virtual]

Re-implemement if the computation of value(double x, double y) requires caching for gridded couples (x,y). This fonction initialize the cached values for x and y aligned to a grid and corresponding to index.

Reimplemented from QGpCoreTools::AbstractFunction2.

Reimplemented in ArrayCore::FKHorizontal.

References _array, ArrayCore::FKStationSignals::isSelected(), and ArrayCore::FKStationSignals::setPhaseShift().

{
  // Init shift table
  for(QList<FKStationSignals *>::iterator it=_array.begin() ; it!=_array.end(); ++it) {
    FKStationSignals * s=static_cast<FKStationSignals *>( *it);
    if(s->isSelected()) s->setPhaseShift(index, kx , ky);
  }
  double squaredK=fabs(kx)>fabs(ky) ? kx*kx : ky*ky;
  if(squaredK > _squaredKmaxGrid) {
    _squaredKmaxGrid=squaredK;
  }
}
double ArrayCore::FK::maximumK2 ( ) const [inline, protected]

Referenced by ArrayCore::FKHorizontal::value(), ArrayCore::HRFK::value(), and value().

{return _squaredKmaxTotal;}
double ArrayCore::FK::maximumSlowness ( ) const [inline]

References QGpCoreTools::sqrt().

{return sqrt(_squaredSlowMax);}
void ArrayCore::FK::setFrequencyBand ( const FrequencyBand f,
double  windowLength 
)

References _frequency, _gaussian, _gaussianPtr, _iFreqMax, _iFreqMin, ArrayCore::FrequencyBand::center(), QGpCoreTools::exp(), ArrayCore::FrequencyBand::halfWidth(), ArrayCore::FrequencyBand::highLimit(), ArrayCore::FrequencyBand::lowLimit(), ArrayCore::FrequencyBand::omega(), and ArrayCore::FrequencyBand::relativeWidth().

Referenced by FKLoopTask::exportMax(), HRFKTimeWindows::setComponent(), and FKTimeWindows::setComponent().

{
  _squaredKmaxTotal=f.omega() * f.omega() * _squaredSlowMax;
  if(_squaredKmaxTotal > _squaredKmaxGrid) _squaredKmaxTotal=_squaredKmaxGrid;
#define GAUSS_WEIGHTING
  // Calculate frequency indexes of the bandwidth limits
  _frequency=f.center();
  _iFreqMin=(int)round(windowLength*f.lowLimit());
  _iFreqMax=(int)round(windowLength*f.highLimit());

  delete [] _gaussian;
  int iSub=_iFreqMax - _iFreqMin;
  _gaussian=new double [iSub+1];
  _gaussianPtr=_gaussian-_iFreqMin;
#ifdef GAUSS_WEIGHTING
  if(_iFreqMin==_iFreqMax) { // Frequency range reduced to one sample
    _gaussianPtr[_iFreqMin]=1.0;
  } else {
    /*
      Multiplication of spectrum by a Gaussian window function:
      G(f)=exp(-((2/(b*fc)*(f-fc))^2, hence sigma=b*Fc/sqrt(8), sqrt(8)=2.83
      which imply that G(fc-b*fc)=0.01378
    */
    double b=2.0/f.relativeWidth();
    double a=2.0/(windowLength*f.halfWidth());
    for (int i=_iFreqMin; i<=_iFreqMax; i++) {
      double v=a*i-b;
      _gaussianPtr[i]=exp(-v*v);
    }
  }
#else
  for(int i=_iFreqMin;i<=_iFreqMax;i++ ) {
    _gaussianPtr[i]=1.0;
  }
#endif
  /*for(int i=_iFreqMin;i<=_iFreqMax;i++ ) {
    printf("Weighting function %i %lf %lf\n",i,i/windowLength,_gaussianPtr[i]);
  }*/
}
void ArrayCore::FK::setMaximumSlowness ( double  slow) [inline]
void ArrayCore::FK::setMaximumWavenumber ( double  k) [inline]

Referenced by HRFKTimeWindows::setComponent(), and FKTimeWindows::setComponent().

{_squaredKmaxGrid=k*k;}
double ArrayCore::FK::value ( double  x,
double  y 
) const [virtual]

Implemement this function to calculate the 2D function at x and y.

Implements QGpCoreTools::AbstractFunction2.

Reimplemented in ArrayCore::HRFK, and ArrayCore::FKHorizontal.

References _array, _gaussianPtr, _iFreqMax, _iFreqMin, QGpCoreTools::Complex::abs2(), ArrayCore::FKStationSignals::getShiftedSignal(), ArrayCore::FKStationSignals::isSelected(), maximumK2(), and ArrayCore::FKStationSignals::setCurrentShift().

Referenced by HRFKLoopTask::getPower(), and FKLoopTask::getPower().

{
  double k2=kx * kx + ky * ky;
  if(k2 > maximumK2()) return -1;
  QList<FKStationSignals *>::const_iterator it;
  for(it=_array.begin(); it!=_array.end(); ++it) {
    FKStationSignals * s=static_cast<FKStationSignals *>( *it);
    if(s->isSelected()) s->setCurrentShift(kx, ky);
  }
  double val=0;
  for(int i=_iFreqMin;i <= _iFreqMax;i++ ) {
    Complex sum;
    for(it=_array.begin(); it!=_array.end(); ++it) {
      FKStationSignals * s=static_cast<FKStationSignals *>( *it);
      if(s->isSelected()) sum += s->getShiftedSignal(0, i);
    }
    val += sum.abs2() * _gaussianPtr[i];
  }
  return val;
}
double ArrayCore::FK::value ( double  x,
double  y,
int  index 
) const [virtual]

Re-mplemement this function to calculate the 2D function for x and y aligned to a grid. x and y correspond to index in the grid: index=iy * nx + ix

If nothing is cached re-implementation of this function is useless.

Reimplemented from QGpCoreTools::AbstractFunction2.

Reimplemented in ArrayCore::HRFK, and ArrayCore::FKHorizontal.

References _array, _gaussianPtr, _iFreqMax, _iFreqMin, QGpCoreTools::Complex::abs2(), ArrayCore::FKStationSignals::getShiftedSignal(), ArrayCore::FKStationSignals::isSelected(), and maximumK2().

{
  double k2=kx * kx + ky * ky;
  if(k2 > maximumK2()) return -1;
  QList<FKStationSignals *>::const_iterator it;
  double val=0;
  for(int i=_iFreqMin;i <= _iFreqMax;i++ ) {
    Complex sum;
    for(it=_array.begin(); it!=_array.end(); ++it) {
      FKStationSignals * s=static_cast<FKStationSignals *>( *it);
      if(s->isSelected()) sum += s->getShiftedSignal(0, i, index);
    }
    val += sum.abs2() * _gaussianPtr[i];
  }
  //printf("%lg\n",val);
  return val;
}

Member Data Documentation

double ArrayCore::FK::_frequency [protected]
double* ArrayCore::FK::_gaussian [protected]

Referenced by FK(), and setFrequencyBand().

double * ArrayCore::FK::_gaussianPtr [protected]
int ArrayCore::FK::_iFreqMax [protected]
int ArrayCore::FK::_iFreqMin [protected]

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