All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes
GeopsyCore::SubSignalPool Class Reference

#include <SubSignalPool.h>

Inheritance diagram for GeopsyCore::SubSignalPool:
GeopsyCore::SignalDB ShotRecord

List of all members.

Public Types

typedef QList< Signal * >
::const_iterator 
const_iterator
typedef QList< Signal * >::iterator iterator

Public Member Functions

void addAll ()
void addFile (int fileN)
void addFile (const SignalFile *sf)
void addGroup (AbstractSignalGroup *g)
void addList (QString signalList)
void addReceiver (Point point)
void addSignal (Signal *sig)
void addSignal (int id)
void addSource (Point point)
void addSubPool (const SubSignalPool &subPool)
void agc (double width)
bool associate3Components ()
Signalat (int index) const
QStringList availableTimePicks () const
double azimuth () const
iterator begin ()
const_iterator begin () const
int checkDuplicateRays ()
bool contains (const Signal *sig) const
void convolution (const Signal *referenceSig)
SubSignalPool copy () const
void correlations (double maxDelay, const Signal *referenceSig=0)
int count () const
void cut (const TimeRangeParameters &param)
void debugSignalSharing ()
void decimateAmplitude (int maxCount, double maxRef)
void decimateTime (int factor)
void discreteFourierTransform ()
bool empty ()
iterator end ()
const_iterator end () const
void exportTable (QString fileName, const MetaDataFieldList &param)
void fastFourierTransform (DoubleSignal::SignalType st)
void filter (const FilterParameters &param)
Signalfirst () const
void importTable (QString fileName)
int indexOf (const Signal *sig) const
void insertSignal (Signal *sig, Signal *refSig=0, bool before=true)
bool isEmpty () const
bool isHeaderModified () const
bool isReadOnlySamples () const
Signallast () const
int linearSearch (const Point &source, const Point &receiver)
int maximumTimePickCount () const
bool merge ()
bool mergeStations ()
void multiply (double value)
const QString & name () const
void normalizedCorrelations (double maxDelay, const Signal *referenceSig=0)
bool operator!= (const SubSignalPool &o) const
SubSignalPooloperator= (const SubSignalPool &o)
bool operator== (const SubSignalPool &o) const
void overSample (double factor)
void pickCoppens (const QString &pickName, double delta, double tend, double tstart=0., bool relative=false, double mute=0.0)
void pickMinMax (const QString &pickNameb, double from, double to, Signal::PickWhat what)
Curve< Pointreceivers () const
void remove (Signal *sig)
void remove (Signal::Components comp)
void removeAll ()
void removeAt (int i)
void rotateComponents (Matrix3x3 rotMatrix)
int samplesCount ()
bool save (QString filePath, bool useOriginalBaseName, SignalFileFormat format, int maximumSignalsPerFile=0, const QString &pickName=QString::null) const
bool saveGeopsySignal (QString filePath) const
void setHeaderModified (bool b) const
void setName (const QString &n)
void shift (double dt)
void sort ()
Curve< Pointsources () const
void stalta (double tsta, double tlta)
void stddevClip (double factor)
 SubSignalPool ()
 SubSignalPool (const SubSignalPool &subPool)
void subtractSignal (Signal *bysig)
void subtractSignals (SubSignalPool *bySubPool)
void subtractValue (double val=0.0)
void taper (const TimeRangeParameters &range, const TaperParameters &param)
TimeRange timeRange () const
void unglitch (double threshold)
void waveletTransform (const MorletParameters &param)
void whiten ()
 ~SubSignalPool ()

Static Public Member Functions

static bool isExportFormat (const SignalFileFormat &f)

Protected Attributes

QString _name

Member Typedef Documentation


Constructor & Destructor Documentation

{}

Copy constuctor: do not forget to increase the reference count

References begin(), end(), and TRACE.

    : QList<Signal *>(subPool), _name(subPool.name())
{
  TRACE;
  for(iterator it=begin(); it!=end(); ++it) {
    ( *it) ->addReference();
  }
}
{removeAll();}

Member Function Documentation

References _name, begin(), GeopsyCore::GeopsyCoreEngine::currentDB(), end(), GeopsyCore::Signal::file(), GeopsyCore::geopsyCore, GeopsyCore::SignalFile::shortName(), GeopsyCore::SignalDB::subPool(), QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  const SubSignalPool & dbList=geopsyCore->currentDB() ->subPool();
  for(const_iterator it=dbList.begin(); it!=dbList.end(); ++it) {
    Signal * sig=* it;
    if(sig->file()==sFile) {
      //qDebug( "SubSignalPool::addFile signal id %i %s", sig->id(), sig->name().toAscii().data());
      append(sig);
    }
  }
  if(_name.isEmpty())
    _name=tr( "File %1" ).arg(sFile->shortName());
  else
    _name += tr( "+File %1" ).arg(sFile->shortName());
}
void GeopsyCore::SubSignalPool::addList ( QString  signalList)

References begin(), end(), GeopsyCore::Signal::receiver(), and TRACE.

{
  TRACE;
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=* it;
    if(point==sig->receiver())
      append(sig);
  }
}
void GeopsyCore::SubSignalPool::addSignal ( Signal sig) [inline]

References begin(), end(), GeopsyCore::Signal::source(), and TRACE.

{
  TRACE;
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=* it;
    if(point==sig->source())
      append(sig);
  }
}

References _name, name(), and TRACE.

Referenced by addAll(), addGroup(), GeopsyCore::SignalGroup::addSignals(), GeopsyGui::SubPoolWindow::addSignals(), GraphicWindow::getSelection(), Station::raw(), and GeopsyCore::AbstractSignalGroup::subPool().

{
  TRACE;
  for(const_iterator it=subPool.constBegin(); it!=subPool.constEnd(); ++it) {
    append( * it);
  }
  if(_name.isEmpty())
    _name=subPool.name();
  else if( !subPool.name().isEmpty())
    _name += "+" + subPool.name();
}
void GeopsyCore::SubSignalPool::agc ( double  width)

Make sure the the sub pool is organized in terms of a list of 3 component stations, listed by Z N E Returns false if some components are missing or if some error were detected. The signals must be associated in triplets (Vertical, North and East component)

  • sort the subpool by receiver name, t0 and component
  • test if sampling rate and number of samples is the same for all

References GeopsyCore::SortKey::add(), addSignal(), at(), GeopsyCore::SortKey::clear(), GeopsyCore::MetaDataFactory::Component, GeopsyCore::Signal::component(), count(), GeopsyCore::DoubleSignal::deltaT(), isEmpty(), MSG_ID, GeopsyCore::MetaDataFactory::Name, GeopsyCore::Signal::name(), GeopsyCore::SignalTemplate< sampleType >::nSamples(), GeopsyCore::Signal::receiver(), removeAll(), sort(), GeopsyCore::MetaDataFactory::T0, GeopsyCore::Signal::t0(), QGpCoreTools::tr(), and TRACE.

Referenced by ToolPtMotion::initStations(), WaveformConsole::rotate(), and rotateComponents().

{
  TRACE;
  // Sorting
  SortKey::clear();
  SortKey::add(MetaDataFactory::Name);
  SortKey::add(MetaDataFactory::T0);
  SortKey::add(MetaDataFactory::Component);
  sort();
  // Testing if all 3 components are present (warning only)
  // Testing if nsamples and sampling rate are constant
  SubSignalPool triplet;
  double deltaT=0;
  int nSamp=0;
  double t0=0;
  QString stat;
  Point rec;
  int n=count();
  for(int i=0;i < n; ) {
    Signal * sig=at(i);
    if(deltaT==0) {
      deltaT=sig->deltaT();
      nSamp=sig->nSamples();
      t0=sig->t0();
      stat=sig->name();
      rec=sig->receiver();
      triplet.addSignal(sig);
      i++;
      continue;
    }
    if(sig->name()==stat && sig->receiver()==rec && sig->t0()==t0) {
      if(sig->deltaT()!=deltaT || sig->nSamples()!=nSamp) {
        Message::warning(MSG_ID, tr( "Associating 3 components" ),
                             tr( "For station %1, the sampling rate or the number of samples "
                                 "is not the same for all component, skiping %2 component." )
                             .arg(stat).arg(sig->component()), Message::cancel());
        return false;
      } else {
        triplet.addSignal(sig);
      }
      i++;
    } else {
      if( !check3ComponentTriplet(triplet) ) return false;
      triplet.removeAll();
      deltaT=0;
    }
  }
  if( !triplet.isEmpty()) {
    if( !check3ComponentTriplet(triplet) ) return false;
  }
  return true;
}
Signal* GeopsyCore::SubSignalPool::at ( int  index) const [inline]

Reimplemented in GeopsyCore::SignalDB.

