mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#10663 WBS Plot: Import well log from CSV file.
Also compute SH_MK_MIN/EXP/MAX and FG_MK_MIN/EXP results.
This commit is contained in:
231
ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp
Normal file
231
ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp
Normal file
@@ -0,0 +1,231 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2024- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RigWellLogCsvFile.h"
|
||||
|
||||
#include "RiaInterpolationTools.h"
|
||||
#include "RifCsvUserDataParser.h"
|
||||
#include "RigWellLogCurveData.h"
|
||||
#include "RigWellPathGeometryTools.h"
|
||||
|
||||
#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaStringEncodingTools.h"
|
||||
|
||||
#include "RimWellLogCurve.h"
|
||||
#include "RimWellPath.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QString>
|
||||
|
||||
#include <limits>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigWellLogCsvFile::RigWellLogCsvFile()
|
||||
: RigWellLogFile()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigWellLogCsvFile::~RigWellLogCsvFile()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigWellLogCsvFile::open( const QString& fileName, RigWellPath* wellPath, QString* errorMessage )
|
||||
{
|
||||
m_wellLogChannelNames.clear();
|
||||
|
||||
RifCsvUserDataFileParser parser( fileName, errorMessage );
|
||||
|
||||
AsciiDataParseOptions parseOptions;
|
||||
parseOptions.useCustomDateTimeFormat = true;
|
||||
parseOptions.dateTimeFormat = "dd.MM.yyyy hh:mm:ss";
|
||||
parseOptions.fallbackDateTimeFormat = "dd.MM.yyyy";
|
||||
parseOptions.cellSeparator = ";";
|
||||
parseOptions.decimalSeparator = ",";
|
||||
|
||||
if ( !parser.parse( parseOptions ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::map<QString, std::vector<double>> readValues;
|
||||
|
||||
for ( auto s : parser.tableData().columnInfos() )
|
||||
{
|
||||
if ( s.dataType != Column::NUMERIC ) continue;
|
||||
QString columnName = QString::fromStdString( s.columnName() );
|
||||
m_wellLogChannelNames.append( columnName );
|
||||
readValues[columnName] = s.values;
|
||||
m_units[columnName] = QString::fromStdString( s.unitName );
|
||||
|
||||
if ( columnName.toUpper() == "TVDMSL" || columnName.toUpper().contains( "TVD" ) )
|
||||
{
|
||||
m_tvdMslLogName = columnName;
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_tvdMslLogName.isEmpty() )
|
||||
{
|
||||
QString message = "CSV file does not have TVD values.";
|
||||
RiaLogging::error( message );
|
||||
if ( errorMessage ) *errorMessage = message;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<double> readTvds = readValues[m_tvdMslLogName];
|
||||
|
||||
for ( auto [channelName, readValues] : readValues )
|
||||
{
|
||||
if ( channelName == m_tvdMslLogName )
|
||||
{
|
||||
// Use TVD from well path.
|
||||
m_values[m_tvdMslLogName] = wellPath->trueVerticalDepths();
|
||||
}
|
||||
else
|
||||
{
|
||||
CAF_ASSERT( readValues.size() == readTvds.size() );
|
||||
|
||||
auto wellPathMds = wellPath->measuredDepths();
|
||||
auto wellPathTvds = wellPath->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).
|
||||
std::vector<double> values;
|
||||
for ( auto tvd : wellPathTvds )
|
||||
{
|
||||
double value = RiaInterpolationTools::linear( readTvds, readValues, tvd, RiaInterpolationTools::ExtrapolationMode::TREND );
|
||||
values.push_back( value );
|
||||
}
|
||||
|
||||
m_values[channelName] = values;
|
||||
}
|
||||
}
|
||||
|
||||
// Use MD from well path.
|
||||
m_depthLogName = "DEPTH";
|
||||
m_values[m_depthLogName] = wellPath->measuredDepths();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigWellLogCsvFile::close()
|
||||
{
|
||||
m_wellLogChannelNames.clear();
|
||||
m_depthLogName.clear();
|
||||
m_values.clear();
|
||||
m_units.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList RigWellLogCsvFile::wellLogChannelNames() const
|
||||
{
|
||||
return m_wellLogChannelNames;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RigWellLogCsvFile::depthValues() const
|
||||
{
|
||||
return values( m_depthLogName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RigWellLogCsvFile::tvdMslValues() const
|
||||
{
|
||||
return values( m_tvdMslLogName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RigWellLogCsvFile::tvdRkbValues() const
|
||||
{
|
||||
// Not supported.
|
||||
return std::vector<double>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RigWellLogCsvFile::values( const QString& name ) const
|
||||
{
|
||||
if ( auto it = m_values.find( name ); it != m_values.end() ) return it->second;
|
||||
return std::vector<double>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RigWellLogCsvFile::depthUnitString() const
|
||||
{
|
||||
return wellLogChannelUnitString( m_tvdMslLogName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RigWellLogCsvFile::wellLogChannelUnitString( const QString& wellLogChannelName ) const
|
||||
{
|
||||
auto unit = m_units.find( wellLogChannelName );
|
||||
if ( unit != m_units.end() )
|
||||
return unit->second;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigWellLogCsvFile::hasTvdMslChannel() const
|
||||
{
|
||||
return !m_tvdMslLogName.isEmpty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigWellLogCsvFile::hasTvdRkbChannel() const
|
||||
{
|
||||
return !m_tvdRkbLogName.isEmpty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RigWellLogCsvFile::getMissingValue() const
|
||||
{
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
Reference in New Issue
Block a user