All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions
GeopsyCore::SparseKeepSignal Class Reference

Brief description of class still missing. More...

#include <SparseKeepSignal.h>

Inheritance diagram for GeopsyCore::SparseKeepSignal:
GeopsyCore::SparseTimeRange

List of all members.

Public Member Functions

void copySamplesFrom (const SparseKeepSignal &o)
void initValues (int value, double start=-1e99, double end=1e99)
SparseKeepSignalintersection (const TimeRange &r) const
QVector< KeepSignal * > keeps (const TimeRange &r) const
const QVector< KeepSignal * > & keeps () const
void printDebug () const
void remove (const TimeRange &r)
bool setSampling (const TimeRange &r, double deltaT)
 SparseKeepSignal ()
 SparseKeepSignal (const SparseTimeRange &r)
 SparseKeepSignal (const SparseKeepSignal &o)
SparseTimeRange timeRange () const
 ~SparseKeepSignal ()

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

References TRACE.

Referenced by intersection().

Description of constructor still missing

References GeopsyCore::SparseTimeRange::ranges(), and TRACE.

    : SparseTimeRange(r)
{
  TRACE;
  const QVector<TimeRange>& rs=ranges();
  int n=rs.count();
  _keeps.resize(n);
  for(int i=0; i<n; i++) {
    _keeps[i]=0;
  }
}

Copy properties of keep signals, not their values. You must call initValues() or copySamplesFrom()

References TRACE.

    : SparseTimeRange(o)
{
  TRACE;
  int n=o._keeps.count();
  _keeps.resize(n);
  for(int i=0; i<n; i++) {
    _keeps[i]=new KeepSignal(*o._keeps[i]);
  }
}

Description of destructor still missing

References TRACE.

{
  TRACE;
  qDeleteAll(_keeps);
}

Member Function Documentation

References TRACE.

Referenced by GeopsyCore::TimeRangeList::addBlanks().

{
  TRACE;
  int n=_keeps.count();
  ASSERT(n==o._keeps.count());
  for(int i=0; i<n; i++) {
    _keeps[i]->copySamplesFrom(o._keeps[i]);
  }
}
void GeopsyCore::SparseKeepSignal::initValues ( int  value,
double  start = -1e99,
double  end = 1e99 
)

References GeopsyCore::KeepSignal::deltaT(), GeopsyCore::SignalTemplate< sampleType >::initValues(), GeopsyCore::SignalTemplate< sampleType >::nSamples(), GeopsyCore::KeepSignal::t0(), and TRACE.

Referenced by RealTimeArrayManager::createTasks(), GeopsyCore::TimeRangeList::inverse(), and MonoStation::AbstractStation::keep().

{
  TRACE;
  int n=_keeps.count();
  for(int i=0;i<n;i++) {
    KeepSignal * keep=_keeps[i];
    double invDeltaT=1.0/keep->deltaT();
    int iStart;
    if(start<keep->t0()) iStart=0;
    else {
      iStart=(int)round((start-keep->t0())*invDeltaT);
      if(iStart>=keep->nSamples()) continue;
    }
    int iEnd;
    if(end>keep->t0()+keep->nSamples()*keep->deltaT()) iEnd=keep->nSamples()-1;
    else {
      iEnd=(int)round((end-keep->t0())*invDeltaT);
      if(iEnd<0) continue;
    }
    keep->initValues(value,iStart,iEnd-iStart+1);
  }
}

Reimplemented from GeopsyCore::SparseTimeRange.

References GeopsyCore::TimeRange::end(), GeopsyCore::KeepSignal::endTime(), GeopsyCore::SparseTimeRange::index(), GeopsyCore::SparseTimeRange::intersection(), SparseKeepSignal(), GeopsyCore::TimeRange::start(), GeopsyCore::KeepSignal::t0(), and TRACE.

{
  TRACE;
  int iFirst=index(r.start());
  SparseKeepSignal * res=new SparseKeepSignal(SparseTimeRange::intersection(iFirst, r));
  int n=res->ranges().count();
  res->_keeps.resize(n);
  if(n>0) {
    for(int i=n-2; i>0; i--) {
      res->_keeps[i]=new KeepSignal(*_keeps.at(iFirst+i));
    }
    const KeepSignal * kStart=_keeps.at(iFirst+n-1);
    if(r.start()>kStart->t0()) {
      res->_keeps[0]=cutStart(kStart, r.start());
    } else {
      res->_keeps[0]=new KeepSignal(*kStart);
    }
    const KeepSignal * kEnd=_keeps.at(iFirst+n-1);
    if(r.end()<kEnd->endTime()) {
      res->_keeps[n-1]=cutEnd(kEnd, r.end());;
    } else {
      res->_keeps[n-1]=new KeepSignal(*kEnd);
    }
  }
  return res;
}