Referenced by GeopsyGui::SubPoolWindow::addSignal(), StructureStationSignals::addSignals(), agc(), associate3Components(), GeopsyCore::SignalDB::at(), convolution(), GeopsyCore::SignalProcess::convolutionCore(), GeopsyCore::StationProcessSignals::copyOriginalSignal(), correlations(), GeopsyCore::SignalProcess::correlationsCore(), GeopsyMainWindow::createNewGroup(), TFAResults::createObjects(), DampingResults::createObjects(), SignalTableItem::data(), decimateTime(), discreteFourierTransform(), GeopsyGui::ChronogramLayer::exportGaps(), fastFourierTransform(), filter(), SignalTableView::getSelection(), GeopsyCore::SignalProcess::headerCore(), ToolNR::highlightShot(), GeopsyGui::SignalLayer::highlightSignal(), ManualPick::init(), ShotRecord::isSameReceiverSet(), GeopsyGui::PickLayer::keyPressEvent(), linearSearch(), GeopsyCore::SignalFile::loadGeopsySignal(), GeopsyGui::SignalLayer::maxAmplitude(), GeopsyGui::SignalLayer::minMaxY(), GeopsyGui::PickLayer::mouseMoveEvent(), GeopsyGui::PickLayer::mousePressEvent(), normalizedCorrelations(), GeopsyCore::SignalProcess::normalizedCorrelationsCore(), operator==(), StructureStationSignals::organizeSubPool(), overSample(), GeopsyGui::PickLayer::paintData(), GeopsyGui::SignalLayer::paintData(), GeopsyGui::ChronogramLayer::rangeUpdate(), ShotRecord::receiverIndex(), remove(), removeAt(), GeopsyCore::SignalFile::save(), GeopsyGui::ChronogramLayer::selection(), MonoStation::AbstractTool::setCurrentDisplayStation(), SignalTableItem::setData(), GeopsyCore::SignalProcess::setHeaderCore(), GeopsyCore::StationProcessSignals::setHighPassFilter(), GeopsyGui::PickLayer::setPick(), MagnifierSignal::setSignal(), SignalViewer::setSignals(), ShotRecord::setSignals(), Convolution::setSubPool(), Correlations::setSubPool(), SubtractSignals::setSubPool(), shift(), MonoStation::AbstractTool::signalMousePressed(), StackWeights::stack(), ToolTFA::start(), stddevClip(), ChronogramWindow::subPoolUpdate(), MapWindow::subPoolUpdate(), GraphicWindow::subPoolUpdate(), GeopsyGui::SignalLayer::subPoolUpdate(), GeopsyCore::SignalProcess::subtractSignalCore(), subtractSignals(), GraphicWindow::updateLabels(), T0Correlation::value(), waveletTransform(), whiten(), GeopsyGui::TimeWindowLayer::xml_layerPolish(), GeopsyCore::SignalFile::xml_polish(), GeopsyGui::SignalLayer::xml_setProperty(), GeopsyGui::TimeWindowLayer::xml_writeChildren(), and GeopsyCore::XMLSubSignalPool::XMLSubSignalPool().

{return QList<Signal *>::at(index);}

References begin(), end(), GeopsyCore::TimePick::names(), GeopsyCore::TimePick::staticId(), TRACE, and QGpCoreTools::unique().

{
  TRACE;
  QStringList names;
  for(const_iterator it=begin(); it!=end(); ++it) {
    const TimePick * o=static_cast<const TimePick *>((*it)->metaData(TimePick::staticId()));
    names.append(o->names());
  }
  qSort(names);
  unique(names);
  return names;
}

Return the general azimuth of the sources of the subpool. If only one source is detected, the general azimuth includes the receivers (-M_PI/2 to M_PI/2)

References GeopsyCore::SortKey::add(), QGpCoreTools::Curve< pointType >::append(), QGpCoreTools::Curve< pointType >::azimuth(), begin(), GeopsyCore::SortKey::clear(), QGpCoreTools::Curve< pointType >::count(), count(), end(), GeopsyCore::Signal::receiver(), sort(), GeopsyCore::Signal::source(), GeopsyCore::MetaDataFactory::SourceReceiverDistance, GeopsyCore::MetaDataFactory::SourceReceiverRoughAzimuth, GeopsyCore::MetaDataFactory::SourceX, GeopsyCore::MetaDataFactory::SourceY, GeopsyCore::MetaDataFactory::SourceZ, and TRACE.

Referenced by ToolRefra::initStations().

{
  TRACE;
  if(count()==0) return 0;
  SubSignalPool ordered=*this;
  SortKey::clear();
  SortKey::add(MetaDataFactory::SourceX);
  SortKey::add(MetaDataFactory::SourceY);
  SortKey::add(MetaDataFactory::SourceZ);
  SortKey::add(MetaDataFactory::SourceReceiverRoughAzimuth);
  SortKey::add(MetaDataFactory::SourceReceiverDistance);
  ordered.sort();
  Curve<Point> srcList;
  iterator it=ordered.begin();
  Signal * sig=*it;
  srcList.append(sig->source());
  Point p=sig->source();
  for(++it; it!= ordered.end(); ++it) {
    sig=*it;
    if(sig->source()!=p) {
      p=sig->source();
      srcList.append(sig->source());
    }
  }
  if(srcList.count()==1) { // only one source, add receivers to define azimuth
    it=ordered.begin();
    for(it=ordered.begin(); it!=ordered.end(); ++it) {
      sig=*it;
      if(sig->receiver()!=p) {
        p=sig->receiver();
        srcList.append(sig->receiver());
      }
    }
  }
  return srcList.azimuth();
}

Referenced by addFile(), addReceiver(), GeopsyCore::StationList::addSignals(), addSource(), GeopsyGui::TimeWindowLayer::addTimeWindows(), availableTimePicks(), azimuth(), MonoStation::CategoryGroupItem::belongsTo(), copy(), PtMotionResults::createObjects(), cut(), debugSignalSharing(), decimateAmplitude(), exportTable(), MonoStation::CategoryGroupItem::flags(), geopsyToFile(), importTable(), StationCoordinates::init(), ToolRefra::initStations(), ToolLinearFKActive::initStations(), isHeaderModified(), GeopsyCore::SignalDB::isModified(), isReadOnlySamples(), maximumTimePickCount(), GeopsyCore::StationSignals::maxTime(), merge(), mergeStations(), GeopsyCore::StationSignals::minTime(), multiply(), GeopsyCore::StationGroup::name(), operator=(), ShotRecord::organizeSubPool(), MonoStation::SpectrumStationSignals::organizeSubPool(), pickCoppens(), pickMinMax(), receivers(), GeopsyCore::SignalDB::removeFile(), rotateComponents(), samplesCount(), save(), saveGeopsySignal(), GeopsyCore::SignalProcess::setHeaderCore(), setHeaderModified(), GeopsyCore::StationProcessSignals::setHighPassFilter(), GeopsyCore::StationSignals::setKeep(), GeopsyMainWindow::setReceivers(), GeopsyCore::StationSignals::setSampling(), MonoStation::CategoryGroupItem::setSignals(), GeopsyMainWindow::setSources(), ToolArrayBase::setTimeWindowLayer(), GeopsyCore::SignalDB::signal(), sources(), stalta(), GeopsyCore::TemporarySignalsGroup::subPool(), GeopsyGui::SignalLayer::subPoolUpdate(), SubSignalPool(), GeopsyCore::SubSignalPoolProcess::SubSignalPoolProcess(), subtractSignal(), subtractValue(), taper(), GeopsyCore::StationSignals::timeRange(), timeRange(), unglitch(), GeopsyGui::SignalLayer::updateGrid(), PtMotionResults::updateSignals(), GeopsyCore::SignalDB::xml_polish(), GeopsyCore::SignalFile::xml_writeChildren(), GeopsyCore::SignalGroup::xml_writeProperties(), and GeopsyCore::SignalDB::~SignalDB().

References TRACE.

