mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-30 17:10:19 -05:00
Python: Add API for importing well log data
Implement comprehensive Python API for importing well log data into ResInsight well paths using lists of float values. Core implementation: - RigImportedWellLogData: Data storage class inheriting from RigWellLogData - RimImportedWellLog: Scriptable model class for Python GRPC interface - RimcWellPath_addWellLogInternal: GRPC method using key-value store for data transfer - well_path.add_well_log(): Python API with validation and error handling Features: - Simple API: well_path.add_well_log(name='LogName', values=[1.0, 2.0, 3.0]) - Comprehensive input validation and type checking - Efficient data transfer via key-value store mechanism - Proper error handling with cleanup on failure - Integration with existing well path functionality Testing: - 10 comprehensive unit tests covering all functionality - Validation of input types, error conditions, and edge cases - Integration testing with well path creation Usage example included in PythonExamples directory demonstrating import of gamma ray, porosity, and permeability log data.
This commit is contained in:
1 parent
5aab904731
commit
8089739add
11 files changed
+758
No files matched your search
@@ -33,6 +33,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCalculatedCurve.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileDataLoader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogDataLoader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimImportedWellLog.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -72,6 +73,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCalculatedCurve.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileDataLoader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogDataLoader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimImportedWellLog.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RimImportedWellLog.h"
|
||||
|
||||
#include "Well/RigImportedWellLogData.h"
|
||||
|
||||
#include "RimWellPath.h"
|
||||
|
||||
#include "RiaFieldHandleTools.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
#include "cafPdmObjectScriptingCapability.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimImportedWellLog, "ImportedWellLog" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimImportedWellLog::RimImportedWellLog()
|
||||
{
|
||||
CAF_PDM_InitScriptableObject( "Imported Well Log", ":/LasFile16x16.png", "", "ImportedWellLog" );
|
||||
|
||||
CAF_PDM_InitScriptableField( &m_name, "Name", QString(), "Name" );
|
||||
m_name.uiCapability()->setUiReadOnly( true );
|
||||
|
||||
setDeletable( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimImportedWellLog::setName( const QString& name )
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimImportedWellLog::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimImportedWellLog::wellName() const
|
||||
{
|
||||
RimWellPath* wellPath = firstAncestorOrThisOfType<RimWellPath>();
|
||||
if ( wellPath )
|
||||
{
|
||||
return wellPath->name();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigWellLogData* RimImportedWellLog::wellLogData()
|
||||
{
|
||||
return m_wellLogData.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimImportedWellLog::setWellLogData( RigImportedWellLogData* wellLogData )
|
||||
{
|
||||
m_wellLogData = wellLogData;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::pair<double, double>>
|
||||
RimImportedWellLog::findMdAndChannelValuesForWellPath( const RimWellPath& wellPath, const QString& channelName, QString* unitString )
|
||||
{
|
||||
if ( unitString ) *unitString = QString();
|
||||
|
||||
if ( !m_wellLogData.notNull() ) return {};
|
||||
|
||||
std::vector<double> depths = m_wellLogData->depthValues();
|
||||
std::vector<double> values = m_wellLogData->values( channelName );
|
||||
|
||||
std::vector<std::pair<double, double>> depthValuePairs;
|
||||
if ( depths.size() == values.size() )
|
||||
{
|
||||
for ( size_t i = 0; i < depths.size(); ++i )
|
||||
{
|
||||
depthValuePairs.emplace_back( depths[i], values[i] );
|
||||
}
|
||||
}
|
||||
|
||||
return depthValuePairs;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimImportedWellLog::userDescriptionField()
|
||||
{
|
||||
return &m_name;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RimWellLog.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class RigImportedWellLogData;
|
||||
class RimWellPath;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimImportedWellLog : public RimWellLog
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimImportedWellLog();
|
||||
|
||||
void setName( const QString& name );
|
||||
QString name() const override;
|
||||
|
||||
QString wellName() const override;
|
||||
|
||||
RigWellLogData* wellLogData() override;
|
||||
void setWellLogData( RigImportedWellLogData* wellLogData );
|
||||
|
||||
std::vector<std::pair<double, double>>
|
||||
findMdAndChannelValuesForWellPath( const RimWellPath& wellPath, const QString& channelName, QString* unitString = nullptr ) override;
|
||||
|
||||
private:
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
private:
|
||||
cvf::ref<RigImportedWellLogData> m_wellLogData;
|
||||
caf::PdmField<QString> m_name;
|
||||
};
|
||||
Reference in new issue
Block a user