mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 07:30:20 -05:00
Python: Update well log import API to accept measured depth and multiple channels
- Updated Python API to accept measured_depth list and channel_data dictionary - Modified C++ GRPC implementation to handle CSV-formatted channel mappings - Replaced single values parameter with dictionary of channels - Added comprehensive validation for all input parameters - Updated parameter name from channel_keys_json to channel_keys_csv - Enhanced tests to cover 16 different scenarios including edge cases - Updated example to demonstrate new dictionary-based API functionality
This commit is contained in:
1 parent
8089739add
commit
160cb71168
16 files changed
+1211
-126
No files matched your search
@@ -34,6 +34,8 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileDataLoader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogDataLoader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimImportedWellLog.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimImportedWellLogData.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellLogChannelData.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -74,6 +76,8 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileDataLoader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogDataLoader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimImportedWellLog.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimImportedWellLogData.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellLogChannelData.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
|
||||
#include "RimImportedWellLog.h"
|
||||
|
||||
#include "Well/RigImportedWellLogData.h"
|
||||
|
||||
#include "RimImportedWellLogData.h"
|
||||
#include "RimWellLogChannel.h"
|
||||
#include "RimWellPath.h"
|
||||
|
||||
#include "Well/RigImportedWellLogData.h"
|
||||
|
||||
#include "RiaFieldHandleTools.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
@@ -41,6 +43,9 @@ RimImportedWellLog::RimImportedWellLog()
|
||||
CAF_PDM_InitScriptableField( &m_name, "Name", QString(), "Name" );
|
||||
m_name.uiCapability()->setUiReadOnly( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_wellLogData, "WellLogData", "Well Log Data" );
|
||||
m_wellLogData.uiCapability()->setUiTreeChildrenHidden( true );
|
||||
|
||||
setDeletable( true );
|
||||
}
|
||||
|
||||
@@ -65,8 +70,8 @@ QString RimImportedWellLog::name() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimImportedWellLog::wellName() const
|
||||
{
|
||||
RimWellPath* wellPath = firstAncestorOrThisOfType<RimWellPath>();
|
||||
if ( wellPath )
|
||||
if ( RimWellPath* wellPath = firstAncestorOrThisOfType<RimWellPath>() )
|
||||
|
||||
{
|
||||
return wellPath->name();
|
||||
}
|
||||
@@ -78,15 +83,46 @@ QString RimImportedWellLog::wellName() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigWellLogData* RimImportedWellLog::wellLogData()
|
||||
{
|
||||
return m_wellLogData.p();
|
||||
return m_cachedRigData.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimImportedWellLog::setWellLogData( RigImportedWellLogData* wellLogData )
|
||||
void RimImportedWellLog::setWellLogData( RimImportedWellLogData* wellLogData )
|
||||
{
|
||||
m_wellLogData = wellLogData;
|
||||
// Clear cached Rig data when setting new PDM data
|
||||
m_cachedRigData = nullptr;
|
||||
|
||||
if ( wellLogData )
|
||||
{
|
||||
// Create temporary Rig data to update channels
|
||||
m_cachedRigData = wellLogData->createRigData();
|
||||
updateChannelsFromWellLogData( m_cachedRigData.p() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_wellLogChannels.deleteChildren();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimImportedWellLog::updateChannelsFromWellLogData( RigImportedWellLogData* wellLogData )
|
||||
{
|
||||
m_wellLogChannels.deleteChildren();
|
||||
|
||||
if ( !wellLogData ) return;
|
||||
|
||||
QStringList wellLogNames = wellLogData->wellLogChannelNames();
|
||||
for ( int logIdx = 0; logIdx < wellLogNames.size(); logIdx++ )
|
||||
{
|
||||
RimWellLogChannel* wellLog = new RimWellLogChannel();
|
||||
wellLog->setName( wellLogNames[logIdx] );
|
||||
m_wellLogChannels.push_back( wellLog );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -97,10 +133,11 @@ std::vector<std::pair<double, double>>
|
||||
{
|
||||
if ( unitString ) *unitString = QString();
|
||||
|
||||
if ( !m_wellLogData.notNull() ) return {};
|
||||
RigWellLogData* wld = wellLogData();
|
||||
if ( !wld ) return {};
|
||||
|
||||
std::vector<double> depths = m_wellLogData->depthValues();
|
||||
std::vector<double> values = m_wellLogData->values( channelName );
|
||||
std::vector<double> depths = wld->depthValues();
|
||||
std::vector<double> values = wld->values( channelName );
|
||||
|
||||
std::vector<std::pair<double, double>> depthValuePairs;
|
||||
if ( depths.size() == values.size() )
|
||||
@@ -114,10 +151,23 @@ std::vector<std::pair<double, double>>
|
||||
return depthValuePairs;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimImportedWellLog::initAfterRead()
|
||||
{
|
||||
// Create cached Rig data from PDM data when loading from project file
|
||||
if ( m_wellLogData() && !m_cachedRigData.notNull() )
|
||||
{
|
||||
m_cachedRigData = m_wellLogData()->createRigData();
|
||||
updateChannelsFromWellLogData( m_cachedRigData.p() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimImportedWellLog::userDescriptionField()
|
||||
{
|
||||
return &m_name;
|
||||
}
|
||||
}
|
||||
@@ -20,12 +20,14 @@
|
||||
|
||||
#include "RimWellLog.h"
|
||||
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class RigImportedWellLogData;
|
||||
class RimImportedWellLogData;
|
||||
class RimWellPath;
|
||||
|
||||
//==================================================================================================
|
||||
@@ -44,15 +46,20 @@ public:
|
||||
QString wellName() const override;
|
||||
|
||||
RigWellLogData* wellLogData() override;
|
||||
void setWellLogData( RigImportedWellLogData* wellLogData );
|
||||
void setWellLogData( RimImportedWellLogData* wellLogData );
|
||||
|
||||
std::vector<std::pair<double, double>>
|
||||
findMdAndChannelValuesForWellPath( const RimWellPath& wellPath, const QString& channelName, QString* unitString = nullptr ) override;
|
||||
|
||||
private:
|
||||
void initAfterRead() override;
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
void updateChannelsFromWellLogData( RigImportedWellLogData* wellLogData );
|
||||
|
||||
private:
|
||||
cvf::ref<RigImportedWellLogData> m_wellLogData;
|
||||
caf::PdmField<QString> m_name;
|
||||
};
|
||||
// PDM-based data storage for project file persistence
|
||||
caf::PdmChildField<RimImportedWellLogData*> m_wellLogData;
|
||||
caf::PdmField<QString> m_name;
|
||||
|
||||
cvf::ref<RigImportedWellLogData> m_cachedRigData;
|
||||
};
|
||||
@@ -0,0 +1,181 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2025 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 "RimImportedWellLogData.h"
|
||||
|
||||
#include "RimWellLogChannelData.h"
|
||||
|
||||
#include "Well/RigImportedWellLogData.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimImportedWellLogData, "ImportedWellLogData" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimImportedWellLogData::RimImportedWellLogData()
|
||||
{
|
||||
CAF_PDM_InitObject( "Imported Well Log Data", "", "", "Imported Well Log Data" );
|
||||
|
||||
CAF_PDM_InitField( &m_depthValues, "DepthValues", {}, "Depth Values" );
|
||||
CAF_PDM_InitField( &m_tvdMslValues, "TvdMslValues", {}, "TVD MSL Values" );
|
||||
CAF_PDM_InitField( &m_tvdRkbValues, "TvdRkbValues", {}, "TVD RKB Values" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_channelDataObjects, "ChannelDataObjects", "Channel Data Objects" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimImportedWellLogData::setDepthValues( const std::vector<double>& depths )
|
||||
{
|
||||
m_depthValues = depths;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimImportedWellLogData::setTvdMslValues( const std::vector<double>& tvdMsl )
|
||||
{
|
||||
m_tvdMslValues = tvdMsl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimImportedWellLogData::setTvdRkbValues( const std::vector<double>& tvdRkb )
|
||||
{
|
||||
m_tvdRkbValues = tvdRkb;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimImportedWellLogData::setChannelData( const QString& name, const std::vector<double>& values )
|
||||
{
|
||||
// Check if channel already exists
|
||||
for ( RimWellLogChannelData* channelData : m_channelDataObjects )
|
||||
{
|
||||
if ( channelData->name() == name )
|
||||
{
|
||||
channelData->setValues( values );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new channel data object
|
||||
RimWellLogChannelData* channelData = new RimWellLogChannelData();
|
||||
channelData->setName( name );
|
||||
channelData->setValues( values );
|
||||
m_channelDataObjects.push_back( channelData );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimImportedWellLogData::depthValues() const
|
||||
{
|
||||
return m_depthValues();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimImportedWellLogData::tvdMslValues() const
|
||||
{
|
||||
return m_tvdMslValues();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimImportedWellLogData::tvdRkbValues() const
|
||||
{
|
||||
return m_tvdRkbValues();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RimImportedWellLogData::channelNames() const
|
||||
{
|
||||
std::vector<QString> names;
|
||||
for ( const RimWellLogChannelData* channelData : m_channelDataObjects )
|
||||
{
|
||||
names.push_back( channelData->name() );
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimImportedWellLogData::channelValues( const QString& name ) const
|
||||
{
|
||||
for ( const RimWellLogChannelData* channelData : m_channelDataObjects )
|
||||
{
|
||||
if ( channelData->name() == name )
|
||||
{
|
||||
return channelData->values();
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimImportedWellLogData::hasTvdMslValues() const
|
||||
{
|
||||
return !m_tvdMslValues().empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimImportedWellLogData::hasTvdRkbValues() const
|
||||
{
|
||||
return !m_tvdRkbValues().empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RigImportedWellLogData> RimImportedWellLogData::createRigData() const
|
||||
{
|
||||
cvf::ref<RigImportedWellLogData> rigData = new RigImportedWellLogData();
|
||||
|
||||
// Set depth values
|
||||
rigData->setDepthValues( m_depthValues() );
|
||||
|
||||
// Set TVD values if present
|
||||
if ( hasTvdMslValues() )
|
||||
{
|
||||
rigData->setTvdMslValues( m_tvdMslValues() );
|
||||
}
|
||||
if ( hasTvdRkbValues() )
|
||||
{
|
||||
rigData->setTvdRkbValues( m_tvdRkbValues() );
|
||||
}
|
||||
|
||||
// Set channel data
|
||||
for ( const RimWellLogChannelData* channelData : m_channelDataObjects )
|
||||
{
|
||||
rigData->setChannelData( channelData->name(), channelData->values() );
|
||||
}
|
||||
|
||||
return rigData;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2025 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
class RigImportedWellLogData;
|
||||
class RimWellLogChannelData;
|
||||
|
||||
//==================================================================================================
|
||||
/// PDM class for storing imported well log data that can be persisted to project files
|
||||
//==================================================================================================
|
||||
class RimImportedWellLogData : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimImportedWellLogData();
|
||||
|
||||
// Setters for data
|
||||
void setDepthValues( const std::vector<double>& depths );
|
||||
void setTvdMslValues( const std::vector<double>& tvdMsl );
|
||||
void setTvdRkbValues( const std::vector<double>& tvdRkb );
|
||||
void setChannelData( const QString& name, const std::vector<double>& values );
|
||||
|
||||
// Getters for data
|
||||
std::vector<double> depthValues() const;
|
||||
std::vector<double> tvdMslValues() const;
|
||||
std::vector<double> tvdRkbValues() const;
|
||||
std::vector<QString> channelNames() const;
|
||||
std::vector<double> channelValues( const QString& name ) const;
|
||||
|
||||
bool hasTvdMslValues() const;
|
||||
bool hasTvdRkbValues() const;
|
||||
|
||||
// Method to produce RigImportedWellLogData from PDM data
|
||||
cvf::ref<RigImportedWellLogData> createRigData() const;
|
||||
|
||||
private:
|
||||
caf::PdmField<std::vector<double>> m_depthValues;
|
||||
caf::PdmField<std::vector<double>> m_tvdMslValues;
|
||||
caf::PdmField<std::vector<double>> m_tvdRkbValues;
|
||||
caf::PdmChildArrayField<RimWellLogChannelData*> m_channelDataObjects;
|
||||
};
|
||||
@@ -0,0 +1,64 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2025 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 "RimWellLogChannelData.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimWellLogChannelData, "WellLogChannelData" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellLogChannelData::RimWellLogChannelData()
|
||||
{
|
||||
CAF_PDM_InitObject( "Well Log Channel Data", "", "", "Well Log Channel Data" );
|
||||
|
||||
CAF_PDM_InitField( &m_name, "Name", QString(), "Name" );
|
||||
CAF_PDM_InitField( &m_values, "Values", {}, "Values" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogChannelData::setName( const QString& name )
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellLogChannelData::name() const
|
||||
{
|
||||
return m_name();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogChannelData::setValues( const std::vector<double>& values )
|
||||
{
|
||||
m_values = values;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimWellLogChannelData::values() const
|
||||
{
|
||||
return m_values();
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2025 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
/// PDM class for storing individual channel data (name and values) for well logs
|
||||
//==================================================================================================
|
||||
class RimWellLogChannelData : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimWellLogChannelData();
|
||||
|
||||
void setName( const QString& name );
|
||||
QString name() const;
|
||||
|
||||
void setValues( const std::vector<double>& values );
|
||||
std::vector<double> values() const;
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_name;
|
||||
caf::PdmField<std::vector<double>> m_values;
|
||||
};
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "Rim3dWellLogCurveCollection.h"
|
||||
#include "RimFishbones.h"
|
||||
#include "RimFishbonesCollection.h"
|
||||
#include "RimImportedWellLog.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimMswCompletionParameters.h"
|
||||
#include "RimOsduWellLog.h"
|
||||
@@ -933,6 +934,10 @@ void RimWellPath::addWellLog( RimWellLog* wellLog )
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( RimImportedWellLog* importedWellLog = dynamic_cast<RimImportedWellLog*>( wellLog ) )
|
||||
{
|
||||
m_wellLogs.push_back( importedWellLog );
|
||||
}
|
||||
else if ( RimOsduWellLog* osduWellLog = dynamic_cast<RimOsduWellLog*>( wellLog ) )
|
||||
{
|
||||
m_wellLogs.push_back( osduWellLog );
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RimImportedWellLog.h"
|
||||
#include "RimImportedWellLogData.h"
|
||||
#include "Well/RigImportedWellLogData.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
@@ -406,7 +407,10 @@ RimcWellPath_addWellLogInternal::RimcWellPath_addWellLogInternal( caf::PdmObject
|
||||
CAF_PDM_InitObject( "Add Well Log", "", "", "Add Well Log" );
|
||||
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_name, "Name", "Name" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_valuesKey, "ValuesKey", "Values Key" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_measuredDepthKey, "MeasuredDepthKey", "Measured Depth Key" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_channelKeysCsv, "ChannelKeysCsv", "Channel Keys CSV" );
|
||||
CAF_PDM_InitScriptableField( &m_tvdMslKey, "TvdMslKey", QString(), "TVD MSL Key" );
|
||||
CAF_PDM_InitScriptableField( &m_tvdRkbKey, "TvdRkbKey", QString(), "TVD RKB Key" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -421,52 +425,184 @@ std::expected<caf::PdmObjectHandle*, QString> RimcWellPath_addWellLogInternal::e
|
||||
return std::unexpected( "Well log name cannot be empty" );
|
||||
}
|
||||
|
||||
if ( m_valuesKey().isEmpty() )
|
||||
if ( m_measuredDepthKey().isEmpty() )
|
||||
{
|
||||
return std::unexpected( "Values key cannot be empty" );
|
||||
return std::unexpected( "Measured depth key cannot be empty" );
|
||||
}
|
||||
|
||||
if ( m_channelKeysCsv().isEmpty() )
|
||||
{
|
||||
return std::unexpected( "Channel keys CSV cannot be empty" );
|
||||
}
|
||||
|
||||
// Retrieve values from key-value store
|
||||
auto keyValueStore = RiaApplication::instance()->keyValueStore();
|
||||
auto valuesData = keyValueStore->get( m_valuesKey().toStdString() );
|
||||
|
||||
if ( !valuesData.has_value() )
|
||||
// Retrieve measured depth values from key-value store
|
||||
auto measuredDepthData = keyValueStore->get( m_measuredDepthKey().toStdString() );
|
||||
if ( !measuredDepthData.has_value() )
|
||||
{
|
||||
return std::unexpected( "Failed to retrieve values from key-value store" );
|
||||
return std::unexpected( "Failed to retrieve measured depth from key-value store" );
|
||||
}
|
||||
|
||||
// Convert from char vector to double vector
|
||||
std::vector<float> values = RiaKeyValueStoreUtil::convertToFloatVector( valuesData );
|
||||
if ( values.empty() )
|
||||
std::vector<float> measuredDepthFloat = RiaKeyValueStoreUtil::convertToFloatVector( measuredDepthData );
|
||||
if ( measuredDepthFloat.empty() )
|
||||
{
|
||||
return std::unexpected( "Values array cannot be empty" );
|
||||
return std::unexpected( "Measured depth array cannot be empty" );
|
||||
}
|
||||
|
||||
// Create well log data
|
||||
auto wellLogData = new RigImportedWellLogData();
|
||||
|
||||
// Generate measured depth values from 0 to size-1 (assuming unit spacing)
|
||||
std::vector<double> depthValues;
|
||||
std::vector<double> doubleValues;
|
||||
for ( size_t i = 0; i < values.size(); ++i )
|
||||
// Convert to double
|
||||
std::vector<double> measuredDepth;
|
||||
for ( float value : measuredDepthFloat )
|
||||
{
|
||||
depthValues.push_back( static_cast<double>( i ) );
|
||||
doubleValues.push_back( values[i] );
|
||||
measuredDepth.push_back( static_cast<double>( value ) );
|
||||
}
|
||||
|
||||
wellLogData->setDepthValues( depthValues );
|
||||
wellLogData->setChannelData( m_name(), doubleValues );
|
||||
// Handle optional TVD MSL
|
||||
std::vector<double> tvdMslValues;
|
||||
if ( !m_tvdMslKey().isEmpty() )
|
||||
{
|
||||
auto tvdMslData = keyValueStore->get( m_tvdMslKey().toStdString() );
|
||||
if ( !tvdMslData.has_value() )
|
||||
{
|
||||
return std::unexpected( "Failed to retrieve TVD MSL from key-value store" );
|
||||
}
|
||||
|
||||
std::vector<float> tvdMslFloat = RiaKeyValueStoreUtil::convertToFloatVector( tvdMslData );
|
||||
if ( tvdMslFloat.size() != measuredDepth.size() )
|
||||
{
|
||||
return std::unexpected(
|
||||
QString( "TVD MSL has %1 values but measured depth has %2 values" ).arg( tvdMslFloat.size() ).arg( measuredDepth.size() ) );
|
||||
}
|
||||
|
||||
for ( float value : tvdMslFloat )
|
||||
{
|
||||
tvdMslValues.push_back( static_cast<double>( value ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Handle optional TVD RKB
|
||||
std::vector<double> tvdRkbValues;
|
||||
if ( !m_tvdRkbKey().isEmpty() )
|
||||
{
|
||||
auto tvdRkbData = keyValueStore->get( m_tvdRkbKey().toStdString() );
|
||||
if ( !tvdRkbData.has_value() )
|
||||
{
|
||||
return std::unexpected( "Failed to retrieve TVD RKB from key-value store" );
|
||||
}
|
||||
|
||||
std::vector<float> tvdRkbFloat = RiaKeyValueStoreUtil::convertToFloatVector( tvdRkbData );
|
||||
if ( tvdRkbFloat.size() != measuredDepth.size() )
|
||||
{
|
||||
return std::unexpected(
|
||||
QString( "TVD RKB has %1 values but measured depth has %2 values" ).arg( tvdRkbFloat.size() ).arg( measuredDepth.size() ) );
|
||||
}
|
||||
|
||||
for ( float value : tvdRkbFloat )
|
||||
{
|
||||
tvdRkbValues.push_back( static_cast<double>( value ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Parse channel keys CSV (format: "channel1:key1,channel2:key2,...")
|
||||
QString channelKeysStr = m_channelKeysCsv();
|
||||
if ( channelKeysStr.isEmpty() )
|
||||
{
|
||||
return std::unexpected( "Channel keys cannot be empty" );
|
||||
}
|
||||
|
||||
QStringList channelMappings = channelKeysStr.split( ",", Qt::SkipEmptyParts );
|
||||
if ( channelMappings.isEmpty() )
|
||||
{
|
||||
return std::unexpected( "Channel data cannot be empty" );
|
||||
}
|
||||
|
||||
QMap<QString, QString> channelKeysMap;
|
||||
for ( const QString& mapping : channelMappings )
|
||||
{
|
||||
QStringList parts = mapping.split( ":", Qt::SkipEmptyParts );
|
||||
if ( parts.size() != 2 )
|
||||
{
|
||||
return std::unexpected( QString( "Invalid channel mapping format: %1" ).arg( mapping ) );
|
||||
}
|
||||
QString channelName = parts[0];
|
||||
QString channelKey = parts[1];
|
||||
|
||||
if ( channelName.isEmpty() || channelKey.isEmpty() )
|
||||
{
|
||||
return std::unexpected( QString( "Empty channel name or key in mapping: %1" ).arg( mapping ) );
|
||||
}
|
||||
|
||||
channelKeysMap[channelName] = channelKey;
|
||||
}
|
||||
|
||||
// Create PDM well log data for project file persistence
|
||||
auto pdmWellLogData = new RimImportedWellLogData();
|
||||
pdmWellLogData->setDepthValues( measuredDepth );
|
||||
|
||||
// Set optional TVD data
|
||||
if ( !tvdMslValues.empty() )
|
||||
{
|
||||
pdmWellLogData->setTvdMslValues( tvdMslValues );
|
||||
}
|
||||
if ( !tvdRkbValues.empty() )
|
||||
{
|
||||
pdmWellLogData->setTvdRkbValues( tvdRkbValues );
|
||||
}
|
||||
|
||||
// Retrieve and set channel data
|
||||
QStringList keysToCleanup;
|
||||
keysToCleanup.append( m_measuredDepthKey() );
|
||||
if ( !m_tvdMslKey().isEmpty() ) keysToCleanup.append( m_tvdMslKey() );
|
||||
if ( !m_tvdRkbKey().isEmpty() ) keysToCleanup.append( m_tvdRkbKey() );
|
||||
|
||||
for ( auto it = channelKeysMap.begin(); it != channelKeysMap.end(); ++it )
|
||||
{
|
||||
QString channelName = it.key();
|
||||
QString channelKey = it.value();
|
||||
|
||||
keysToCleanup.append( channelKey );
|
||||
|
||||
// Retrieve channel values from key-value store
|
||||
auto channelData = keyValueStore->get( channelKey.toStdString() );
|
||||
if ( !channelData.has_value() )
|
||||
{
|
||||
return std::unexpected( QString( "Failed to retrieve channel '%1' from key-value store" ).arg( channelName ) );
|
||||
}
|
||||
|
||||
std::vector<float> channelValuesFloat = RiaKeyValueStoreUtil::convertToFloatVector( channelData );
|
||||
if ( channelValuesFloat.size() != measuredDepth.size() )
|
||||
{
|
||||
return std::unexpected( QString( "Channel '%1' has %2 values but measured depth has %3 values" )
|
||||
.arg( channelName )
|
||||
.arg( channelValuesFloat.size() )
|
||||
.arg( measuredDepth.size() ) );
|
||||
}
|
||||
|
||||
// Convert to double
|
||||
std::vector<double> channelValues;
|
||||
for ( float value : channelValuesFloat )
|
||||
{
|
||||
channelValues.push_back( static_cast<double>( value ) );
|
||||
}
|
||||
|
||||
pdmWellLogData->setChannelData( channelName, channelValues );
|
||||
}
|
||||
|
||||
// Create well log object
|
||||
auto importedWellLog = new RimImportedWellLog();
|
||||
importedWellLog->setName( m_name() );
|
||||
importedWellLog->setWellLogData( wellLogData );
|
||||
importedWellLog->setWellLogData( pdmWellLogData );
|
||||
|
||||
// Add to well path
|
||||
wellPath->addWellLog( importedWellLog );
|
||||
|
||||
// Clean up key-value store
|
||||
keyValueStore->remove( m_valuesKey().toStdString() );
|
||||
for ( const QString& keyToCleanup : keysToCleanup )
|
||||
{
|
||||
keyValueStore->remove( keyToCleanup.toStdString() );
|
||||
}
|
||||
|
||||
wellPath->updateConnectedEditors();
|
||||
|
||||
return importedWellLog;
|
||||
}
|
||||
|
||||
@@ -160,5 +160,8 @@ public:
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_name;
|
||||
caf::PdmField<QString> m_valuesKey;
|
||||
caf::PdmField<QString> m_measuredDepthKey;
|
||||
caf::PdmField<QString> m_channelKeysCsv;
|
||||
caf::PdmField<QString> m_tvdMslKey;
|
||||
caf::PdmField<QString> m_tvdRkbKey;
|
||||
};
|
||||
@@ -65,8 +65,7 @@ std::vector<double> RigImportedWellLogData::depthValues() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RigImportedWellLogData::tvdMslValues() const
|
||||
{
|
||||
// Not supported for imported data
|
||||
return std::vector<double>();
|
||||
return m_tvdMslValues;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -74,8 +73,7 @@ std::vector<double> RigImportedWellLogData::tvdMslValues() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RigImportedWellLogData::tvdRkbValues() const
|
||||
{
|
||||
// Not supported for imported data
|
||||
return std::vector<double>();
|
||||
return m_tvdRkbValues;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -114,7 +112,7 @@ QString RigImportedWellLogData::depthUnitString() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigImportedWellLogData::hasTvdMslChannel() const
|
||||
{
|
||||
return false;
|
||||
return !m_tvdMslValues.empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -122,7 +120,7 @@ bool RigImportedWellLogData::hasTvdMslChannel() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigImportedWellLogData::hasTvdRkbChannel() const
|
||||
{
|
||||
return false;
|
||||
return !m_tvdRkbValues.empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -147,4 +145,20 @@ void RigImportedWellLogData::setChannelData( const QString& channelName, const s
|
||||
void RigImportedWellLogData::setDepthValues( const std::vector<double>& depthValues )
|
||||
{
|
||||
m_depthValues = depthValues;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigImportedWellLogData::setTvdMslValues( const std::vector<double>& tvdMslValues )
|
||||
{
|
||||
m_tvdMslValues = tvdMslValues;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigImportedWellLogData::setTvdRkbValues( const std::vector<double>& tvdRkbValues )
|
||||
{
|
||||
m_tvdRkbValues = tvdRkbValues;
|
||||
}
|
||||
@@ -53,9 +53,13 @@ public:
|
||||
|
||||
void setChannelData( const QString& channelName, const std::vector<double>& values );
|
||||
void setDepthValues( const std::vector<double>& depthValues );
|
||||
void setTvdMslValues( const std::vector<double>& tvdMslValues );
|
||||
void setTvdRkbValues( const std::vector<double>& tvdRkbValues );
|
||||
|
||||
private:
|
||||
std::vector<double> m_depthValues;
|
||||
std::vector<double> m_tvdMslValues;
|
||||
std::vector<double> m_tvdRkbValues;
|
||||
std::map<QString, std::vector<double>> m_channelData;
|
||||
|
||||
static const double MISSING_VALUE;
|
||||
|
||||
Reference in new issue
Block a user