{
  TRACE;
  int ndrays=0;
  /* TODO: not usefull if tomography is not included in geopsy
           to be revised in a more object oriented form (e.g. DupRay witch all necessary search properties
  PointList sources,receivers;
  SubSignalPool sigs(_pool,(bool)false);
  int index;
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=* it;
    delete sig->duplicateRaysPool();
    sig->duplicateRaysPool(NULL);
    sig->duplicateRaysID(-1);
    // Look for a source corresponding to this one
    index=sources.indexOf(sig->source());
    // For this source, look for a matching receiver
    while(index>-1 && receivers.at(index)!=sig->receiver())
      index=sources.findNext(&sig->source());
    if(index==-1) {
      // Look for a source corresponding to this receiver
      index=sources.find (&sig->receiver());
      // For this source, look for a matching receiver
      while(index >-1 && *(receivers.at(index))!=sig->source())
        index=sources.findNext(&sig->receiver());
    }
    if(index==-1) {
      sources.append(&sig->source());
      receivers.append(&sig->receiver());
      sigs.append(sig);
    }
    else {
      Signal * otherSig=sigs.at(index);
      SubSignalPool* dupPool=otherSig->duplicateRaysPool();
      if(dupPool==NULL) {
        ndrays++;
        // Set duplicate for the other signal
        dupPool=new SubSignalPool(_pool,(bool)false);
        otherSig->duplicateRaysPool(dupPool);
        dupPool->append(sig);
        otherSig->duplicateRaysID(ndrays);
        // Set Duplicate for signal i
        SubSignalPool* tmpPool=new SubSignalPool(_pool,(bool)false);
        sig->duplicateRaysPool(tmpPool);
        tmpPool->append(otherSig);
        sig->duplicateRaysID(ndrays);
      }
      else {
        SubSignalPool* tmpPool=new SubSignalPool(_pool,(bool)false);
        tmpPool->append(otherSig);
        SubSignalPoolIterator itDup(*dupPool);
        for(Signal * dupSig=itDup.current();dupSig;dupSig=++itDup) {
          dupSig->duplicateRaysPool()->append(sig);
          tmpPool->append(dupSig);
        }
        dupPool->append(sig);
        sig->duplicateRaysID(otherSig->duplicateRaysID());
        sig->duplicateRaysPool(tmpPool);
      }
    }
  }*/ 
  return ndrays;
}
bool GeopsyCore::SubSignalPool::contains ( const Signal sig) const [inline]

References contains().

{return QList<Signal *>::contains(const_cast<Signal *>(sig));}
void GeopsyCore::SubSignalPool::convolution ( const Signal referenceSig)

Computes convolution product with respect to referenceSig

References _name, addSignal(), at(), GeopsyCore::DoubleSignal::convolution(), count(), GeopsyCore::GeopsyCoreEngine::currentDB(), GeopsyCore::geopsyCore, setName(), GeopsyCore::Signal::setTemporary(), and TRACE.

Referenced by GeopsyCore::SignalProcess::convolutionCore().

{
  TRACE;
  SubSignalPool convSubPool;
  convSubPool.setName(_name);
  int n=count();
  for(int i=0; i< n; i++) {
    Signal * sig=at(i);
    if(sig!=referenceSig) {
      Signal * convSig=new Signal(geopsyCore->currentDB());
      convSig->setTemporary();
      convSig->convolution(referenceSig, sig);
      convSubPool.addSignal(convSig);
    }
  }
  *this=convSubPool;
}

References _name, addSignal(), begin(), GeopsyCore::Signal::copySamplesFrom(), end(), and TRACE.

Referenced by Station::filter1(), Station::filter2(), and GeopsyCore::SignalProcess::saveStepCore().

{
  TRACE;
    SubSignalPool c;
    c._name=_name;
    for(const_iterator it=begin(); it!=end(); ++it) {
      Signal * sig=new Signal( **it);
      sig->copySamplesFrom( *it);
      c.addSignal(sig);
    }
    return c;
}
void GeopsyCore::SubSignalPool::correlations ( double  maxDelay,
const Signal referenceSig = 0 
)

Computes all possible correlations from this subpool if referenceSig is null.

The correlation is computed with a maximum delay of delay.

References _name, addSignal(), at(), GeopsyCore::Signal::correlation(), count(), GeopsyCore::GeopsyCoreEngine::currentDB(), GeopsyCore::geopsyCore, setName(), GeopsyCore::Signal::setTemporary(), and TRACE.

Referenced by GeopsyCore::SignalProcess::correlationsCore().

{
  TRACE;
  SubSignalPool corrSubPool;
  corrSubPool.setName(_name);
  int n=count();
  if(referenceSig) {
    for(int i=0; i< n; i++ ) {
      Signal * sig=at(i);
      if(sig!=referenceSig) {
        Signal * corrSig=new Signal(geopsyCore->currentDB());
        corrSig->setTemporary();
        corrSig->correlation(referenceSig, sig, maxDelay);
        corrSubPool.addSignal(corrSig);
      }
    }
  } else {
    for(int i=0; i< n-1; i++ ) {
      Signal * sig=at(i);
      for(int j=i+1; j< n; j++) {
        Signal * corrSig=new Signal(geopsyCore->currentDB());
        corrSig->setTemporary();
        corrSig->correlation(sig, at(j), maxDelay);
        corrSubPool.addSignal(corrSig);
      }
    }
  }
  *this=corrSubPool;
}
int GeopsyCore::SubSignalPool::count ( ) const [inline]

Reimplemented in GeopsyCore::SignalDB.

Referenced by GeopsyGui::SubPoolWindow::addSignal(), StructureStationSignals::addSignals(), agc(), associate3Components(), azimuth(), convolution(), GeopsyCore::StationProcessSignals::copyOriginalSignal(), correlations(), GeopsyCore::SignalDB::count(), GeopsyMainWindow::createNewGroup(), PtMotionResults::createObjects(), TFAResults::createObjects(), DampingResults::createObjects(), GeopsyGui::SignalGroupItem::data(), decimateTime(), discreteFourierTransform(), GeopsyGui::SignalLayer::drawingAmplitude(), GeopsyGui::SignalLayer::drawSignal(), GeopsyGui::ChronogramLayer::exportGaps(), fastFourierTransform(), filter(), geopsyToFile(), SignalTableView::getSelection(), MapWindow::getSelection(), SignalTableItem::index(), ManualPick::init(), ToolStructure::initStations(), ToolLinearFKActive::initStations(), ToolNR::initStations(), ShotRecord::isSameReceiverSet(), GeopsyGui::PickLayer::keyPressEvent(), linearSearch(), GeopsyCore::SignalFile::loadGeopsySignal(), GeopsyGui::SignalLayer::maxAmplitude(), GeopsyGui::SignalLayer::minMaxY(), normalizedCorrelations(), ShotRecord::nReceivers(), operator==(), StructureStationSignals::organizeSubPool(), overSample(), GeopsyGui::PickLayer::paintData(), GeopsyGui::ChronogramLayer::rangeUpdate(), ShotRecord::receiverIndex(), remove(), SignalTableItem::rowCount(), Process::run(), GeopsyCore::SignalFile::save(), save(), saveGeopsySignal(), GeopsyGui::ChronogramLayer::selection(), MonoStation::AbstractTool::setCurrentDisplayStation(), SignalTableItem::setData(), GeopsyCore::StationProcessSignals::setHighPassFilter(), GeopsyGui::SignalLayer::setIsigMinMax(), MagnifierSignal::setSignal(), SignalViewer::setSignals(), ShotRecord::setSignals(), Convolution::setSubPool(), Correlations::setSubPool(), SubtractSignals::setSubPool(), shift(), GeopsyGui::SignalLayer::signalAt(), GeopsyCore::SignalProcess::signalCountCore(), GeopsyCore::SignalHeaderScript::SignalHeaderScript(), GraphicWindow::signalsUpdate(), StackWeights::stack(), ToolTFA::start(), stddevClip(), GeopsyGui::SignalLayer::subPoolUpdate(), subtractSignals(), GeopsyGui::SignalLayer::updateGrid(), GraphicWindow::updateLabels(), PtMotionResults::updateSignals(), waveletTransform(), whiten(), GeopsyCore::SignalFile::xml_polish(), GeopsyGui::TimeWindowLayer::xml_writeChildren(), and GeopsyCore::XMLSubSignalPool::XMLSubSignalPool().

Cut signals according to param time limits.

References _name, GeopsyCore::TimeRangeParameters::absoluteRange(), addSignal(), begin(), GeopsyCore::Signal::cut(), end(), fastFourierTransform(), setName(), TRACE, and GeopsyCore::DoubleSignal::Waveform.

Referenced by GeopsyCore::SignalProcess::cutCore().

{
  TRACE;
  SubSignalPool cuttedSignals;
  cuttedSignals.setName(_name);
  // Make sure all signals are in time series
  fastFourierTransform(Signal::Waveform);
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=*it;
    Signal * newSig=sig->cut(param.absoluteRange(sig));
    if(newSig) {
      cuttedSignals.addSignal(newSig);
    }
  }
  *this=cuttedSignals;
}

References begin(), end(), GeopsyCore::Signal::id(), GeopsyCore::Signal::name(), QGpCoreTools::SharedObject::referenceCount(), and TRACE.

{
  TRACE;
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=*it;
    qDebug( "Signal %i named %s ptr %lx -> refCount=%i", sig->id(), sig->name().toAscii().data(), (long) sig, sig->referenceCount());
  }
}
void GeopsyCore::SubSignalPool::decimateAmplitude ( int  maxCount,
double  maxRef 
)

Decimate signals along amplitude scale. maxCount is the maximum number of discretization steps. maxRef is the amplitude value corresponding to maxCount. If maxRef is negative, the maximum of the signal is taken as a reference.

