diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp index 849a32c29f..f94c4470d3 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp @@ -58,6 +58,8 @@ RigWellLogCsvFile::~RigWellLogCsvFile() bool RigWellLogCsvFile::open( const QString& fileName, RigWellPath* wellPath, QString* errorMessage ) { m_wellLogChannelNames.clear(); + double samplingInterval = 1.0; + cvf::cref resampledWellPath = resampleWellPath( *wellPath, samplingInterval ); RifCsvUserDataFileParser parser( fileName, errorMessage ); @@ -104,14 +106,14 @@ bool RigWellLogCsvFile::open( const QString& fileName, RigWellPath* wellPath, QS if ( channelName == m_tvdMslLogName ) { // Use TVD from well path. - m_values[m_tvdMslLogName] = wellPath->trueVerticalDepths(); + m_values[m_tvdMslLogName] = resampledWellPath->trueVerticalDepths(); } else { CAF_ASSERT( readValues.size() == readTvds.size() ); - auto wellPathMds = wellPath->measuredDepths(); - auto wellPathTvds = wellPath->trueVerticalDepths(); + auto wellPathMds = resampledWellPath->measuredDepths(); + auto wellPathTvds = resampledWellPath->trueVerticalDepths(); // Interpolate values for the well path depths (from TVD). // Assumes that the well channel values is dependent on TVD only (MD is not considered). @@ -128,7 +130,7 @@ bool RigWellLogCsvFile::open( const QString& fileName, RigWellPath* wellPath, QS // Use MD from well path. m_depthLogName = "DEPTH"; - m_values[m_depthLogName] = wellPath->measuredDepths(); + m_values[m_depthLogName] = resampledWellPath->measuredDepths(); return true; } @@ -229,3 +231,37 @@ double RigWellLogCsvFile::getMissingValue() const { return std::numeric_limits::infinity(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigWellPath* RigWellLogCsvFile::resampleWellPath( const RigWellPath& wellPath, double samplingInterval ) +{ + std::vector measuredDepths = resampleMeasuredDepths( wellPath.measuredDepths(), samplingInterval ); + + std::vector wellPathPoints; + for ( double md : measuredDepths ) + { + wellPathPoints.push_back( wellPath.interpolatedPointAlongWellPath( md ) ); + } + + return new RigWellPath( wellPathPoints, measuredDepths ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigWellLogCsvFile::resampleMeasuredDepths( const std::vector& measuredDepths, double samplingInterval ) +{ + double firstMd = measuredDepths.front(); + double lastMd = measuredDepths.back(); + + std::vector resampledMds; + for ( double md = firstMd; md < lastMd; md += samplingInterval ) + { + resampledMds.push_back( md ); + } + resampledMds.push_back( lastMd ); + + return resampledMds; +} diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.h b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.h index 78857d8779..aa25027fb8 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.h +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.h @@ -60,6 +60,9 @@ class RigWellLogCsvFile : public RigWellLogFile void close(); QString depthUnitString() const override; + static RigWellPath* resampleWellPath( const RigWellPath& wellPath, double samplingInterval ); + static std::vector resampleMeasuredDepths( const std::vector& measuredDepths, double samplingInterval ); + QStringList m_wellLogChannelNames; QString m_depthLogName; QString m_tvdMslLogName;