#2327 Formation RFT Plot: Read tvdss from well pick files

This commit is contained in:
Rebecca Cox
2018-01-24 08:21:22 +01:00
parent 7dbd6c1027
commit 9617481406
5 changed files with 367 additions and 150 deletions

View File

@@ -39,11 +39,29 @@ std::map<QString, cvf::ref<RigWellPathFormations>>
std::vector<QString> wellNames;
std::vector<QString> formationNames;
std::vector<double> mdTop;
std::vector<double> mdBase;
readFile(filePath, &wellNames, &formationNames, &mdTop, &mdBase);
if (wellNames.empty() || formationNames.empty() || mdTop.empty() || mdBase.empty())
std::vector<double> tvdTop;
std::vector<double> tvdBase;
readFile(filePath, &wellNames, &formationNames, &mdTop, &mdBase, &tvdTop, &tvdBase);
bool mdIsPresent = true;
bool tvdIsPresent = true;
if (mdTop.empty() || mdBase.empty())
{
mdIsPresent = false;
}
if (tvdTop.empty() || tvdBase.empty())
{
tvdIsPresent = false;
}
if (wellNames.empty() || formationNames.empty())
{
QMessageBox::warning(RiuMainWindow::instance(), "Import failure",
QString("Failed to parse %1 as a well pick file").arg(filePath));
@@ -51,10 +69,16 @@ std::map<QString, cvf::ref<RigWellPathFormations>>
return result;
}
else if (!(mdIsPresent || tvdIsPresent))
{
QMessageBox::warning(RiuMainWindow::instance(), "Import failure",
QString("Failed to parse %1 as a well pick file. Neither MD or TVD is present.").arg(filePath));
RiaLogging::error(QString("Failed to parse %1 as a well pick file. Neither MD or TVD is present.").arg(filePath));
return result;
}
CVF_ASSERT(wellNames.size() == formationNames.size());
CVF_ASSERT(mdTop.size() == formationNames.size());
CVF_ASSERT(mdBase.size() == formationNames.size());
std::map<QString, std::vector<RigWellPathFormation>> formations;
@@ -62,8 +86,18 @@ std::map<QString, cvf::ref<RigWellPathFormations>>
{
RigWellPathFormation formation;
formation.formationName = formationNames[i];
if (mdIsPresent)
{
formation.mdTop = mdTop[i];
formation.mdBase = mdBase[i];
}
if (tvdIsPresent)
{
formation.tvdTop = tvdTop[i];
formation.tvdBase = tvdBase[i];
}
if (!formations.count(wellNames[i]))
{
@@ -73,10 +107,10 @@ std::map<QString, cvf::ref<RigWellPathFormations>>
formations[wellNames[i]].push_back(formation);
}
for (auto it = formations.begin(); it != formations.end(); it++)
for (const std::pair<QString, std::vector<RigWellPathFormation>>& formation : formations)
{
cvf::ref<RigWellPathFormations> wellPathFormations = new RigWellPathFormations(it->second, filePath, it->first);
result[it->first] = wellPathFormations;
cvf::ref<RigWellPathFormations> wellPathFormations = new RigWellPathFormations(formation.second, filePath, formation.first);
result[formation.first] = wellPathFormations;
}
return result;
@@ -95,7 +129,8 @@ void removeWhiteSpaces(QString* word)
//--------------------------------------------------------------------------------------------------
void RifWellPathFormationReader::readFile(const QString& filePath, std::vector<QString>* wellNames,
std::vector<QString>* formationNames, std::vector<double>* mdTop,
std::vector<double>* mdBase)
std::vector<double>* mdBase, std::vector<double>* tvdTop,
std::vector<double>* tvdBase)
{
QFile data(filePath);
@@ -151,12 +186,31 @@ void RifWellPathFormationReader::readFile(const QString& filePath, std::vector<Q
static const QString unitNameText = "unitname";
static const QString measuredDepthToptext = "topmd";
static const QString measuredDepthBasetext = "basemd";
static const QString trueVerticalDepthToptext = "toptvdss";
static const QString trueVerticalDepthBasetext = "basetvdss";
int unitNameIndex = header.indexOf(unitNameText);
int measuredDepthTopIndex = header.indexOf(measuredDepthToptext);
int measuredDepthBaseIndex = header.indexOf(measuredDepthBasetext);
if (unitNameIndex != -1 && measuredDepthTopIndex != -1 && measuredDepthBaseIndex != -1)
int trueVerticalDepthTopIndex = header.indexOf(trueVerticalDepthToptext);
int trueVerticalDepthBaseIndex = header.indexOf(trueVerticalDepthBasetext);
bool mdIsPresent = true;
bool tvdIsPresent = true;
if (measuredDepthTopIndex == -1 || measuredDepthBaseIndex == -1)
{
mdIsPresent = false;
}
if (trueVerticalDepthTopIndex == -1 || trueVerticalDepthBaseIndex == -1)
{
tvdIsPresent = false;
}
if (unitNameIndex != -1 && (mdIsPresent || tvdIsPresent))
{
do
{
@@ -168,13 +222,27 @@ void RifWellPathFormationReader::readFile(const QString& filePath, std::vector<Q
QString wellName = dataLine[wellNameIndex];
QString unitName = dataLine[unitNameIndex];
unitName = unitName.trimmed();
double measuredDepthTop = dataLine[measuredDepthTopIndex].toDouble();
double measuredDepthBase = dataLine[measuredDepthBaseIndex].toDouble();
if (mdIsPresent)
{
double mdTopValue = dataLine[measuredDepthTopIndex].toDouble();
double mdBaseValue = dataLine[measuredDepthBaseIndex].toDouble();
mdTop->push_back(mdTopValue);
mdBase->push_back(mdBaseValue);
}
if (tvdIsPresent)
{
double tvdTopValue = dataLine[trueVerticalDepthTopIndex].toDouble();
double tvdBaseValue = dataLine[trueVerticalDepthBaseIndex].toDouble();
tvdTop->push_back(-tvdTopValue);
tvdBase->push_back(-tvdBaseValue);
}
wellNames->push_back(wellName);
formationNames->push_back(unitName);
mdTop->push_back(measuredDepthTop);
mdBase->push_back(measuredDepthBase);
} while (!data.atEnd());
}

View File

@@ -39,5 +39,6 @@ public:
private:
static void readFile(const QString& filePath, std::vector<QString>* wellNames, std::vector<QString>* formationNames,
std::vector<double>* mdTop, std::vector<double>* mdBase);
std::vector<double>* mdTop, std::vector<double>* mdBase, std::vector<double>* tvdTop,
std::vector<double>* tvdBase);
};

View File

@@ -1269,14 +1269,19 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
else if (m_formationSource() == WELL_PICK_FILTER)
{
if (m_formationWellPathForSourceWellPath == nullptr) return;
if (plot->depthType() != RimWellLogPlot::MEASURED_DEPTH) return;
if (!(plot->depthType() == RimWellLogPlot::MEASURED_DEPTH || plot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH))
{
return;
}
std::vector<double> yValues;
const RigWellPathFormations* formations = m_formationWellPathForSourceWellPath->formationsGeometry();
if (!formations) return;
formations->measuredDepthAndFormationNamesUpToLevel(m_formationLevel(), &formationNamesToPlot, &yValues, m_showformationFluids());
formations->depthAndFormationNamesUpToLevel(m_formationLevel(), &formationNamesToPlot, &yValues, m_showformationFluids(), plot->depthType());
m_annotationTool->attachWellPicks(this->viewer(), formationNamesToPlot, yValues);
}

View File

@@ -20,8 +20,6 @@
#include "QStringList"
#include "cvfMath.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -47,26 +45,17 @@ RigWellPathFormations::RigWellPathFormations(const std::vector<RigWellPathFormat
}
}
struct MeasuredDepthComp
{
bool operator()(const double& md1, const double& md2) const
{
if (cvf::Math::abs(md1 - md2) < 0.1)
{
return false;
}
return md1 < md2;
}
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellPathFormations::measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector<QString>* names,
std::vector<double>* measuredDepths) const
void RigWellPathFormations::depthAndFormationNamesWithoutDuplicatesOnDepth(std::vector<QString>* names,
std::vector<double>* measuredDepths,
RimWellLogPlot::DepthTypeEnum depthType) const
{
std::map<double, bool, MeasuredDepthComp> tempMakeVectorUniqueOnMeasuredDepth;
std::map<double, bool, DepthComp> tempMakeVectorUniqueOnMeasuredDepth;
if (depthType == RimWellLogPlot::MEASURED_DEPTH)
{
for (const std::pair<RigWellPathFormation, FormationLevel>& formation : m_formations)
{
if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.mdTop))
@@ -86,35 +75,84 @@ void RigWellPathFormations::measuredDepthAndFormationNamesWithoutDuplicatesOnDep
tempMakeVectorUniqueOnMeasuredDepth[formation.first.mdBase] = true;
}
}
}
else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
{
for (const std::pair<RigWellPathFormation, FormationLevel>& formation : m_formations)
{
if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.tvdTop))
{
measuredDepths->push_back(formation.first.tvdTop);
names->push_back(formation.first.formationName + " Top");
tempMakeVectorUniqueOnMeasuredDepth[formation.first.tvdTop] = true;
}
}
for (const std::pair<RigWellPathFormation, FormationLevel>& formation : m_formations)
{
if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.tvdBase))
{
measuredDepths->push_back(formation.first.tvdBase);
names->push_back(formation.first.formationName + " Base");
tempMakeVectorUniqueOnMeasuredDepth[formation.first.tvdBase] = true;
}
}
}
/*
for (const std::pair<RigWellPathFormation, FormationLevel>& formation : m_formations)
{
if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.mdTop))
{
double depth;
if (depthType == RimWellLogPlot::MEASURED_DEPTH)
{
depth = formation.first.mdTop;
}
else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
{
depth = formation.first.tvdTop;
}
else return;
measuredDepths->push_back(depth);
names->push_back(formation.first.formationName + " Top");
tempMakeVectorUniqueOnMeasuredDepth[depth] = true;
}
}
for (const std::pair<RigWellPathFormation, FormationLevel>& formation : m_formations)
{
double depth;
if (depthType == RimWellLogPlot::MEASURED_DEPTH)
{
depth = formation.first.mdBase;
}
else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
{
depth = formation.first.tvdBase;
}
else return;
if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.mdBase))
{
measuredDepths->push_back(depth);
names->push_back(formation.first.formationName + " Base");
tempMakeVectorUniqueOnMeasuredDepth[depth] = true;
}
}*/
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
struct LevelAndName
{
LevelAndName() {}
LevelAndName(RigWellPathFormations::FormationLevel level, QString name) : level(level), name(name) {}
RigWellPathFormations::FormationLevel level;
QString name;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
enum PICK_POSITION
{
TOP,
BASE
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void evaluateFormationsForOnePosition(const std::vector<std::pair<RigWellPathFormation, RigWellPathFormations::FormationLevel>>& formations,
const RigWellPathFormations::FormationLevel& maxLevel, const PICK_POSITION& position,
std::map<double, LevelAndName, MeasuredDepthComp>* uniqueListMaker)
void RigWellPathFormations::evaluateFormationsForOnePosition(
const std::vector<std::pair<RigWellPathFormation, FormationLevel>>& formations,
const FormationLevel& maxLevel, const PickPosition& position,
std::map<double, LevelAndName, DepthComp>* uniqueListMaker, RimWellLogPlot::DepthTypeEnum depthType) const
{
QString postFix;
@@ -127,92 +165,134 @@ void evaluateFormationsForOnePosition(const std::vector<std::pair<RigWellPathFor
postFix = " Base";
}
for (const std::pair<RigWellPathFormation, RigWellPathFormations::FormationLevel>& formation : formations)
for (const std::pair<RigWellPathFormation, FormationLevel>& formation : formations)
{
double depth;
if (depthType == RimWellLogPlot::MEASURED_DEPTH)
{
double md;
if (position == TOP)
{
md = formation.first.mdTop;
depth = formation.first.mdTop;
}
else
{
md = formation.first.mdBase;
depth = formation.first.mdBase;
}
}
else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
{
if (position == TOP)
{
depth = formation.first.tvdTop;
}
else
{
depth = formation.first.tvdBase;
}
}
else return;
if (formation.second > maxLevel) continue;
if (!uniqueListMaker->count(md) || uniqueListMaker->at(md).level < formation.second)
if (!uniqueListMaker->count(depth) || uniqueListMaker->at(depth).level < formation.second)
{
(*uniqueListMaker)[md] = LevelAndName(formation.second, formation.first.formationName + postFix);
(*uniqueListMaker)[depth] = LevelAndName(formation.second, formation.first.formationName + postFix);
}
}
}
void evaluateFormations(const std::vector<std::pair<RigWellPathFormation, RigWellPathFormations::FormationLevel>>& formations,
const RigWellPathFormations::FormationLevel& maxLevel,
std::vector<QString>* names, std::vector<double>* measuredDepths)
{
std::map<double, LevelAndName, MeasuredDepthComp> tempMakeVectorUniqueOnMeasuredDepth;
evaluateFormationsForOnePosition(formations, maxLevel, PICK_POSITION::TOP, &tempMakeVectorUniqueOnMeasuredDepth);
evaluateFormationsForOnePosition(formations, maxLevel, PICK_POSITION::BASE, &tempMakeVectorUniqueOnMeasuredDepth);
for (auto it = tempMakeVectorUniqueOnMeasuredDepth.begin(); it != tempMakeVectorUniqueOnMeasuredDepth.end(); it++)
{
measuredDepths->push_back(it->first);
names->push_back(it->second.name);
}
}
void evaluateFluids(const std::vector<RigWellPathFormation>& fluidFormations,
std::vector<QString>* names, std::vector<double>* measuredDepths)
{
std::map<double, QString, MeasuredDepthComp> uniqueListMaker;
for (const RigWellPathFormation& formation : fluidFormations)
{
uniqueListMaker[formation.mdBase] = formation.formationName + " Base";
}
for (const RigWellPathFormation& formation : fluidFormations)
{
uniqueListMaker[formation.mdTop] = formation.formationName + " Top";
}
for (auto it = uniqueListMaker.begin(); it != uniqueListMaker.end(); it++)
{
measuredDepths->push_back(it->first);
names->push_back(it->second);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellPathFormations::measuredDepthAndFormationNamesUpToLevel(FormationLevel maxLevel,
std::vector<QString>* names,
std::vector<double>* measuredDepths, bool includeFluids) const
void RigWellPathFormations::evaluateFormations(const std::vector<std::pair<RigWellPathFormation, FormationLevel>>& formations,
const FormationLevel& maxLevel, std::vector<QString>* names,
std::vector<double>* depths, RimWellLogPlot::DepthTypeEnum depthType) const
{
std::map<double, LevelAndName, DepthComp> tempMakeVectorUniqueOnDepth;
evaluateFormationsForOnePosition(formations, maxLevel, PickPosition::TOP, &tempMakeVectorUniqueOnDepth, depthType);
evaluateFormationsForOnePosition(formations, maxLevel, PickPosition::BASE, &tempMakeVectorUniqueOnDepth, depthType);
for (const std::pair<double, LevelAndName>& uniqueDepth : tempMakeVectorUniqueOnDepth)
{
depths->push_back(uniqueDepth.first);
names->push_back(uniqueDepth.second.name);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellPathFormations::evaluateFluids(const std::vector<RigWellPathFormation>& fluidFormations, std::vector<QString>* names,
std::vector<double>* depths, RimWellLogPlot::DepthTypeEnum depthType) const
{
std::map<double, QString, DepthComp> uniqueListMaker;
for (const RigWellPathFormation& formation : fluidFormations)
{
double depthBase;
if (depthType == RimWellLogPlot::MEASURED_DEPTH)
{
depthBase = formation.mdBase;
}
else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
{
depthBase = formation.tvdBase;
}
else return;
uniqueListMaker[depthBase] = formation.formationName + " Base";
}
for (const RigWellPathFormation& formation : fluidFormations)
{
double depthTop;
if (depthType == RimWellLogPlot::MEASURED_DEPTH)
{
depthTop = formation.mdTop;
}
else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
{
depthTop = formation.tvdTop;
}
else return;
uniqueListMaker[depthTop] = formation.formationName + " Top";
}
for (const std::pair<double, QString>& depthAndFormation : uniqueListMaker)
{
depths->push_back(depthAndFormation.first);
names->push_back(depthAndFormation.second);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellPathFormations::depthAndFormationNamesUpToLevel(FormationLevel level, std::vector<QString>* names, std::vector<double>* depths,
bool includeFluids, RimWellLogPlot::DepthTypeEnum depthType) const
{
names->clear();
measuredDepths->clear();
depths->clear();
if (includeFluids)
{
evaluateFluids(m_fluids, names, measuredDepths);
evaluateFluids(m_fluids, names, depths, depthType);
}
if (maxLevel == RigWellPathFormations::NONE)
if (level == RigWellPathFormations::NONE)
{
return;
}
else if (maxLevel == RigWellPathFormations::ALL)
else if (level == RigWellPathFormations::ALL)
{
measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(names, measuredDepths);
depthAndFormationNamesWithoutDuplicatesOnDepth(names, depths, depthType);
}
else
{
evaluateFormations(m_formations, maxLevel, names, measuredDepths);
evaluateFormations(m_formations, level, names, depths, depthType);
}
}
@@ -223,9 +303,9 @@ std::vector<RigWellPathFormations::FormationLevel> RigWellPathFormations::format
{
std::vector<RigWellPathFormations::FormationLevel> formationLevels;
for (auto it = m_formationsLevelsPresent.begin(); it != m_formationsLevelsPresent.end(); it++)
for (const std::pair<RigWellPathFormations::FormationLevel, bool>& formationLevel : m_formationsLevelsPresent)
{
formationLevels.push_back(it->first);
formationLevels.push_back(formationLevel.first);
}
return formationLevels;
}
@@ -327,7 +407,7 @@ RigWellPathFormations::FormationLevel RigWellPathFormations::detectLevel(QString
QString levelDescriptor = levelDesctiptorCandidates[0];
QStringList joinedLevel = levelDescriptor.split('+');
if ( joinedLevel.size() > 1 )
if (joinedLevel.size() > 1)
{
levelDescriptor = joinedLevel[0];
}

View File

@@ -19,8 +19,11 @@
#pragma once
#include "cvfBase.h"
#include "cvfMath.h"
#include "cvfObject.h"
#include "RimWellLogPlot.h"
#include <map>
#include <utility>
#include <vector>
@@ -31,21 +34,41 @@ struct RigWellPathFormation
{
double mdTop;
double mdBase;
double tvdTop;
double tvdBase;
QString formationName;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RigWellPathFormations : public cvf::Object
{
public:
RigWellPathFormations(const std::vector<RigWellPathFormation>& formations, const QString& filePath, const QString& key);
enum FormationLevel
{
GROUP, LEVEL0, LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5, LEVEL6, LEVEL7, LEVEL8, LEVEL9, LEVEL10, ALL, UNKNOWN, NONE
GROUP,
LEVEL0,
LEVEL1,
LEVEL2,
LEVEL3,
LEVEL4,
LEVEL5,
LEVEL6,
LEVEL7,
LEVEL8,
LEVEL9,
LEVEL10,
ALL,
UNKNOWN,
NONE
};
void measuredDepthAndFormationNamesUpToLevel(FormationLevel level, std::vector<QString>* names,
std::vector<double>* measuredDepths, bool includeFluids) const;
public:
RigWellPathFormations(const std::vector<RigWellPathFormation>& formations, const QString& filePath, const QString& key);
void depthAndFormationNamesUpToLevel(FormationLevel level, std::vector<QString>* names, std::vector<double>* depths,
bool includeFluids, RimWellLogPlot::DepthTypeEnum depthType) const;
std::vector<FormationLevel> formationsLevelsPresent() const;
@@ -55,8 +78,48 @@ public:
size_t formationNamesCount() const;
private:
void measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector<QString>* names,
std::vector<double>* measuredDepths) const;
struct DepthComp
{
bool operator()(const double& depth1, const double& depth2) const
{
if (cvf::Math::abs(depth1 - depth2) < 0.1)
{
return false;
}
return depth1 < depth2;
}
};
struct LevelAndName
{
LevelAndName() = default;
LevelAndName(RigWellPathFormations::FormationLevel level, QString name) : level(level), name(name) {}
RigWellPathFormations::FormationLevel level;
QString name;
};
enum PickPosition
{
TOP,
BASE
};
private:
void evaluateFormations(const std::vector<std::pair<RigWellPathFormation, FormationLevel>>& formations,
const FormationLevel& maxLevel, std::vector<QString>* names, std::vector<double>* depths,
RimWellLogPlot::DepthTypeEnum depthType) const;
void evaluateFluids(const std::vector<RigWellPathFormation>& fluidFormations, std::vector<QString>* names,
std::vector<double>* depths, RimWellLogPlot::DepthTypeEnum depthType) const;
void evaluateFormationsForOnePosition(const std::vector<std::pair<RigWellPathFormation, FormationLevel>>& formations,
const FormationLevel& maxLevel, const PickPosition& position,
std::map<double, LevelAndName, DepthComp>* uniqueListMaker,
RimWellLogPlot::DepthTypeEnum depthType) const;
void depthAndFormationNamesWithoutDuplicatesOnDepth(std::vector<QString>* names, std::vector<double>* measuredDepths,
RimWellLogPlot::DepthTypeEnum depthType) const;
bool isFluid(QString formationName);
FormationLevel detectLevel(QString formationName);