References begin(), GeopsyCore::DoubleSignal::decimateAmplitude(), end(), GeopsyCore::Signal::maximumAmplitude(), TRACE, and GeopsyCore::Signal::warnReadOnlySamples().

Referenced by GeopsyCore::SignalProcess::decimateAmplitudeCore().

{
  TRACE;
  if(maxRef < 0.0) {
    double invMaxCount=1.0/(double) maxCount;
    for(iterator it=begin(); it!=end(); ++it) {
      Signal& sig=** it;
      if(!sig.warnReadOnlySamples()) {
        sig.decimateAmplitude(sig.maximumAmplitude() * invMaxCount);
      }
    }
  } else {
    double delta=maxRef/maxCount;
    for(iterator it=begin(); it!=end(); ++it) {
      Signal& sig=** it;
      if(!sig.warnReadOnlySamples()) {
        sig.decimateAmplitude(delta);
      }
    }
  }
}

Decimate signals along time scale.

References _name, addSignal(), at(), count(), GeopsyCore::DoubleSignal::decimateTime(), fastFourierTransform(), GeopsyCore::geopsyCore, setName(), GeopsyCore::GeopsyCoreEngine::setProgressMaximum(), GeopsyCore::GeopsyCoreEngine::setProgressValue(), TRACE, and GeopsyCore::DoubleSignal::Waveform.

Referenced by GeopsyCore::SignalProcess::decimateTimeCore().

{
  TRACE;
  SubSignalPool decimatedSignals;
  decimatedSignals.setName(_name);
  // Make sure all signals are in time series
  fastFourierTransform(Signal::Waveform);
  geopsyCore->setProgressMaximum(count() - 1);
  for(int i=0; i<count(); i++ ) {
    Signal * sig=at(i);
    geopsyCore->setProgressValue(i);
    Signal * newsig=new Signal( *sig);
    newsig->decimateTime(factor, sig);
    decimatedSignals.addSignal(newsig);
  }
  *this=decimatedSignals;
}

Referenced by addFile(), addReceiver(), GeopsyCore::StationList::addSignals(), addSource(), GeopsyGui::TimeWindowLayer::addTimeWindows(), availableTimePicks(), azimuth(), MonoStation::CategoryGroupItem::belongsTo(), copy(), cut(), debugSignalSharing(), decimateAmplitude(), exportTable(), MonoStation::CategoryGroupItem::flags(), geopsyToFile(), importTable(), StationCoordinates::init(), ToolRefra::initStations(), ToolLinearFKActive::initStations(), isHeaderModified(), GeopsyCore::SignalDB::isModified(), isReadOnlySamples(), maximumTimePickCount(), GeopsyCore::StationSignals::maxTime(), merge(), mergeStations(), GeopsyCore::StationSignals::minTime(), multiply(), GeopsyCore::StationGroup::name(), operator=(), ShotRecord::organizeSubPool(), MonoStation::SpectrumStationSignals::organizeSubPool(), pickCoppens(), pickMinMax(), receivers(), GeopsyCore::SignalDB::removeFile(), rotateComponents(), samplesCount(), save(), saveGeopsySignal(), GeopsyCore::SignalProcess::setHeaderCore(), setHeaderModified(), GeopsyCore::StationProcessSignals::setHighPassFilter(), GeopsyCore::StationSignals::setKeep(), GeopsyMainWindow::setReceivers(), GeopsyCore::StationSignals::setSampling(), MonoStation::CategoryGroupItem::setSignals(), GeopsyMainWindow::setSources(), ToolArrayBase::setTimeWindowLayer(), GeopsyCore::SignalDB::signal(), MapWindow::signalsUpdate(), sources(), stalta(), GeopsyCore::TemporarySignalsGroup::subPool(), GeopsyGui::SignalLayer::subPoolUpdate(), SubSignalPool(), GeopsyCore::SubSignalPoolProcess::SubSignalPoolProcess(), subtractSignal(), subtractValue(), taper(), GeopsyCore::StationSignals::timeRange(), timeRange(), unglitch(), GeopsyGui::SignalLayer::updateGrid(), GraphicWindow::updateLabels(), GeopsyCore::SignalDB::xml_polish(), GeopsyCore::SignalFile::xml_writeChildren(), GeopsyCore::SignalGroup::xml_writeProperties(), and GeopsyCore::SignalDB::~SignalDB().

void GeopsyCore::SubSignalPool::exportTable ( QString  fileName,
const MetaDataFieldList param 
)

References GeopsyCore::MetaDataFieldList::begin(), begin(), GeopsyCore::MetaDataFactory::Duration, GeopsyCore::MetaDataFieldList::end(), end(), QGpCoreTools::endl(), GeopsyCore::MetaDataFactory::EndTime, GeopsyCore::Signal::header(), GeopsyCore::MetaDataFactory::instance(), MSG_ID, GeopsyCore::MetaDataFactory::name(), str, GeopsyCore::MetaDataFactory::T0, QGpCoreTools::tr(), and TRACE.

Referenced by TableWindow::exportTable().

{
  TRACE;
  QFile f(fileName);
  if(!f.open(QIODevice::WriteOnly)) {
    Message::warning(MSG_ID, tr( "Exporting table ..." ),
                         tr( "Unable to save file" ), Message::cancel());
    return;
  }
  QString str;
  QTextStream s(&f);
  s << tr("# This file contains all the variables that were listed in Geopsy's Table\n"
          "# You can edit this file as you want.\n"
          "# All columns must be separated by only one tabulation.\n"
          "# Lines starting with '#' are always ignored when importing.\n"
          "# The first line starting without '#' must contains the name of each variable.\n"
          "#\n");
  MetaDataFieldList::const_iterator itvar;
  for(itvar=param.begin();itvar!=param.end();++itvar) {
    s << MetaDataFactory::instance()->name(*itvar) << "\t";
  }
  s << endl;
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=*it;
    for (itvar=param.begin(); itvar!=param.end(); ++itvar) {
      switch (itvar->id()) {
      case MetaDataFactory::T0:
      case MetaDataFactory::EndTime:
      case MetaDataFactory::Duration:
        str=Number::secondsToTime(sig->header(*itvar).toDouble());
        break;
      default:
        str=sig->header(*itvar).toString();
        break;
      }
      s << str << "\t";
    }
    s << endl;
  }
}
void GeopsyCore::SubSignalPool::importTable ( QString  fileName)

References GeopsyCore::MetaDataFieldList::add(), GeopsyCore::MetaDataFieldList::begin(), begin(), GeopsyCore::MetaDataFactory::DeltaT, GeopsyCore::MetaDataFieldList::end(), end(), GeopsyCore::MetaDataIndex::id(), GeopsyCore::MetaDataFactory::index(), GeopsyCore::MetaDataFactory::instance(), GeopsyCore::MetaDataIndex::isValid(), QGpCoreTools::StringSection::isValid(), MSG_ID, QGpCoreTools::StringSection::nextField(), QGpCoreTools::StringSection::set(), GeopsyCore::Signal::setHeader(), GeopsyCore::Signal::setHeaderModified(), str, QGpCoreTools::StringSection::toString(), QGpCoreTools::tr(), and TRACE.

Referenced by TableWindow::importTable().

{
  TRACE;
  QFile f(fileName);
  if( !f.open(QIODevice::ReadOnly) ) {
    Message::warning(MSG_ID, tr( "Importing Table ..." ),
                         tr("Unable to open file %1").arg(fileName), Message::cancel());
    return ;
  }
  QString str;
  // Get the list of variable (IDs)
  QTextStream s(&f);
  str=s.readLine().trimmed();
  while(str[ 0 ]=='#' ) {
    str=s.readLine().trimmed(); // comment line
  }
  MetaDataFieldList varList;
  MetaDataIndex varItem;
  StringSection strItem;
  StringSection strLine(str);
  const QChar * ptr=0;
  strItem=strLine.nextField(ptr, "\t" );
  bool doDeltaT=false;
  while(strItem.isValid()) {
    varItem=MetaDataFactory::instance()->index(strItem.toString());
    if(!varItem.isValid()) {
      Message::warning(MSG_ID, tr("Importing Table ..."),
                       tr("Unrecognized meta data: '%1'").arg(strItem.toString()),
                       Message::cancel());
      return;
    }
    if(varItem.id()==MetaDataFactory::DeltaT) {
      switch (Message::warning(MSG_ID, tr( "Importing table ..." ),
                                    tr( "You are about to modify the DeltaT of your signals. "
                                        "This action may alter their time scale. "
                                        "Do you want to proceed?\n\n"
                                        "- If you answer 'No'', all the other variables will be imported as usual.\n"
                                        "- If you answer 'Cancel', nothing will be imported." ),
                                    Message::yes(), Message::no(),
                                    Message::cancel()) ) {
      case Message::Answer0:
        doDeltaT=true;
        break;
      case Message::Answer1:
        doDeltaT=false;
        break;
      default:
        return ;
      }
    }
    varList.add(varItem);
    strItem=strLine.nextField(ptr, "\t" );
  }
  // Get the values
  for(iterator it=begin(); it!=end() && !s.atEnd(); ++it) {
    Signal * sig=* it;
    str=s.readLine().trimmed();
    while(str[ 0 ]=='#' ) {
      str=s.readLine().trimmed(); // comment line
    }
    ptr=0;
    strLine.set(str.data(), str.size());
    strItem=strLine.nextField(ptr, "\t" );
    for(MetaDataFieldList::iterator itvar=varList.begin();itvar!=varList.end();++itvar) {
      if(itvar->id()!=MetaDataFactory::DeltaT || doDeltaT) {
        sig->setHeader(*itvar, strItem.toString());
      }
      strItem=strLine.nextField(ptr, "\t" );
    }
    sig->setHeaderModified(true);
  }
}
int GeopsyCore::SubSignalPool::indexOf ( const Signal sig) const [inline]
void GeopsyCore::SubSignalPool::insertSignal ( Signal sig,
Signal refSig = 0,
bool  before = true 
)

