All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Static Public Member Functions
QGpCoreWave::Profile Class Reference

Storage for a 1D profile. More...

#include <Profile.h>

Inheritance diagram for QGpCoreWave::Profile:
QGpCoreWave::Resistivity1DModel

List of all members.

Public Member Functions

void average ()
void clear ()
void collectDepths (QVector< double > &depths) const
int count () const
Curve< Point2Dcurve () const
const QVector< double > & depths () const
double interpoleAt (double depth)
void inverse ()
void operator= (const Profile &p)
void print () const
void readReport (QDataStream &s)
void resample (const Profile &p, const QVector< double > &baseD)
void resample (const QVector< double > &baseD)
void resample (const QVector< double > &baseD1, const QVector< double > &baseD2)
void resize (int n)
void setDepth (int i, double depth)
void setSamples (const QVector< double > &baseD)
void setValue (int i, double value)
void toStream (QTextStream &s, bool plotMode) const
double uniformAt (double depth)
const QVector< double > & values () const
QVector< double > & values ()
void writeReport (QDataStream &s) const

Static Public Member Functions

static void report2plot (QDataStream &s, Point2D *points)

Detailed Description

Storage for a 1D profile.

A profile is made of layers with a uniform value over the depth axis. Internally 2 vectors ar maintained, one for the depths and the other for the values of the parameter. The first depth is not null. It is the bottom depth of the first layer.


Member Function Documentation

Calculates the average values. The average is defined by a mean weighted by the thicknesses. If the parameter is a slowness, it is the total thickness down to a depth divided by the total time needed to cross the layer stack to that depth.

References TRACE.

Referenced by EC8Reader::parse(), and QGpCoreWave::Seismic1DModel::roughFundamentalFrequency().

{
  TRACE;
  int n=_depths.count();
  if(n==0) return;
  double sum=_values[0]*_depths[0];
  for(int i=1; i<n; i++) {
    sum+=_values[i]*(_depths[i]-_depths[i-1]);
    _values[i]=sum/_depths[i];
  }
}
void QGpCoreWave::Profile::clear ( ) [inline]

References TRACE.

Referenced by QGpCoreWave::Resistivity1DModel::fromStream().

{
  TRACE;
  _depths.clear();
  _values.clear();
}
void QGpCoreWave::Profile::collectDepths ( QVector< double > &  depths) const [inline]

References TRACE.

Referenced by DinverDCCore::TargetList2D::misfit().

{
  TRACE;
  depths << _depths;
}
int QGpCoreWave::Profile::count ( ) const [inline]

References QGpCoreTools::Curve< pointType >::append(), count(), and TRACE.

Referenced by Seismic1DThread::addModel(), MagnetoTelluricThread::addModel(), Seismic1DThread::setModel(), and MagnetoTelluricThread::setModel().

{
  TRACE;
  int n=count();
  double lastDepth=0.0;
  Curve<Point2D> c;
  for(int i=0;i<n;i++) {
    c.append(Point2D(_values[i], lastDepth));
    lastDepth=_depths[i];
    c.append(Point2D(_values[i], lastDepth));
  }
  return c;
}
const QVector<double>& QGpCoreWave::Profile::depths ( ) const [inline]
double QGpCoreWave::Profile::interpoleAt ( double  depth)

References TRACE.

{
  TRACE;
  int i=0;
  int n=_depths.count();
  if(n<2) return 0.0;
  while(i<n && depth<_depths[i]) i++;
  if(i>=n-1) i=n-2;
  return _values[i]+(_values[i+1]-_values[i])/(_depths[i+1]-_depths[i])*(depth-_depths[i]);
}

Inverses values

References TRACE.

Referenced by EC8Reader::parse(), QGpCoreWave::Seismic1DModel::vpProfile(), and QGpCoreWave::Seismic1DModel::vsProfile().

{
  TRACE;
  int n=_depths.count();
  for(int i=0; i<n; i++ ) {
    _values[i]=1.0/_values[i];
  }
}
void QGpCoreWave::Profile::operator= ( const Profile p) [inline]

References TRACE.

Referenced by QGpCoreWave::Resistivity1DModel::operator=(), and QGpCoreWave::Resistivity1DModel::Resistivity1DModel().

{
  TRACE;
  _depths=p._depths;
  _values=p._values;
}

References count(), and TRACE.

Referenced by DinverDCCore::ParamProfile::pMaxRaw(), DinverDCCore::ParamProfile::pMaxResampled(), DinverDCCore::ParamProfile::pRaw(), and DinverDCCore::ParamProfile::pResampled().

{
  TRACE;
  int n=count();
  for(int i=0;i<n;i++) {
    printf( "%20.15lg %20.15lg\n", _values[i], _depths[i] );
  }
}
void QGpCoreWave::Profile::readReport ( QDataStream &  s) [inline]
void QGpCoreWave::Profile::report2plot ( QDataStream &  s,
Point2D points 
) [static]

References QGpCoreTools::Point2D::setX(), QGpCoreTools::Point2D::setY(), and TRACE.

{
  TRACE;
  int n;
  s >> n;
  double lastDepth=0.0;
  double depth,value;
  for(int i=0;i<n;i++) {
    s >> depth;
    s >> value;
    points[0].setY(lastDepth);
    points[0].setX(value);
    points[1].setY(depth);
    points[1].setX(value);
    points+=2;
    lastDepth=depth;
  }
}
void QGpCoreWave::Profile::resample ( const Profile p,
const QVector< double > &  baseD 
)

Set this profile as the resample of p with baseD. All depths of p must belong to baseD. p must be different from this.

References TRACE.