Returns all keeps hit by r

References GeopsyCore::TimeRange::end(), GeopsyCore::SparseTimeRange::index(), GeopsyCore::SparseTimeRange::isNull(), GeopsyCore::SparseTimeRange::ranges(), GeopsyCore::TimeRange::start(), and TRACE.

Referenced by GeopsyCore::TimeRangeList::add(), and GeopsyCore::StationSignals::setKeep().

{
  TRACE;
  QVector<KeepSignal *> res;
  if(isNull()) return res;
  int i=index(r.start());
  const QVector<TimeRange>& rs=ranges();
  int n=rs.count();
  for(;i<n && rs.at(i).end()<r.end();i++) {
    res.append(_keeps.at(i));
  }
  // Add the last block that had its end after r.end() but can have a start() before.
  if(i<n && rs.at(i).start()<r.end()) {
    res.append(_keeps.at(i));
  }
  return res;
}
{return _keeps;}

Removes all ranges that overlap with r

Reimplemented from GeopsyCore::SparseTimeRange.

References GeopsyCore::TimeRange::end(), GeopsyCore::KeepSignal::endTime(), GeopsyCore::SparseTimeRange::index(), GeopsyCore::SparseTimeRange::ranges(), GeopsyCore::TimeRange::start(), GeopsyCore::KeepSignal::t0(), and TRACE.

Referenced by GeopsyCore::StationSignals::setSampling().

{
  TRACE;
  int iFirst=index(r.start());
  KeepSignal * kStart=_keeps.at(iFirst);
  if(r.start()>kStart->t0() && r.start()<kStart->endTime()) {
    _keeps[iFirst]=cutEnd(kStart, r.start());
    delete kStart;
  }
  int nRemoved=SparseTimeRange::remove(iFirst, r);
  for(int i=nRemoved-1; i>=0; i--) {
    delete _keeps[iFirst+i];
  }
  _keeps.remove(iFirst, nRemoved);
  if(iFirst<ranges().count()) {
    KeepSignal * kEnd=_keeps.at(iFirst);
    if(r.end()>kEnd->t0() && r.end()<kEnd->endTime()) {
      _keeps[iFirst]=cutStart(kEnd, r.end());
      delete kEnd;
    }
  }
}
bool GeopsyCore::SparseKeepSignal::setSampling ( const TimeRange r,
double  deltaT 
)

Set T0 and deltaT for all continuous blocks hit by r. T0 is set to match r with a multiple of deltaT(). The samples are not affected by this function.

Returns false if T0 is already set but not compatible with r. Tests also deltaT.

References GeopsyCore::KeepSignal::deltaT(), GeopsyCore::TimeRange::end(), GeopsyCore::SparseTimeRange::index(), GeopsyCore::SparseTimeRange::ranges(), GeopsyCore::KeepSignal::setDeltaT(), GeopsyCore::KeepSignal::setT0(), GeopsyCore::TimeRange::start(), GeopsyCore::KeepSignal::t0(), and TRACE.

Referenced by GeopsyCore::StationSignals::setSampling().

{
  TRACE;
  if(_keeps.isEmpty()) return true;
  double t=r.start();
  int i=index(t);
  double invDeltaT=1.0/deltaT;
  const QVector<TimeRange>& rs=ranges();
  for(;i<rs.count();i++) {
    KeepSignal * k=_keeps[i];
    const TimeRange& r=rs.at(i);
    if(rs.at(i).start()>=r.end()) break;
    if(k) {
      if(k->deltaT()!=deltaT) return false;
      double dt=fabs(k->t0()-t);
      int nSamples=(int)round(fabs((k->t0()-t)*invDeltaT));
      if(fabs(nSamples*deltaT-dt)*invDeltaT>0.001) { // 1/1000 sampling period
        return false;
      }
    } else {
      //printf("Arbitrary limits %lf to %lf\n",r.start(), r.end());
      double t0=t-floor((t-r.start())*invDeltaT)*deltaT;
      // +1 is there because the time end cuts the last time step which beginning
      // is still inside time range
      KeepSignal * k=new KeepSignal((int)floor((r.end()-t0)*invDeltaT)+1);
      k->setDeltaT(deltaT);
      k->setT0(t0);
      _keeps[i]=k;
    }
  }
  return true;
}

Referenced by ArrayCore::ArrayProcess::setFrequency().

{return *this;}

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