References QGpCoreTools::SharedObject::addReference(), indexOf(), and TRACE.

Referenced by StructureStationSignals::organizeSubPool().

{
  TRACE;
  if( !refSig)
    append(sig);
  else {
    int index=indexOf(refSig);
    if(index!=-1) {
      sig->addReference();
      if(before)
        insert(index, sig);
      else
        insert(index + 1, sig);
    }
  }
}
bool GeopsyCore::SubSignalPool::isEmpty ( ) const [inline]
static bool GeopsyCore::SubSignalPool::isExportFormat ( const SignalFileFormat f) [static]

References begin(), end(), and TRACE.

Referenced by GeopsyCore::SignalDB::isModified().

{
  TRACE;
  for(const_iterator it=begin(); it!=end(); ++it) {
    if((*it)->isHeaderModified())
      return true;
  }
  return false;
}

References begin(), end(), and TRACE.

Referenced by GeopsyMainWindow::activeWindowChanged().

{
  TRACE;
  for(const_iterator it=begin(); it!=end(); ++it) {
    if(( *it) ->isReadOnlySamples())
      return true;
  }
  return false;
}
int GeopsyCore::SubSignalPool::linearSearch ( const Point source,
const Point receiver 
)

References at(), count(), GeopsyCore::Signal::receiver(), GeopsyCore::Signal::source(), and TRACE.

{
  TRACE;
  for(int i=0; i < count(); ++i) {
    Signal * sig=at(i);
    if(source==sig->source() && receiver==sig->receiver()) {
      return i;
    }
  }
  return -1;
}

References begin(), end(), and TRACE.

Referenced by GeopsyMainWindow::exportSignal(), and ToolRefra::initStations().

{
  TRACE;
  int n=0;
  for(const_iterator it=begin(); it!=end(); ++it) {
    int t=(*it)->timePickCount();
    if(t>n) n=t;
  }
  return n;
}

Merge all traces of the subpool into a single trace

References addSignal(), begin(), CONST_LOCK_SAMPLES, database, GeopsyCore::DoubleSignal::deltaT(), end(), fastFourierTransform(), first(), isEmpty(), MSG_ID, name(), GeopsyCore::SignalTemplate< sampleType >::nSamples(), removeAll(), GeopsyCore::DynamicSignal::set(), GeopsyCore::Signal::setComponent(), GeopsyCore::Signal::setDeltaT(), GeopsyCore::Signal::setName(), GeopsyCore::Signal::setT0(), GeopsyCore::Signal::setTimeReference(), GeopsyCore::TimeRange::start(), GeopsyCore::Signal::t0(), timeRange(), QGpCoreTools::tr(), TRACE, GeopsyCore::DoubleSignal::type(), UNLOCK_SAMPLES, and GeopsyCore::DoubleSignal::Waveform.

Referenced by GeopsyCore::SignalProcess::mergeCore(), and mergeStations().

{
  TRACE;
  if(isEmpty()) return false;
  // Make sure all signals are in time series
  fastFourierTransform(Signal::Waveform);
  iterator it;
  Signal * sig;
  for(it=begin(); it!=end(); ++it) {
    sig=* it;
    if(sig->type()!=Signal::Waveform) {
      Message::warning(MSG_ID, tr( "Merging signals ..." ),
                           tr( "Some signals are not waveforms" ),
                           Message::cancel(), true);
      return false;
    }
  }
  // Get the min and max time
  TimeRange r=timeRange();
  // Check if they have the same sampling frequency
  it=begin();
  sig=* it;
  double dT=sig->deltaT();
  for( ; it!=end(); ++it) {
    double d_jump=(sig->t0() - r.start())/dT;
    int i_jump=(int) floor(d_jump + 0.5);
    if(dT!=sig->deltaT() && fabs(d_jump - (double) i_jump) < 0.001) {
      Message::warning(MSG_ID, tr( "Merging signals ..." ),
                           tr( "All signals must have the same sampling frequency "
                               "and differences between t0 must be a multiple of dT." ),
                               Message::cancel(), true);
      return false;
    }
  }
  // Allocate the new signal
  DynamicSignal * mergedsig=new DynamicSignal(first()->database());
  mergedsig->setDeltaT(first()->deltaT());
  mergedsig->setName(first()->name());
  mergedsig->setComponent(first()->component());
  mergedsig->setTimeReference(first()->timeReference());
  mergedsig->setT0(first()->t0());
  // Copy samples in it
  for(it=begin(); it!=end(); ++it) {
    sig=*it;
    CONST_LOCK_SAMPLES(double, samples, sig)
      mergedsig->set(sig->t0(), samples, sig->nSamples());
    UNLOCK_SAMPLES(sig)
  }
  removeAll();
  addSignal(mergedsig);
  return true;
}

Merge only signals that have common names, components and that have compatible T0.

References _name, GeopsyCore::SortKey::add(), addSignal(), begin(), GeopsyCore::SortKey::clear(), GeopsyCore::MetaDataFactory::Component, GeopsyCore::Signal::component(), GeopsyCore::DoubleSignal::deltaT(), end(), first(), isEmpty(), merge(), MSG_ID, GeopsyCore::MetaDataFactory::Name, GeopsyCore::Signal::name(), GeopsyCore::Signal::receiver(), removeAll(), SAFE_UNINITIALIZED, setName(), sort(), GeopsyCore::MetaDataFactory::T0, GeopsyCore::Signal::t0(), QGpCoreTools::tr(), TRACE, and GeopsyCore::Signal::Vertical.

Referenced by GeopsyCore::SignalProcess::mergeStationsCore().

{
  TRACE;
  // Sorting
  SortKey::clear();
  SortKey::add(MetaDataFactory::Name);
  SortKey::add(MetaDataFactory::Component);
  SortKey::add(MetaDataFactory::T0);
  sort();
  SubSignalPool toMerge;
  SubSignalPool merged;
  merged.setName(_name);
  double deltaT=0;
  Signal::Components comp;
  SAFE_UNINITIALIZED(comp, Signal::Vertical);
  QString stat;
  Point rec;
  for(iterator it=begin(); it!=end(); ) {
    Signal * sig=* it;
    if(deltaT==0) {
      deltaT=sig->deltaT();
      stat=sig->name();
      rec=sig->receiver();
      comp=sig->component();
      toMerge.addSignal(sig);
      ++it;
      continue;
    }
    if(sig->name()==stat && sig->receiver()==rec && sig->component()==comp) {
      if(sig->deltaT()!=deltaT) {
        Message::warning(MSG_ID, tr( "Merging station components" ),
                             tr( "For station %1, the sampling rate is not the "
                                 "same for all parts, skiping %2 part." )
                             .arg(stat).arg(Number::secondsToTime(sig->t0(), Number::Weeks, 3) ), Message::cancel(), true);
        return false;
      } else {
        toMerge.addSignal(sig);
      }
      ++it;
    } else {
      if( ! toMerge.merge()) return false;
      merged.addSignal(toMerge.first());
      toMerge.removeAll();
      deltaT=0;
    }
  }
  if( !toMerge.isEmpty()) {
    if( ! toMerge.merge()) return false;
    merged.addSignal(toMerge.first());
  }
  *this=merged;
  return true;
}
void GeopsyCore::SubSignalPool::multiply ( double  value)

References begin(), end(), GeopsyCore::SignalTemplate< sampleType >::multiply(), TRACE, and GeopsyCore::Signal::warnReadOnlySamples().

Referenced by GeopsyCore::SignalProcess::multiplyCore().

