#12569 Python: Add API for creating well paths from XYZ coordinates

Add import_fixed_trajectory_well_path() method to WellPathCollection that enables
creation of well paths from coordinate lists in Python. Implements feature request
for programmatic well path creation without file-based imports.

- Add RimFixedTrajectoryWellPath class for coordinate-based well paths
- Add GRPC interface for coordinate data transfer via key-value store
- Add comprehensive Python API with input validation and error handling
- Add example script importing well on Norne.
- Add 7 unit tests covering all functionality and edge cases

The API allows creating well paths like:
well_path = collection.import_fixed_trajectory_well_path(
    name="MyWell",
    coordinates=[[x1,y1,z1], [x2,y2,z2], ...]
)
This commit is contained in:
Kristian Bendiksen committed 2025-08-25 13:27:31 +02:00
1 parent 66756ff21e
commit 83ae9fb7ac
10 files changed
+601

No files matched your search

@@ -0,0 +1,113 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimFixedTrajectoryWellPath.h"
#include "Well/RigWellPath.h"
// Make sure to include cafPdmFieldScriptingCapabilityCvfVec3d. Include of general cafPdmFieldScriptingCapability causes unity build issues.
#include "cafPdmFieldScriptingCapabilityCvfVec3d.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiOrdering.h"
CAF_PDM_SOURCE_INIT( RimFixedTrajectoryWellPath, "FixedTrajectoryWellPath" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFixedTrajectoryWellPath::RimFixedTrajectoryWellPath()
{
CAF_PDM_InitScriptableObject( "Fixed Trajectory Well Path", ":/Well.svg", "", "FixedTrajectoryWellPath" );
CAF_PDM_InitScriptableField( &m_trajectoryPoints, "TrajectoryPoints", std::vector<cvf::Vec3d>(), "Trajectory Points" );
m_trajectoryPoints.uiCapability()->setUiHidden( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFixedTrajectoryWellPath::~RimFixedTrajectoryWellPath()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFixedTrajectoryWellPath::setTrajectoryPoints( const std::vector<cvf::Vec3d>& wellTargets )
{
m_trajectoryPoints = wellTargets;
createWellPathGeometry();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RimFixedTrajectoryWellPath::trajectoryPoints() const
{
return m_trajectoryPoints();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFixedTrajectoryWellPath::createWellPathGeometry()
{
if ( m_trajectoryPoints().empty() )
{
return;
}
// Create well path geometry from the target points
std::vector<cvf::Vec3d> wellPathPoints = m_trajectoryPoints();
std::vector<double> measuredDepths;
// Calculate measured depths along the path
double totalMD = 0.0;
measuredDepths.push_back( totalMD );
for ( size_t i = 1; i < wellPathPoints.size(); ++i )
{
cvf::Vec3d segmentVector = wellPathPoints[i] - wellPathPoints[i - 1];
double segmentLength = segmentVector.length();
totalMD += segmentLength;
measuredDepths.push_back( totalMD );
}
auto wellPathGeometry = new RigWellPath( wellPathPoints, measuredDepths );
setWellPathGeometry( wellPathGeometry );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFixedTrajectoryWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimWellPath::defineUiOrdering( uiConfigName, uiOrdering );
// Hide the well targets field from UI since this is Python-only
uiOrdering.skipRemainingFields( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFixedTrajectoryWellPath::initAfterRead()
{
createWellPathGeometry();
}