Storage for a 1D profile. More...
#include <Profile.h>
Public Member Functions | |
void | average () |
void | clear () |
void | collectDepths (QVector< double > &depths) const |
int | count () const |
Curve< Point2D > | curve () 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) |
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.
void QGpCoreWave::Profile::average | ( | ) |
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] |
int QGpCoreWave::Profile::count | ( | ) | const [inline] |
Referenced by curve(), QGpCoreWave::Resistivity1DModel::layerCount(), print(), QGpCoreWave::Resistivity1DModel::profile(), DinverDCCore::DCReportBlock::readElectricModel(), DinverDCCore::DCReportBlock::readSeismicModel(), resample(), setSamples(), and toStream().
{return _depths.count();}
Curve< Point2D > QGpCoreWave::Profile::curve | ( | ) | const |
References QGpCoreTools::Curve< pointType >::append(), count(), and TRACE.
Referenced by Seismic1DThread::addModel(), MagnetoTelluricThread::addModel(), Seismic1DThread::setModel(), and MagnetoTelluricThread::setModel().
const QVector<double>& QGpCoreWave::Profile::depths | ( | ) | const [inline] |
Reimplemented in QGpCoreWave::Resistivity1DModel.
Referenced by QGpCoreWave::Resistivity1DModel::depths(), DinverDCGui::GroundModelViewer::exportModels(), DinverDCCore::PoissonCondition::getLimits(), DinverDCCore::PoissonCondition::isOk(), main(), ModelGenerator::misfit(), DinverDCCore::TargetList2D::misfit(), DinverDCCore::TargetList::misfit(), outputDCModel(), DinverDCCore::DCReportBlock::readSeismicModel(), reportMode(), and DinverDCCore::ParamLayer::setFinalProfileValues().
{return _depths;}
double QGpCoreWave::Profile::interpoleAt | ( | double | depth | ) |
void QGpCoreWave::Profile::inverse | ( | ) |
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; }
void QGpCoreWave::Profile::print | ( | ) | const |
References count(), and TRACE.
Referenced by DinverDCCore::ParamProfile::pMaxRaw(), DinverDCCore::ParamProfile::pMaxResampled(), DinverDCCore::ParamProfile::pRaw(), and DinverDCCore::ParamProfile::pResampled().
void QGpCoreWave::Profile::readReport | ( | QDataStream & | s | ) | [inline] |
References resize(), setDepth(), setValue(), and TRACE.
Referenced by DinverDCGui::GroundModelViewer::exportModels(), DinverDCGui::GroundModelViewer::minMaxProfiles(), outputDCModel(), DinverDCCore::DCReportBlock::readElectricModel(), DinverDCCore::DCReportBlock::readSeismicModel(), reportMode(), DinverDCCore::DCReportBlock::write(), and DinverDCCore::DCReportBlock::writeBeta().
void QGpCoreWave::Profile::report2plot | ( | QDataStream & | s, |
Point2D * | points | ||
) | [static] |
References QGpCoreTools::Point2D::setX(), QGpCoreTools::Point2D::setY(), and TRACE.
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.
void QGpCoreWave::Profile::resize | ( | int | n | ) | [inline] |
References TRACE.
Referenced by QGpCoreWave::Resistivity1DModel::fromStream(), QGpCoreWave::Seismic1DModel::impedanceProfile(), DinverDCCore::ParamProfile::initFinalProfile(), main(), QGpCoreWave::Seismic1DModel::poissonProfile(), readReport(), QGpCoreWave::Seismic1DModel::rhoProfile(), QGpCoreWave::Seismic1DModel::slowpProfile(), and QGpCoreWave::Seismic1DModel::slowsProfile().
{ TRACE; _depths.resize(n); _values.resize(n); }
void QGpCoreWave::Profile::setDepth | ( | int | i, |
double | depth | ||
) | [inline] |
Reimplemented in QGpCoreWave::Resistivity1DModel.
References TRACE.
Referenced by QGpCoreWave::Seismic1DModel::impedanceProfile(), main(), QGpCoreWave::Seismic1DModel::poissonProfile(), QGpCoreWave::Resistivity1DModel::profile(), readReport(), QGpCoreWave::Seismic1DModel::rhoProfile(), QGpCoreWave::Resistivity1DModel::setDepth(), DinverDCCore::ParamLayer::setFinalProfileDepthsCondition(), DinverDCCore::ParamLayer::setFinalProfileDepthsParam(), QGpCoreWave::Seismic1DModel::slowpProfile(), and QGpCoreWave::Seismic1DModel::slowsProfile().
{ TRACE; _depths[i]=depth; }
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] |
References TRACE.
Referenced by QGpCoreWave::Seismic1DModel::impedanceProfile(), main(), QGpCoreWave::Seismic1DModel::poissonProfile(), readReport(), QGpCoreWave::Seismic1DModel::rhoProfile(), DinverDCCore::ParamLayer::setFinalProfileValues(), QGpCoreWave::Resistivity1DModel::setResistivity(), QGpCoreWave::Seismic1DModel::slowpProfile(), and QGpCoreWave::Seismic1DModel::slowsProfile().
{ TRACE; _values[i]=value; }
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] |
Referenced by DinverDCGui::GroundModelViewer::exportModels(), DinverDCCore::PoissonCondition::getLimits(), DinverDCCore::PoissonCondition::isOk(), main(), ModelGenerator::misfit(), DinverDCCore::TargetList2D::misfit(), DinverDCCore::TargetList::misfit(), outputDCModel(), EC8Reader::parse(), DinverDCCore::DCReportBlock::readSeismicModel(), reportMode(), and QGpCoreWave::Seismic1DModel::roughFundamentalFrequency().
{return _values;}
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); } }