{
  TRACE;
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=* it;
    if(!sig->warnReadOnlySamples()) {
      sig->multiply(value);
    }
  }
}
const QString& GeopsyCore::SubSignalPool::name ( ) const [inline]
void GeopsyCore::SubSignalPool::normalizedCorrelations ( double  maxDelay,
const Signal referenceSig = 0 
)

Computes all possible normalized correlations from this subpool if referenceSig is null.

The correlation is computed with a maximum delay of delay.

References _name, addSignal(), at(), count(), GeopsyCore::GeopsyCoreEngine::currentDB(), GeopsyCore::geopsyCore, GeopsyCore::Signal::normalizedCorrelation(), setName(), GeopsyCore::Signal::setTemporary(), and TRACE.

Referenced by GeopsyCore::SignalProcess::normalizedCorrelationsCore().

{
  TRACE;
  SubSignalPool corrSubPool;
  corrSubPool.setName(_name);
  int n=count();
  if(referenceSig) {
    for(int i=0; i< n; i++ ) {
      Signal * sig=at(i);
      if(sig!=referenceSig) {
        Signal * corrSig=new Signal(geopsyCore->currentDB());
        corrSig->setTemporary();
        corrSig->normalizedCorrelation(referenceSig, sig, maxDelay);
        corrSubPool.addSignal(corrSig);
      }
    }
  } else {
    for(int i=0; i< n-1; i++ ) {
      Signal * sig=at(i);
      for(int j=i+1; j< n; j++) {
        Signal * corrSig=new Signal(geopsyCore->currentDB());
        corrSig->setTemporary();
        corrSig->normalizedCorrelation(sig, at(j), maxDelay);
        corrSubPool.addSignal(corrSig);
      }
    }
  }
  *this=corrSubPool;
}
bool GeopsyCore::SubSignalPool::operator!= ( const SubSignalPool o) const [inline]
{return !operator==(o);}
SubSignalPool & GeopsyCore::SubSignalPool::operator= ( const SubSignalPool o)

References _name, begin(), end(), isEmpty(), removeAll(), and TRACE.

{
  TRACE;
  if( !isEmpty())
    removeAll();
  QList<Signal *>::operator=(o);
  _name=o._name;
  for(iterator it=begin(); it!=end(); ++it) {
    ( *it) ->addReference();
  }
  return *this;
}
bool GeopsyCore::SubSignalPool::operator== ( const SubSignalPool o) const

References _name, at(), count(), and TRACE.

{
  TRACE;
  if(_name!=o._name) return false;
  int n=count();
  if(n!=o.count()) return false;
  for(int i=0; i<n; i++ ) {
    if(at(i)!=o.at(i)) return false;
  }
  return true;
}
void GeopsyCore::SubSignalPool::overSample ( double  factor)

References _name, addSignal(), at(), count(), GeopsyCore::geopsyCore, GeopsyCore::DoubleSignal::overSample(), setName(), GeopsyCore::GeopsyCoreEngine::setProgressMaximum(), GeopsyCore::GeopsyCoreEngine::setProgressValue(), and TRACE.

Referenced by GeopsyCore::SignalProcess::overSampleCore().

{
  TRACE;
  SubSignalPool sampledSignals;
  sampledSignals.setName(_name);
  geopsyCore->setProgressMaximum(count() - 1);
  geopsyCore->setProgressValue(0);
  for(int i=0; i < count(); ++i) {
    Signal * sig=at(i);
    Signal * newsig=new Signal( *sig);
    newsig->overSample(factor, sig);
    sampledSignals.addSignal(newsig);
    geopsyCore->setProgressValue(i);
  }
  *this=sampledSignals;
}
void GeopsyCore::SubSignalPool::pickCoppens ( const QString &  pickName,
double  delta,
double  tend,
double  tstart = 0.,
bool  relative = false,
double  mute = 0.0 
)

References begin(), end(), GeopsyCore::Signal::pickCoppens(), and TRACE.

{
  TRACE;
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=* it;
    sig->pickCoppens(pickName, delta, tend, tstart, relative, mute);
  }
}
void GeopsyCore::SubSignalPool::pickMinMax ( const QString &  pickNameb,
double  from,
double  to,
Signal::PickWhat  what 
)

References begin(), end(), and TRACE.

{
  TRACE;
  for(iterator it=begin(); it!=end(); ++it) {
    (*it)->pickMinMax(pickName, from, to, what);
  }
}

Returns a vector of all receivers.

References QGpCoreTools::Curve< pointType >::append(), begin(), end(), GeopsyCore::Signal::receiver(), and TRACE.

Referenced by GeopsyGui::SignalLayer::subPoolUpdate().

{
  TRACE;
  Curve<Point> l;
  for(const_iterator it=begin(); it!=end(); ++it) {
    Signal * sig=*it;
    l.append(sig->receiver());
  }
  return l;
}

References at(), GeopsyCore::Signal::component(), count(), removeAt(), and QGpCoreTools::SharedObject::removeReference().

{
  int i=0;
  while(i < int(count()) ) {
    Signal * sig=at(i);
    if(sig->component()==comp) {
      QList<Signal *>::removeAt(i);
      Signal::removeReference(sig);
    } else
      i++;
  }
}

References associate3Components(), begin(), end(), LOCK_SAMPLES, QGpCoreTools::CacheProcess::next(), GeopsyCore::SignalTemplate< sampleType >::nSamples(), QGpCoreTools::Point::set(), TRACE, UNLOCK_SAMPLES, GeopsyCore::Signal::warnReadOnlySamples(), and QGpCoreTools::Point2D::x().

Referenced by GeopsyCore::SignalProcess::rotateComponentsCore().

{
  TRACE;
  if( !associate3Components()) return ;
  int nSamples;
  Point p;
  Signal * sigV, * sigN, * sigE;
  SubSignalPoolProcess cp(*this);
  for(iterator it=begin(); it!=end(); ++it) {
    sigV=* it;
    nSamples=sigV->nSamples();
    LOCK_SAMPLES(double, sampV, sigV)
      ++it;
      if(it!=end()) {
        sigN=* it;
       LOCK_SAMPLES(double, sampN, sigN)
          ++it;
          if(it!=end()) {
            sigE=* it;
            LOCK_SAMPLES(double, sampE, sigE)
              if( !sigV->warnReadOnlySamples() &&
                  !sigN->warnReadOnlySamples() &&
                  !sigE->warnReadOnlySamples()) {
                for(int i=0;i < nSamples;i++ ) {
                  p.set(sampE[ i ], sampN[ i ], sampV[ i ] );
                  p=rotMatrix*p;
                  sampE[ i ]=p.x();
                  sampN[ i ]=p.y();
                  sampV[ i ]=p.z();
                }
              }
            UNLOCK_SAMPLES(sigE)
          }
        UNLOCK_SAMPLES(sigN)
      }
    UNLOCK_SAMPLES(sigV)
    cp.next(3);
  }
}

References begin(), end(), GeopsyCore::SignalTemplate< sampleType >::nSamples(), and TRACE.

{
  TRACE;
  int nSamples=0;
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=*it;
    nSamples += sig->nSamples();
  }
  return nSamples;
}
bool GeopsyCore::SubSignalPool::save ( QString  filePath,
bool  useOriginalBaseName,
SignalFileFormat  format,
int  maximumSignalsPerFile = 0,
const QString &  pickName = QString::null 
) const

Export subPool signals to file filePAth with format f. If format is SignalFile::Unknown, The format is guessed from the extension of filePath. If useOriginalBaseName is true, filePath is considered as a directory (f is mandatory).

References addSignal(), GeopsyCore::SignalFileFormat::Ascii, GeopsyCore::SignalFileFormat::AsciiOneColumn, begin(), count(), GeopsyCore::SignalFileFormat::Custom, GeopsyCore::SignalFileFormat::customFormat(), end(), QGpCoreTools::endl(), GeopsyCore::SignalFileFormat::fromSuffix(), GeopsyCore::SignalFileFormat::GeopsySignal, GeopsyCore::SignalFileFormat::Gse2, GeopsyCore::SignalFileFormat::id(), GeopsyCore::AbstractFileFormat::isReadOnly(), GeopsyCore::SignalFileFormat::MiniSeed, MSG_ID, GeopsyCore::SignalFileFormat::MultiGse2, removeAll(), GeopsyCore::SignalFileFormat::SacBigEndian, GeopsyCore::SignalFileFormat::SacLittleEndian, GeopsyCore::SignalFileFormat::Saf, GeopsyCore::AbstractFileFormat::save(), saveGeopsySignal(), GeopsyCore::SignalFileFormat::Seg2, GeopsyCore::SignalFileFormat::SegYBigEndian, GeopsyCore::SignalFileFormat::SegYLittleEndian, SIGNALFILEFORMAT_READONLY, GeopsyCore::SignalFileFormat::Single, GeopsyCore::AbstractFileFormat::storage(), GeopsyCore::SignalFileFormat::SuBigEndian, GeopsyCore::SignalFileFormat::SuLittleEndian, GeopsyCore::SignalFileFormat::Tomo, GeopsyCore::SignalFileFormat::toString(), QGpCoreTools::tr(), TRACE, GeopsyCore::SignalFileFormat::Unknown, and GeopsyCore::SignalFileFormat::Wav.

