mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5164 Fix crash when adding LAS curve and support TVDRKB from LAS-files
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "RiuQwtPlotWidget.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
@@ -88,78 +89,59 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot )
|
||||
{
|
||||
std::vector<double> values = wellLogFile->values( m_wellLogChannnelName );
|
||||
std::vector<double> measuredDepthValues = wellLogFile->depthValues();
|
||||
std::vector<double> tvdMslValues = wellLogFile->tvdMslValues();
|
||||
std::vector<double> tvdRkbValues = wellLogFile->tvdRkbValues();
|
||||
|
||||
if ( wellLogPlot && ( wellLogPlot->depthType() == RiaDefines::TRUE_VERTICAL_DEPTH ||
|
||||
wellLogPlot->depthType() == RiaDefines::TRUE_VERTICAL_DEPTH_RKB ) )
|
||||
bool rkbDiff = m_wellPath->wellPathGeometry() ? m_wellPath->wellPathGeometry()->rkbDiff() : 0.0;
|
||||
|
||||
if ( tvdMslValues.size() != values.size() )
|
||||
{
|
||||
bool canUseTvd = false;
|
||||
if ( wellLogFile->hasTvdChannel() )
|
||||
RigWellPath* rigWellPath = m_wellPath->wellPathGeometry();
|
||||
if ( rigWellPath )
|
||||
{
|
||||
std::vector<double> tvdMslValues = wellLogFile->tvdMslValues();
|
||||
|
||||
if ( values.size() == measuredDepthValues.size() && values.size() == tvdMslValues.size() )
|
||||
tvdMslValues.clear();
|
||||
for ( double measuredDepthValue : measuredDepthValues )
|
||||
{
|
||||
this->setValuesWithMdAndTVD( values,
|
||||
measuredDepthValues,
|
||||
tvdMslValues,
|
||||
m_wellPath->wellPathGeometry()->rkbDiff(),
|
||||
wellLogFile->depthUnit(),
|
||||
false );
|
||||
canUseTvd = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !canUseTvd )
|
||||
{
|
||||
RigWellPath* rigWellPath = m_wellPath->wellPathGeometry();
|
||||
if ( rigWellPath )
|
||||
{
|
||||
std::vector<double> trueVerticalDepthValues;
|
||||
|
||||
for ( double measuredDepthValue : measuredDepthValues )
|
||||
{
|
||||
trueVerticalDepthValues.push_back(
|
||||
-rigWellPath->interpolatedPointAlongWellPath( measuredDepthValue ).z() );
|
||||
}
|
||||
if ( values.size() == trueVerticalDepthValues.size() &&
|
||||
values.size() == measuredDepthValues.size() )
|
||||
{
|
||||
this->setValuesWithMdAndTVD( values,
|
||||
measuredDepthValues,
|
||||
trueVerticalDepthValues,
|
||||
m_wellPath->wellPathGeometry()->rkbDiff(),
|
||||
wellLogFile->depthUnit(),
|
||||
false );
|
||||
canUseTvd = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !canUseTvd )
|
||||
{
|
||||
if ( RiaApplication::instance()->preferences()->showLasCurveWithoutTvdWarning() )
|
||||
{
|
||||
QString tmp = QString(
|
||||
"Display of True Vertical Depth (TVD) for LAS curves is not possible without a well "
|
||||
"log path, and the LAS curve will be hidden in this mode.\n\n" );
|
||||
tmp += "Control display of this warning from \"Preferences->Show LAS curve without TVD "
|
||||
"warning\"";
|
||||
|
||||
QMessageBox::warning( nullptr, "LAS curve without TVD", tmp );
|
||||
tvdMslValues.push_back(
|
||||
-rigWellPath->interpolatedPointAlongWellPath( measuredDepthValue ).z() );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
std::map<RiaDefines::DepthTypeEnum, std::vector<double>> validDepths;
|
||||
if ( values.size() == measuredDepthValues.size() )
|
||||
{
|
||||
if ( values.size() == measuredDepthValues.size() )
|
||||
{
|
||||
this->setValuesAndDepths( values,
|
||||
measuredDepthValues,
|
||||
RiaDefines::MEASURED_DEPTH,
|
||||
0.0,
|
||||
wellLogFile->depthUnit(),
|
||||
false );
|
||||
}
|
||||
validDepths.insert( std::make_pair( RiaDefines::MEASURED_DEPTH, measuredDepthValues ) );
|
||||
}
|
||||
if ( values.size() == tvdMslValues.size() )
|
||||
{
|
||||
validDepths.insert( std::make_pair( RiaDefines::TRUE_VERTICAL_DEPTH, tvdMslValues ) );
|
||||
}
|
||||
if ( values.size() == tvdRkbValues.size() )
|
||||
{
|
||||
validDepths.insert( std::make_pair( RiaDefines::TRUE_VERTICAL_DEPTH_RKB, tvdRkbValues ) );
|
||||
}
|
||||
|
||||
this->setValuesAndDepths( values, validDepths, rkbDiff, wellLogFile->depthUnit(), false );
|
||||
|
||||
QString errMsg;
|
||||
if ( wellLogPlot && !this->curveData()->availableDepthTypes().count( wellLogPlot->depthType() ) )
|
||||
{
|
||||
QString depthTitle = wellLogPlot->depthAxisTitle();
|
||||
errMsg = QString( "Display of %1 for LAS curves is not possible without %1 "
|
||||
"values in the LAS-file or a well path to derive them from." )
|
||||
.arg( depthTitle )
|
||||
.arg( depthTitle );
|
||||
}
|
||||
|
||||
bool showWarning = !RiaApplication::instance()->preferences()->showLasCurveWithoutTvdWarning();
|
||||
if ( !errMsg.isEmpty() && showWarning )
|
||||
{
|
||||
QString tmp = QString( "The LAS curve can not be displayed.\n%1\n" ).arg( errMsg );
|
||||
tmp += "Control display of this warning from \"Preferences->Show LAS curve without TVD "
|
||||
"warning\"";
|
||||
|
||||
QMessageBox::warning( nullptr, "LAS curve without current depth type", tmp );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -345,13 +345,16 @@ void RigLasFileExporter::wellPathsAndRkbDiff( std::vector<QString>* wellNames, s
|
||||
|
||||
for ( auto metaData : lasFileDescriptions )
|
||||
{
|
||||
QString wellName = metaData.wellName();
|
||||
if ( uniqueWellNames.find( wellName ) == uniqueWellNames.end() )
|
||||
if ( metaData.rkbDiff() != std::numeric_limits<double>::infinity() )
|
||||
{
|
||||
uniqueWellNames.insert( wellName );
|
||||
QString wellName = metaData.wellName();
|
||||
if ( uniqueWellNames.find( wellName ) == uniqueWellNames.end() )
|
||||
{
|
||||
uniqueWellNames.insert( wellName );
|
||||
|
||||
wellNames->push_back( wellName );
|
||||
rkbDiffs->push_back( metaData.rkbDiff() );
|
||||
wellNames->push_back( wellName );
|
||||
rkbDiffs->push_back( metaData.rkbDiff() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -105,20 +105,34 @@ const std::vector<double>& RigWellLogCurveData::xValues() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RigWellLogCurveData::depths( RiaDefines::DepthTypeEnum depthType ) const
|
||||
{
|
||||
if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH_RKB && m_rkbDiff != 0.0 )
|
||||
auto it = m_depths.find( depthType );
|
||||
if ( it != m_depths.end() )
|
||||
{
|
||||
std::vector<double> tvds = depths( RiaDefines::TRUE_VERTICAL_DEPTH );
|
||||
for ( double& tvdValue : tvds )
|
||||
return it->second;
|
||||
}
|
||||
|
||||
if ( m_rkbDiff != 0.0 )
|
||||
{
|
||||
if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH_RKB && m_depths.count( RiaDefines::TRUE_VERTICAL_DEPTH ) )
|
||||
{
|
||||
tvdValue += m_rkbDiff;
|
||||
std::vector<double> tvds = depths( RiaDefines::TRUE_VERTICAL_DEPTH );
|
||||
for ( double& tvdValue : tvds )
|
||||
{
|
||||
tvdValue += m_rkbDiff;
|
||||
}
|
||||
return tvds;
|
||||
}
|
||||
else if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH && m_depths.count( RiaDefines::TRUE_VERTICAL_DEPTH_RKB ) )
|
||||
{
|
||||
std::vector<double> tvds = depths( RiaDefines::TRUE_VERTICAL_DEPTH_RKB );
|
||||
for ( double& tvdValue : tvds )
|
||||
{
|
||||
tvdValue -= m_rkbDiff;
|
||||
}
|
||||
return tvds;
|
||||
}
|
||||
return tvds;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = m_depths.find( depthType );
|
||||
return it != m_depths.end() ? it->second : std::vector<double>();
|
||||
}
|
||||
return std::vector<double>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -131,11 +145,22 @@ std::set<RiaDefines::DepthTypeEnum> RigWellLogCurveData::availableDepthTypes() c
|
||||
for ( auto depthValuePair : m_depths )
|
||||
{
|
||||
depthTypes.insert( depthValuePair.first );
|
||||
if ( depthValuePair.first == RiaDefines::TRUE_VERTICAL_DEPTH && m_rkbDiff != 0.0 )
|
||||
}
|
||||
|
||||
if ( m_rkbDiff != 0.0 )
|
||||
{
|
||||
if ( depthTypes.count( RiaDefines::TRUE_VERTICAL_DEPTH ) &&
|
||||
!depthTypes.count( RiaDefines::TRUE_VERTICAL_DEPTH_RKB ) )
|
||||
{
|
||||
depthTypes.insert( RiaDefines::TRUE_VERTICAL_DEPTH_RKB );
|
||||
}
|
||||
else if ( depthTypes.count( RiaDefines::TRUE_VERTICAL_DEPTH_RKB ) &&
|
||||
!depthTypes.count( RiaDefines::TRUE_VERTICAL_DEPTH ) )
|
||||
{
|
||||
depthTypes.insert( RiaDefines::TRUE_VERTICAL_DEPTH );
|
||||
}
|
||||
}
|
||||
|
||||
return depthTypes;
|
||||
}
|
||||
|
||||
|
@@ -104,6 +104,10 @@ bool RigWellLogFile::open( const QString& fileName, QString* errorMessage )
|
||||
{
|
||||
m_tvdMslLogName = logName;
|
||||
}
|
||||
else if ( logName.toUpper() == "TVDRKB" )
|
||||
{
|
||||
m_tvdRkbLogName = logName;
|
||||
}
|
||||
}
|
||||
|
||||
m_wellLogChannelNames = wellLogNames;
|
||||
@@ -169,6 +173,14 @@ std::vector<double> RigWellLogFile::tvdMslValues() const
|
||||
return values( m_tvdMslLogName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RigWellLogFile::tvdRkbValues() const
|
||||
{
|
||||
return values( m_tvdRkbLogName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -251,11 +263,19 @@ QString RigWellLogFile::wellLogChannelUnitString( const QString& well
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigWellLogFile::hasTvdChannel() const
|
||||
bool RigWellLogFile::hasTvdMslChannel() const
|
||||
{
|
||||
return !m_tvdMslLogName.isEmpty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigWellLogFile::hasTvdRkbChannel() const
|
||||
{
|
||||
return !m_tvdRkbLogName.isEmpty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -50,13 +50,16 @@ public:
|
||||
|
||||
std::vector<double> depthValues() const;
|
||||
std::vector<double> tvdMslValues() const;
|
||||
std::vector<double> tvdRkbValues() const;
|
||||
|
||||
std::vector<double> values( const QString& name ) const;
|
||||
|
||||
QString wellLogChannelUnitString( const QString& wellLogChannelName,
|
||||
RiaDefines::DepthUnitType displayDepthUnit ) const;
|
||||
RiaDefines::DepthUnitType depthUnit() const;
|
||||
|
||||
bool hasTvdChannel() const;
|
||||
bool hasTvdMslChannel() const;
|
||||
bool hasTvdRkbChannel() const;
|
||||
|
||||
private:
|
||||
void close();
|
||||
@@ -66,4 +69,5 @@ private:
|
||||
QStringList m_wellLogChannelNames;
|
||||
QString m_depthLogName;
|
||||
QString m_tvdMslLogName;
|
||||
QString m_tvdRkbLogName;
|
||||
};
|
||||
|
Reference in New Issue
Block a user