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

Brief description of class still missing. More...

#include <MiniSeedTrace.h>

List of all members.

Classes

class  Record

Public Member Functions

void addRecord (LibMSeed::MSRecord *msr, off_t pos)
bool belongsTo (LibMSeed::MSRecord *msr)
QString channel () const
QString location () const
 MiniSeedTrace (LibMSeed::MSRecord *msr)
QString network () const
int nSamples () const
MiniSeedRecords records () const
double samplingFrequency () const
MiniSeedTracesplit ()
QDateTime startTime () const
QString station () const
double t0 () const
 ~MiniSeedTrace ()

Detailed Description

Brief description of class still missing.

Represents a Mini Seed trace. This class is used only while reading a new file. Function records() returns a compact description of records to be stored in Signal.


Constructor & Destructor Documentation

GeopsyCore::MiniSeedTrace::MiniSeedTrace ( LibMSeed::MSRecord *  msr)

Description of constructor still missing

References TRACE.

{
  TRACE;
  _network=msr->network;
  _station=msr->station;
  _location=msr->location;
  _channel=msr->channel;
  _samplingFrequency=msr->samprate;
  _deltaT=1.0/_samplingFrequency;
  _sorted=false;
}

References TRACE.

{
  TRACE;
  qDeleteAll(_records);
}

Member Function Documentation

void GeopsyCore::MiniSeedTrace::addRecord ( LibMSeed::MSRecord *  msr,
off_t  pos 
)

Add new samples from record msr located at position pos in mseed volume.

References TRACE.

Referenced by GeopsyCore::MiniSeedVolume::read().

{
  TRACE;
  Record * rec=new Record;
  _records.append(rec);
  LibMSeed::BTime& t=msr->fsdh->start_time;
  rec->_startTime=QDateTime(QDate( t.year, 1, 1), QTime(t.hour, t.min, t.sec));
  rec->_startTime=rec->_startTime.addDays(t.day -1);
  rec->_t0=t.fract * 0.0001; // Time is stored with a precision of 100 us in seed blocket
                               // t.fract is the fractional second from 0 to 9999
  rec->_nSamples=msr->samplecnt;
  rec->_byteLength=msr->reclen;
  rec->_pos=pos;
  /*printf("Adding record to %s_%s:%s\t\t%i\t%i\t%li\t%s\t%lf\n",
         _network.toAscii().data(), _station.toAscii().data(), _channel.toAscii().data(),
         rec->_nSamples, rec->_byteLength, rec->_pos,
         rec->_startTime.toString("yyyy-MM-dd hh:mm:ss").toAscii().data(), rec->_t0);*/
}
bool GeopsyCore::MiniSeedTrace::belongsTo ( LibMSeed::MSRecord *  msr)

References TRACE.

{
  TRACE;
  return _network==msr->network &&
         _station==msr->station &&
         _location==msr->location &&
         _channel==msr->channel &&
         _samplingFrequency==msr->samprate;
}
QString GeopsyCore::MiniSeedTrace::channel ( ) const [inline]
{return _channel;}
QString GeopsyCore::MiniSeedTrace::location ( ) const [inline]
{return _location;}
QString GeopsyCore::MiniSeedTrace::network ( ) const [inline]
{return _network;}

References TRACE.

{
  TRACE;
  int n=0;
  for(QList<Record*>::const_iterator it=_records.begin(); it!=_records.end(); it++) {
    n+=(*it)->_nSamples;
  }
  return n;
}

References GeopsyCore::MiniSeedRecords::add(), and TRACE.

{
  TRACE;
  int n=_records.count();
  MiniSeedRecords recs;
  for(int i=0; i<n; i++) {
    const Record& r=*_records.at(i);
    recs.add(r._pos, r._byteLength);
  }
  return recs;
}
{return _samplingFrequency;}

Slit non-continuous trace, does nothing except sorting records by increasing time if the trace is continous.

References TRACE.

Referenced by GeopsyCore::MiniSeedVolume::read().

{
  TRACE;
  if(!_sorted) {
    qSort(_records.begin(), _records.end(), Record::lessThan);
    _sorted=true;
  }
  int n=_records.count();
  Record * last=_records.at(0);
  for(int i=1; i<n;i++) {
    Record * current=_records.at(i);
    double elapsed=last->_startTime.secsTo(current->_startTime)-last->_t0+current->_t0;
    /*printf("Checking continuity of %s_%s:%s\t\t%i\t%lf\t%s\t%lf\n",
          _network.toAscii().data(), _station.toAscii().data(), _channel.toAscii().data(),
          current->_nSamples, fabs(nElapsed - last->_nSamples),
          current->_startTime.toString("yyyy-MM-dd hh:mm:ss").toAscii().data(), current->_t0);*/
    double duration=_deltaT*last->_nSamples;
    if(fabs(elapsed-duration)>=0.0001) { // MiniSeed has a 100 us presicion on times
      if(elapsed>duration) {
        MiniSeedTrace * sig=new MiniSeedTrace(*this);
        // Move all remaining records including the current to the new trace
        for(int j=i; j<n; j++) {
          sig->_records.append(_records.at(j));
        }
        for(int j=i; j<n; j++) {
          _records.removeLast();
        }
        return sig;
      } else {
        // overlaping records: look for matching records further in the list
        MiniSeedTrace * sig=new MiniSeedTrace(*this);
        splitOverlapping(i, sig);
        /*printf("After split overlapping new sig[%i] starts at %s %lf and ends at %s %lf\n", sig->nSamples(),
               sig->_records.first()->_startTime.toString("yyyy-MM-dd hh:mm:ss").toAscii().data(), sig->_records.first()->_t0,
               sig->_records.last()->_startTime.toString("yyyy-MM-dd hh:mm:ss").toAscii().data(), sig->_records.last()->_t0);
        printf("After split overlapping this sig[%i] starts at %s %lf and ends at %s %lf\n", nSamples(),
               _records.first()->_startTime.toString("yyyy-MM-dd hh:mm:ss").toAscii().data(), _records.first()->_t0,
               _records.last()->_startTime.toString("yyyy-MM-dd hh:mm:ss").toAscii().data(), _records.last()->_t0);*/
        return sig;
      }
    } else {
      last=current;
    }
  }
  return 0;
}
QDateTime GeopsyCore::MiniSeedTrace::startTime ( ) const [inline]
{return _records.first()->_startTime;}
QString GeopsyCore::MiniSeedTrace::station ( ) const [inline]
{return _station;}
double GeopsyCore::MiniSeedTrace::t0 ( ) const [inline]
{return _records.first()->_t0;}

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