Referenced by GeopsyCore::SignalProcess::exportFileCore(), GeopsyMainWindow::exportSignal(), modeExport(), and Process::run().

{
  TRACE;
  // Split eventually the subpool into various subsubpool of maximumSignalsPerFile signals and save them.
  if(maximumSignalsPerFile>0) {
    SubSignalPool subPool;
    maximumSignalsPerFile--;
    for(const_iterator it=begin();it!=end();it++) {
      subPool.addSignal( *it);
      if(subPool.count()==maximumSignalsPerFile) {
        if(!save(filePath, useOriginalBaseName, format, 0, pickName)) {
          return false;
        }
        subPool.removeAll();
      }
    }
    return true;
  }
  if(format.id()==SignalFileFormat::Unknown) {
    if(useOriginalBaseName) {
      Message::warning(MSG_ID, tr("Exporting signals"), tr("No path given with option 'use original base name'. Cannot guess "
                                                            "ouput file format from extension."), true);
      return false;
    }
    format=SignalFileFormat::fromSuffix(filePath);
    if(format.id()==SignalFileFormat::Unknown) {
      Message::warning(MSG_ID, tr("Exporting signals"), tr("Cannot determine export format from file extension"), true);
      return false;
    }
  }
  if(useOriginalBaseName) {
    QFileInfo fi(filePath);
    if(!fi.exists() || !fi.isDir()) {
      Message::warning(MSG_ID, tr("Exporting signals"),
                       tr("%1 does not exists or is not a directory (option 'original base name' is on).").arg(filePath),
                       true);
      return false;
    }
  }
  switch (format.id()) {
  case SignalFileFormat::Custom:
    if(!format.customFormat() || format.customFormat()->isReadOnly()) {
      App::stream() << tr("Format %1 is currently not supported for export.").arg(format.toString()) << endl;
      return false;
    }
    if(format.customFormat()->storage()==SignalFileFormat::Single) {
      break;
    }
    // Else custom format with export capabilities of multiple signal in one file
  case SignalFileFormat::Seg2:
  case SignalFileFormat::SuLittleEndian:
  case SignalFileFormat::SuBigEndian:
  case SignalFileFormat::SegYLittleEndian:
  case SignalFileFormat::SegYBigEndian:
  case SignalFileFormat::Gse2:
  case SignalFileFormat::MultiGse2:
  case SignalFileFormat::GeopsySignal:
  case SignalFileFormat::Tomo:
  case SignalFileFormat::Ascii:
  case SignalFileFormat::AsciiOneColumn:
  case SignalFileFormat::Saf:
  case SignalFileFormat::Wav:
  case SignalFileFormat::MiniSeed:
    // For multi signal formats
    if(!exportFilePath(filePath, useOriginalBaseName, format)) return false;
    if(useOriginalBaseName){
      QFileInfo fi(filePath);
      QString newFilePath=File::uniqueName(fi.fileName(), fi.path());
      if(newFilePath!=filePath) {
        if(Message::warning(MSG_ID, tr("Exporting signals"), tr("File %1 already exists, saving to %2?").arg(filePath).arg(newFilePath),
                             Message::yes(), Message::no())==Message::Answer1) {
          return false;
        }
        App::stream() << tr("File %1 already exists, saving to %2").arg(filePath).arg(newFilePath) << endl;
        filePath=newFilePath;
      }
    }
    break;
  case SignalFileFormat::SacLittleEndian:
  case SignalFileFormat::SacBigEndian:
    break;
  SIGNALFILEFORMAT_READONLY
    App::stream() << tr("Format %1 is currently not supported for export.").arg(format.toString()) << endl;
    return false;
  }
  switch (format.id()) {
  case SignalFileFormat::Seg2:
    return saveSeg2(filePath);
  case SignalFileFormat::SuLittleEndian:
    return saveSu(filePath, QDataStream::LittleEndian);
  case SignalFileFormat::SuBigEndian:
    return saveSu(filePath, QDataStream::BigEndian);
  case SignalFileFormat::SegYLittleEndian:
    return saveSegY(filePath, QDataStream::LittleEndian);
  case SignalFileFormat::SegYBigEndian:
    return saveSegY(filePath, QDataStream::BigEndian);
  case SignalFileFormat::SacLittleEndian:
    return saveSac(filePath, useOriginalBaseName, QDataStream::LittleEndian);
  case SignalFileFormat::SacBigEndian:
    return saveSac(filePath, useOriginalBaseName, QDataStream::BigEndian);
  case SignalFileFormat::Gse2:
  case SignalFileFormat::MultiGse2:
    return saveGse2(filePath);
  case SignalFileFormat::GeopsySignal:
    return saveGeopsySignal(filePath);
  case SignalFileFormat::Tomo:
    return saveArrivalTimes(filePath, pickName);
  case SignalFileFormat::Ascii:
    if(!format.customFormat()) {
      return saveAsciiMultiColumns(filePath);
    }
    break;
  case SignalFileFormat::Custom:
    if(format.customFormat()) {
      return format.customFormat()->save(*this, filePath);
    }
    break;
  case SignalFileFormat::AsciiOneColumn:
    return saveAsciiOneColumn(filePath);
  case SignalFileFormat::Saf:
    return saveSaf(filePath);
  case SignalFileFormat::Wav:
    return saveWav(filePath);
  case SignalFileFormat::MiniSeed:
    return saveMiniSeed(filePath);
  SIGNALFILEFORMAT_READONLY
    break;
  }
  return false;
}
bool GeopsyCore::SubSignalPool::saveGeopsySignal ( QString  filePath) const

Save samples in a binary format (double) for quick access. This format is machine dependent. Hence, a magic int and double number is stored at the beginning of the file. If the correct value can be retrieved there very little chance than the internal representation of number is different on this machine and on the machine that generated the file.

Format for current version (2) ------------------------------

Header: char*16 (16) "GeopsySignal " (tag ending with 0) int (4) Magic integer number double (8) Magic float number int (4) version (currently=2) int (4) offset to first data (currently=22+n*4) int (4) nSignals int*nSignals (4*nSignals) nSamples

Format for each signal: double*nSamples (8*...) samples

N samples is stored even if it is not necessary for database reloading. It makes this format a minimum self-contained. This binary file format is generally with a database file (.gpy) with contains the header information with a XML format.

Format for version 1 -------------------- Header: char*10 (10) "DBSignals" (tag) int (4) version (=1) int (4) offset to first data (currently=22+n*12) int (4) nSignals int*nSignals (4*...) nSamples int*nSignals (4*...) conversionFactors

Format for each signal: double*nSamples (8*...) samples

References begin(), CONST_LOCK_SAMPLES, count(), end(), GeopsyCore::GeopsySignalHeader::field, GEOPSYSIGNAL_HEADERSIZE, GEOPSYSIGNAL_MAGICFLOAT, GEOPSYSIGNAL_MAGICINT, GEOPSYSIGNAL_TAG, GEOPSYSIGNAL_VERSION, GeopsyCore::SignalTemplate< sampleType >::nSamples(), GeopsyCore::GeopsySignalHeader::raw, GeopsyCore::DoubleSignal::saveType(), TRACE, UNLOCK_SAMPLES, and GeopsyCore::DoubleSignal::Waveform.

Referenced by GeopsyCore::SignalFile::save(), and save().

{
  TRACE;
  QFile f(filePath);
  if( !f.open(QIODevice::WriteOnly) ) return false;
  GeopsySignalHeader h;
  memcpy(h.field.tag, GEOPSYSIGNAL_TAG, 16);
  h.field.magicInt=GEOPSYSIGNAL_MAGICINT;
  h.field.magicFloat=GEOPSYSIGNAL_MAGICFLOAT;
  h.field.version=GEOPSYSIGNAL_VERSION;
  h.field.nSignals=count();
  h.field.offset=GEOPSYSIGNAL_HEADERSIZE + h.field.nSignals * 4;
  if(f.write(h.raw, GEOPSYSIGNAL_HEADERSIZE)!=GEOPSYSIGNAL_HEADERSIZE) return false;
  for(const_iterator it=begin(); it!=end(); ++it) {
    qint32 nSamples=( *it) ->nSamples();
    if(f.write((const char *)&nSamples, 4)!=4) return false;
  }
  for(const_iterator it=begin(); it!=end(); ++it) {
    int nWritten=0;
    const DoubleSignal * sig=const_cast<const Signal *>(*it)->saveType(Signal::Waveform);
    CONST_LOCK_SAMPLES(double, sigSamples, sig)
      nWritten=f.write((const char *)sigSamples, sizeof(double)*sig->nSamples());
    UNLOCK_SAMPLES(sig)
    (*it)->restoreType(sig);
    if(!sigSamples || nWritten!=(int)sizeof(double)*sig->nSamples()) return false;
  }
  return true;
}

