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

Brief description of class still missing. More...

#include <Resistivity1DModel.h>

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

List of all members.

Classes

class  ResistivityContext
 Brief description of class still missing. More...
class  ResistivityStorage
class  VariableD
class  VariableN
class  VariableRes

Public Member Functions

virtual GeophysicalModelclone () const
const QVector< double > & depths () const
virtual GeophysicalContextexpressionContext () const
virtual bool fromStream (QTextStream &s, QString *comments=0)
virtual bool isEmpty () const
int layerCount () const
void operator= (const Resistivity1DModel &o)
Profile profile () const
const QVector< double > & resistivities () const
QVector< double > & resistivities ()
 Resistivity1DModel ()
 Resistivity1DModel (int layerCount)
 Resistivity1DModel (const Resistivity1DModel &o)
 Resistivity1DModel (const Profile &o)
void setDepth (int i, double d)
void setResistivity (int i, double v)
virtual void toStream (QTextStream &s) const
virtual QString toString () const

Static Public Member Functions

static QString formatHelp ()

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

{}
: Profile() {resize(layerCount);}
: GeophysicalModel(), Profile() {operator=(o);}

Member Function Documentation

virtual GeophysicalModel* QGpCoreWave::Resistivity1DModel::clone ( ) const [inline, virtual]

Implements QGpCoreWave::GeophysicalModel.

{return new Resistivity1DModel(*this);}
const QVector<double>& QGpCoreWave::Resistivity1DModel::depths ( ) const [inline]

Implements QGpCoreWave::GeophysicalModel.

{return new ResistivityContext;}

References TRACE.

Referenced by QGpCoreWave::GeophysicalModel::allFormatHelp().

{
  TRACE;
  return "  Line 1    <number of layers including half-space for first model>\n"
         "  Line 2    <thickness (m)> <Res (ohm m)>\n"
         "  ....\n"
         "  Line n    0 <Res (ohm m)>\n"
         "  Line n+1  <number of layers including half-space for second model>\n"
         "  ....";
}
bool QGpCoreWave::Resistivity1DModel::fromStream ( QTextStream &  s,
QString *  comments = 0 
) [virtual]

Loads model from a text stream

Format:

      layerCount
      h res (layer 1)
      ...
      0 res (layer n)
      

Returns false if an error occured during reading or if the read model is not consistent. It returns true even if the number of layers is null or cannot be read. This is the responsability of the caller to test if the number of layers is greater than 1 before doing anything else.

Implements QGpCoreWave::GeophysicalModel.

References QGpCoreWave::Profile::clear(), QGpCoreTools::endl(), QGpCoreTools::StringSection::isValid(), layerCount(), QGpCoreTools::StringSection::nextField(), QGpCoreWave::Profile::resize(), QGpCoreTools::StringSection::set(), setDepth(), setResistivity(), QGpCoreTools::StringSection::toInt(), QGpCoreTools::tr(), TRACE, and QGpCoreTools::StringSection::trimmed().

Referenced by MagnetoTelluricReader::parse().

{
  TRACE;
  // read the number of layers
  StringSection field, fields;
  const QChar * ptr;
  QString buf;
  buf=File::readLineNoComments(s, comments);
  fields.set(buf);
  fields.trimmed();
  ptr=0;
  field=fields.nextField(ptr);
  if(!field.isValid()) {
    return true;  // This is just a blank line, before doing anything, you must test if the number of layer is >0
  }
  int layerCount=field.toInt();
  if(layerCount>1 && !s.atEnd()) {
    resize(layerCount);
    // read the data
    double d=0.0;
    for(int i=0;i<layerCount;i++) {
      if(s.atEnd()) {
        App::stream() << tr("Layered model: reaching the end of file, %1 layers found, expecting %2")
                  .arg(i).arg(layerCount) << endl;
        clear();
        return false;
      }
      buf=File::readLineNoComments(s, comments);
      fields.set(buf);
      fields.trimmed();
      ptr=0;
      double v;
      if(i<layerCount-1) {
        field=fields.nextField(ptr);
        if(!setValue(v, field, i, tr("thickness"), false) ) return false;
        d+=v;
        setDepth(i, d);
      } else {
        fields.nextField(ptr);
      }
      field=fields.nextField(ptr);
      if(!setValue(v, field, i, tr("resistivity"), false) ) return false;
      setResistivity(i, v);
    }
    return true;
  } else {
    return false;
  }
}
virtual bool QGpCoreWave::Resistivity1DModel::isEmpty ( ) const [inline, virtual]

Implements QGpCoreWave::GeophysicalModel.

{return layerCount()==0;}
void QGpCoreWave::Resistivity1DModel::operator= ( const Resistivity1DModel o) [inline]

References QGpCoreWave::Profile::count(), QGpCoreWave::Profile::setDepth(), and TRACE.

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

{
  TRACE;
  Profile p(*this);
  p.setDepth(p.count()-1, 1e99);
  return p;
}
const QVector<double>& QGpCoreWave::Resistivity1DModel::resistivities ( ) const [inline]
{return values();}
void QGpCoreWave::Resistivity1DModel::setDepth ( int  i,
double  d 
) [inline]
void QGpCoreWave::Resistivity1DModel::setResistivity ( int  i,
double  v 
) [inline]
void QGpCoreWave::Resistivity1DModel::toStream ( QTextStream &  s) const [virtual]

Saves model to a text stream

Format:

      nLayers
      h res (layer 1)
      ...
      0 res (layer n)
      

Implements QGpCoreWave::GeophysicalModel.

References depths(), layerCount(), resistivities(), and TRACE.

{
  TRACE;
  static const QString str2("%1 %2\n");
  s << layerCount() << "\n";
  int n=layerCount()-1;
  double d0=0;
  for(int i=0;i<n;i++) {
    double d1=depths().at(i);
    s << str2.arg(d1-d0, 0, 'g', 20)
             .arg(resistivities().at(i), 0, 'g', 20);
    d0=d1;
  }
  s << str2.arg(0.0, 0, 'g', 20)
           .arg(resistivities().at(n), 0, 'g', 20);
}
QString QGpCoreWave::Resistivity1DModel::toString ( ) const [virtual]

Returns model as a string

Implements QGpCoreWave::GeophysicalModel.

References depths(), layerCount(), resistivities(), str, and TRACE.

{
  TRACE;
  QString str;
  str=QString("%1 layers\n").arg(layerCount());
  str+="          H(m)       Res(ohm m)\n";
  int n=layerCount()-1;
  double d0=0;
  for(int i=0;i<n;i++) {
    double d1=depths().at(i);
    str+=QString::number(d1-d0,'f',1).leftJustified(14,' ',true);
    str+=QString::number(resistivities().at(i),'f',1).leftJustified(14,' ',true);
    str+="\n";
    d0=d1;
  }
  str+=QString("-").leftJustified(14,' ',true);
  str+=QString::number(resistivities().at(n),'f',1).leftJustified(14,' ',true);
  str+="\n";
  return str;
}

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