Referenced by DinverDCGui::GroundModelViewer::exportModels(), DinverDCCore::TargetList2D::misfit(), outputDCModel(), EC8Reader::parse(), DinverDCCore::DCReportBlock::readSeismicModel(), reportMode(), resample(), and DinverDCCore::ParamProfile::resampleProfile().

{
  TRACE;
  _depths.clear();
  _values.clear();
  QVector<double>::const_iterator itBase=baseD.begin();
  int i=0, n=p._depths.count();
  double nextDepth=p._depths.at(i);
  double value=p._values.at(i);
  double depth;
  while(true) {
    depth=*(itBase++);
    _depths.append(depth);
    _values.append(value);
    if(depth==nextDepth) {
      ++i;
      if(i>=n) break;
      nextDepth=p._depths.at(i);
      value=p._values.at(i);
    }
  }
  /*App::stream() << "resample(const Profile& p, const QList<double>& baseD)" << endl;
  int nd=_depths.count();
  for(int i=0;i<nd;i++) {
    App::stream() << "  " << _depths.at(i) << " ; " << _values.at(i) << endl;
  }*/
}
void QGpCoreWave::Profile::resample ( const QVector< double > &  baseD)

Add samples from baseD to this profile if they do not exist already. Depths must be ordered

References count(), and TRACE.

{
  TRACE;
  /*App::stream() << "resample(const QList<double>& baseD): baseD" << endl;
  for(int i=0;i<baseD.count();i++) {
    App::stream() << "  " << baseD.at(i) << endl;
  }*/
  int i=0, n=count();
  for(QVector<double>::const_iterator it=baseD.begin(); it!=baseD.end(); it++ ) {
    double depth=*it;
    while(i<n && _depths.at(i)<depth) i++;
    if(i<n) {
      if(_depths.at(i)>depth) {
        _depths.insert(i, depth);
        _values.insert(i, _values[i] );
        i++; n++;
      }
    } else break;
  }
  /*App::stream() << "resample(const QList<double>& baseD): result" << endl;
  for(int i=0;i<_depths.count();i++) {
    App::stream() << "  " << _depths.at(i) << " ; " << _values.at(i) << endl;
  }*/
}
void QGpCoreWave::Profile::resample ( const QVector< double > &  baseD1,
const QVector< double > &  baseD2 
) [inline]

References resample(), and TRACE.

{
  TRACE;
  resample(baseD1);
  resample(baseD2);
}
void QGpCoreWave::Profile::resize ( int  n) [inline]
void QGpCoreWave::Profile::setDepth ( int  i,
double  depth 
) [inline]
void QGpCoreWave::Profile::setSamples ( const QVector< double > &  baseD)

Remove all samples that are not in baseD. Depths must be ordered

References count(), and TRACE.

Referenced by EC8Reader::parse().

{
  TRACE;
  /*App::stream() << "setSamples(const QList<double>& baseD): baseD" << endl;
  for(int i=0;i<baseD.count();i++) {
    App::stream() << "  " << baseD.at(i) << endl;
  }*/
  int i=0, n=count();
  for(QVector<double>::const_iterator it=baseD.begin(); it!=baseD.end(); it++ ) {
    double depth=*it;
    while(i<n && _depths.at(i)<depth) {
      _depths.remove(i);
      _values.remove(i);
      n--;
    }
    i++;
    if(i>=n) break;
  }
  while(i<n) {
      _depths.remove(i);
      _values.remove(i);
      n--;
  }
  /*App::stream() << "setSamples(const QList<double>& baseD): result" << endl;
  for(int i=0;i<_depths.count();i++) {
    App::stream() << "  " << _depths.at(i) << " ; " << _values.at(i) << endl;
  }*/
}
void QGpCoreWave::Profile::setValue ( int  i,
double  value 
) [inline]
void QGpCoreWave::Profile::toStream ( QTextStream &  s,
bool  plotMode 
) const

References count(), QGpCoreTools::flush(), and TRACE.

Referenced by outputDCModel(), and ProfileReader::terminate().

{
  TRACE;
  static const QString fmt("%1 %2\n");
  int n=count();
  if(plotMode) {
    double lastDepth=0.0;
    for(int i=0;i<n;i++) {
      s << fmt.arg(_values[i], 20, 'g', 15).arg(lastDepth, 20, 'g', 15);
      lastDepth=_depths[i];
      s << fmt.arg(_values[i], 20, 'g', 15).arg(lastDepth, 20, 'g', 15);
    }
  } else {
    for(int i=0;i<n;i++) {
      s << fmt.arg(_values[i], 20, 'g', 15).arg(_depths[i], 20, 'g', 15);
    }
  }
  s << flush;
}
double QGpCoreWave::Profile::uniformAt ( double  depth)

References TRACE.

Referenced by DinverDCGui::GroundModelViewer::minMaxProfiles().

{
  TRACE;
  int i=0;
  int n=_depths.count();
  while(i<n && depth>_depths[i] ) i++;
  if(i==n) i--;
  return _values[i];
}
const QVector<double>& QGpCoreWave::Profile::values ( ) const [inline]
QVector<double>& QGpCoreWave::Profile::values ( ) [inline]
{return _values;}
void QGpCoreWave::Profile::writeReport ( QDataStream &  s) const [inline]

References TRACE.

Referenced by DinverDCCore::DCReportBlock::write(), DinverDCCore::DCReportBlock::writeBeta(), and DinverDCCore::DCReportBlock::writeNaViewer().

{
  TRACE;
  int n=_depths.count();
  s << n;
  for(int i=0;i<n;i++) {
    s << _depths.at(i);
    s << _values.at(i);
  }
}

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