References begin(), end(), and TRACE.

Referenced by GeopsyCore::SignalDB::save().

{
  TRACE;
  for(const_iterator it=begin(); it!=end(); ++it) {
    (*it)->setHeaderModified(b);
  }
}
void GeopsyCore::SubSignalPool::setName ( const QString &  n) [inline]
void GeopsyCore::SubSignalPool::shift ( double  dt)

Returns a vector of all receivers.

References QGpCoreTools::Curve< pointType >::append(), begin(), end(), GeopsyCore::Signal::source(), and TRACE.

Referenced by ToolRefra::initStations().

{
  TRACE;
  Curve<Point> l;
  for(const_iterator it=begin(); it!=end(); ++it) {
    Signal * sig=*it;
    l.append(sig->source());
  }
  return l;
}
void GeopsyCore::SubSignalPool::stalta ( double  tsta,
double  tlta 
)

Computes STA/LTA ratios

References _name, GeopsyCore::DoubleSignal::abs(), addSignal(), begin(), GeopsyCore::DoubleSignal::copySamplesFrom(), end(), fastFourierTransform(), setName(), GeopsyCore::DoubleSignal::stalta(), TRACE, and GeopsyCore::DoubleSignal::Waveform.

Referenced by GeopsyCore::SignalProcess::staltaCore().

{
  TRACE;
  SubSignalPool staltaSignals;
  staltaSignals.setName(_name);
  // Make sure all signals are in time series
  fastFourierTransform(Signal::Waveform);
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=* it;
    DoubleSignal * cpsig=new DoubleSignal( *sig);
    cpsig->copySamplesFrom(sig);
    cpsig->abs();
    Signal * ratiosig=new Signal( *sig);
    cpsig->stalta(tsta, tlta, ratiosig);
    delete cpsig;
    staltaSignals.addSignal(ratiosig);
  }
  *this=staltaSignals;
}
void GeopsyCore::SubSignalPool::stddevClip ( double  factor)

References begin(), GeopsyCore::Signal::constLockSamples(), end(), fastFourierTransform(), QGpCoreTools::CacheProcess::next(), GeopsyCore::SignalTemplate< sampleType >::subtractSignal(), TRACE, GeopsyCore::SignalTemplate< sampleType >::unlockSamples(), GeopsyCore::Signal::warnReadOnlySamples(), and GeopsyCore::DoubleSignal::Waveform.

Referenced by GeopsyCore::SignalProcess::subtractSignalCore().

{
  TRACE;
  // Make sure all signals are in time series
  fastFourierTransform(Signal::Waveform);
  bool bySigIncludedInSubpool=false;
  SubSignalPoolProcess cp(*this);
  bysig->constLockSamples();
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=* it;
    if(sig!=bysig) { // avoid bysig to zeroed, postponed to the end
      if( !sig->warnReadOnlySamples()) {
        sig->subtractSignal(bysig);
      }
    } else {
      bySigIncludedInSubpool=true;
    }
    cp.next();
  }
  if(bySigIncludedInSubpool) { // Set it to 0
    if(!bysig->warnReadOnlySamples()) {
      bysig->subtractSignal(bysig);
    }
  }
  bysig->unlockSamples();
}

References at(), count(), fastFourierTransform(), GeopsyCore::SignalTemplate< sampleType >::subtractSignal(), TRACE, GeopsyCore::Signal::warnReadOnlySamples(), and GeopsyCore::DoubleSignal::Waveform.

Referenced by GeopsyCore::SignalProcess::subtractSignalsCore().

{
  TRACE;
  if(count()!=bySubPool->count())
    return ;
  // Make sure all signals are in time series
  fastFourierTransform(Signal::Waveform);
  for(int i=0; i < count(); ++i) {
    Signal * sig=at(i);
    Signal * bysig=bySubPool->at(i);
    if(!sig->warnReadOnlySamples()) {
      sig->subtractSignal(bysig);
    }
  }
}
void GeopsyCore::SubSignalPool::subtractValue ( double  val = 0.0)

References begin(), end(), GeopsyCore::DoubleSignal::subtractValue(), TRACE, and GeopsyCore::Signal::warnReadOnlySamples().

Referenced by Station::filter1(), Station::filter2(), and GeopsyCore::SignalProcess::subtractValueCore().

{
  TRACE;
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=* it;
    if(!sig->warnReadOnlySamples()) {
      sig->subtractValue(val);
    }
  }
}
void GeopsyCore::SubSignalPool::taper ( const TimeRangeParameters range,
const TaperParameters param 
)

Multiplies signal in in time domain by a window function.

References GeopsyCore::TimeRangeParameters::absoluteRange(), begin(), end(), GeopsyCore::Signal::taper(), TRACE, and GeopsyCore::Signal::warnReadOnlySamples().

Referenced by GeopsyCore::SignalProcess::taperCore().

{
  TRACE;
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=* it;
    if(!sig->warnReadOnlySamples()) {
      TimeRange tw=range.absoluteRange(sig);
      sig->taper(tw, param);
    }
  }
}

Find minimum and maximum time over all signal of subPool and returns it as a TimeRange. It handles signals not in Waveform and return the spectrum limits.

References begin(), GeopsyCore::DoubleSignal::deltaF(), GeopsyCore::DoubleSignal::deltaT(), end(), GeopsyCore::DoubleSignal::isComplex(), GeopsyCore::DoubleSignal::isSpectrum(), GeopsyCore::SignalTemplate< sampleType >::nSamples(), GeopsyCore::Signal::t0(), tmax, tmin, and TRACE.

Referenced by GeopsyGui::SignalLayer::boundingRect(), ManualPick::init(), merge(), GraphicWindow::setLimits(), GeopsyGui::TimeRangeParameterWidget::setPicks(), and GraphicWindow::signalsUpdate().

{
  TRACE;
  double tmin=1e99;
  double tmax=-1e99;
  for(const_iterator it=begin(); it!=end(); ++it) {
    Signal * sig=* it;
    double tminsig, tmaxsig;
    if(sig->isSpectrum()) {
      if(sig->isComplex())
        tmaxsig=0.5/sig->deltaT();
      else
        tmaxsig=sig->deltaF() * (double) sig->nSamples();
      tminsig=0.1;
    } else {
      tminsig=sig->t0();
      if(sig->isComplex())
        tmaxsig=0.5/sig->deltaF();
      else
        tmaxsig=tminsig + sig->deltaT() * (double) sig->nSamples();
    }
    if(tminsig < tmin)
      tmin=tminsig;
    if(tmaxsig > tmax)
      tmax=tmaxsig;
  }
  return TimeRange(tmin,tmax);
}
void GeopsyCore::SubSignalPool::unglitch ( double  threshold)

References begin(), end(), TRACE, GeopsyCore::DoubleSignal::unglitch(), and GeopsyCore::Signal::warnReadOnlySamples().

{
  TRACE;
  for(iterator it=begin(); it!=end(); ++it) {
    Signal * sig=* it;
    if( !sig->warnReadOnlySamples()) {
      sig->unglitch(threshold);
    }
  }
}

References GeopsyCore::ComplexSignal::abs(), at(), count(), GeopsyCore::geopsyCore, GeopsyCore::DoubleSignal::morletWavelet(), GeopsyCore::SignalTemplate< sampleType >::nSamples(), GeopsyCore::GeopsyCoreEngine::setProgressMaximum(), GeopsyCore::GeopsyCoreEngine::setProgressValue(), GeopsyCore::DoubleSignal::setType(), TRACE, GeopsyCore::Signal::warnReadOnlySamples(), and GeopsyCore::DoubleSignal::Waveform.

Referenced by GeopsyCore::SignalProcess::waveletTransformCore().

{
  TRACE;
  geopsyCore->setProgressMaximum(count() - 1);
  for(int i=0; i < count(); ++i) {
    Signal * sig=at(i);
    geopsyCore->setProgressValue(i);
    if(!sig->warnReadOnlySamples()) {
      ComplexSignal * sigComp=sig->morletWavelet(param);
      DoubleSignal * sigAbs=sigComp->abs();
      sig->SignalTemplate<double>::copySamplesFrom(sigAbs, 0, 0, sig->nSamples());
      sig->setType(Signal::Waveform);
      delete sigAbs;
      delete sigComp;
    }
  }
}

Member Data Documentation

QString GeopsyCore::SubSignalPool::_name [protected]

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