Brief description of class still missing. More...
#include <Resistivity1DModel.h>
Classes | |
class | ResistivityContext |
Brief description of class still missing. More... | |
class | ResistivityStorage |
class | VariableD |
class | VariableN |
class | VariableRes |
Public Member Functions | |
virtual GeophysicalModel * | clone () const |
const QVector< double > & | depths () const |
virtual GeophysicalContext * | expressionContext () 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 () |
Brief description of class still missing.
Full description of class still missing
QGpCoreWave::Resistivity1DModel::Resistivity1DModel | ( | ) | [inline] |
{}
QGpCoreWave::Resistivity1DModel::Resistivity1DModel | ( | int | layerCount | ) | [inline] |
: Profile() {resize(layerCount);}
QGpCoreWave::Resistivity1DModel::Resistivity1DModel | ( | const Resistivity1DModel & | o | ) | [inline] |
: GeophysicalModel(), Profile() {operator=(o);}
QGpCoreWave::Resistivity1DModel::Resistivity1DModel | ( | const Profile & | o | ) | [inline] |
References QGpCoreWave::Profile::operator=().
: GeophysicalModel(), Profile() {Profile::operator=(o);}
virtual GeophysicalModel* QGpCoreWave::Resistivity1DModel::clone | ( | ) | const [inline, virtual] |
Implements QGpCoreWave::GeophysicalModel.
{return new Resistivity1DModel(*this);}
const QVector<double>& QGpCoreWave::Resistivity1DModel::depths | ( | ) | const [inline] |
Reimplemented from QGpCoreWave::Profile.
References QGpCoreWave::Profile::depths().
Referenced by QGpCoreWave::MagnetoTelluricFactory::calculate(), toStream(), toString(), and QGpCoreWave::Resistivity1DModel::VariableD::value().
{return Profile::depths();}
virtual GeophysicalContext* QGpCoreWave::Resistivity1DModel::expressionContext | ( | ) | const [inline, virtual] |
Implements QGpCoreWave::GeophysicalModel.
{return new ResistivityContext;}
QString QGpCoreWave::Resistivity1DModel::formatHelp | ( | ) | [static] |
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;}
int QGpCoreWave::Resistivity1DModel::layerCount | ( | ) | const [inline] |
References QGpCoreWave::Profile::count().
Referenced by QGpCoreWave::MagnetoTelluricFactory::calculate(), fromStream(), MagnetoTelluricReader::parse(), QGpCoreWave::Resistivity1DModel::VariableD::setValue(), QGpCoreWave::Resistivity1DModel::VariableRes::setValue(), toStream(), toString(), QGpCoreWave::Resistivity1DModel::VariableD::value(), and QGpCoreWave::Resistivity1DModel::VariableRes::value().
{return Profile::count();}
void QGpCoreWave::Resistivity1DModel::operator= | ( | const Resistivity1DModel & | o | ) | [inline] |
References QGpCoreWave::Profile::operator=().
{Profile::operator=(o);}
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] |
Referenced by QGpCoreWave::MagnetoTelluricFactory::calculate(), toStream(), toString(), and QGpCoreWave::Resistivity1DModel::VariableRes::value().
{return values();}
QVector<double>& QGpCoreWave::Resistivity1DModel::resistivities | ( | ) | [inline] |
{return values();}
void QGpCoreWave::Resistivity1DModel::setDepth | ( | int | i, |
double | d | ||
) | [inline] |
Reimplemented from QGpCoreWave::Profile.
References QGpCoreWave::Profile::setDepth().
Referenced by fromStream(), and QGpCoreWave::Resistivity1DModel::VariableD::setValue().
{Profile::setDepth(i, d);}
void QGpCoreWave::Resistivity1DModel::setResistivity | ( | int | i, |
double | v | ||
) | [inline] |
References QGpCoreWave::Profile::setValue().
Referenced by fromStream(), and QGpCoreWave::Resistivity1DModel::VariableRes::setValue().
{Profile::setValue(i, v);}
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; }