Osdu Well Log: make it possible to add Osdu well logs to plot.

This commit is contained in:
Kristian Bendiksen
2024-06-03 19:42:08 +02:00
parent 23d716754e
commit 10ad053c30
14 changed files with 104 additions and 78 deletions

View File

@@ -72,24 +72,30 @@ void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked )
if ( !oilField->wellPathCollection ) oilField->wellPathCollection = std::make_unique<RimWellPathCollection>();
RimOsduWellLog* osduWellLog = new RimOsduWellLog;
// TODO: get from OSDU...
osduWellLog->setWellLogId( "npequinor-dev:work-product-component--WellLog:aeb5bd8b1de14138afe9f23cacbc7fe7" );
oilField->wellPathCollection->addWellLog( osduWellLog, wellPath );
std::vector<QString> wellLogIds = { "npequinor-dev:work-product-component--WellLog:aeb5bd8b1de14138afe9f23cacbc7fe7" };
auto osduConnector = makeOsduConnector( app );
auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector.get(), osduWellLog->wellLogId() );
if ( wellLogData.notNull() )
for ( QString wellLogId : wellLogIds )
{
osduWellLog->setWellLogData( wellLogData.p() );
}
else
{
RiaLogging::error( "Importing OSDU well log failed: " + errorMessage );
}
RimOsduWellLog* osduWellLog = new RimOsduWellLog;
osduWellLog->setName( wellLogId );
osduWellLog->setWellLogId( wellLogId );
oilField->wellPathCollection->addWellLog( osduWellLog, wellPath );
osduWellLog->updateConnectedEditors();
auto osduConnector = makeOsduConnector( app );
auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector.get(), osduWellLog->wellLogId() );
if ( wellLogData.notNull() )
{
osduWellLog->setWellLogData( wellLogData.p() );
}
else
{
RiaLogging::error( "Importing OSDU well log failed: " + errorMessage );
}
osduWellLog->updateConnectedEditors();
}
}
}

View File

@@ -147,7 +147,7 @@ void RicWellLogTools::addWellLogChannelsToPlotTrack( RimWellLogTrack* plotTrack,
if ( wellPath )
{
if ( wellLogFile ) plotCurve->setWellLogFile( wellLogFile );
if ( wellLogFile ) plotCurve->setWellLog( wellLogFile );
plotCurve->setWellPath( wellPath );
plotCurve->setWellLogChannelName( wellLogChannel->name() );

View File

@@ -69,13 +69,12 @@ void RicAddWellLogToPlotFeature::onActionTriggered( bool isChecked )
plot->loadDataAndUpdate();
for ( size_t wlIdx = 0; wlIdx < selection.size(); wlIdx++ )
bool isFirst = true;
for ( RimWellLogChannel* wellLogChannel : selection )
{
RimWellLogChannel* wellLog = selection[wlIdx];
auto wellPath = wellLog->firstAncestorOrThisOfType<RimWellPath>();
auto wellLogFile = wellLog->firstAncestorOrThisOfType<RimWellLogLasFile>();
if ( wellLogFile )
auto wellPath = wellLogChannel->firstAncestorOrThisOfType<RimWellPath>();
auto wellLog = wellLogChannel->firstAncestorOrThisOfType<RimWellLog>();
if ( wellLog )
{
RimWellLogLasFileCurve* curve = new RimWellLogLasFileCurve;
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plotTrack->curveCount() );
@@ -83,18 +82,19 @@ void RicAddWellLogToPlotFeature::onActionTriggered( bool isChecked )
plotTrack->addCurve( curve );
RigWellLogLasFile* wellLogDataFile = wellLogFile->wellLogData();
CVF_ASSERT( wellLogDataFile );
RigWellLogData* wellLogData = wellLog->wellLogData();
CVF_ASSERT( wellLogData );
if ( wlIdx == 0 )
if ( isFirst )
{
// Initialize plot with depth unit from the first log file
plot->setDepthUnit( wellLogDataFile->depthUnit() );
plot->setDepthUnit( wellLogData->depthUnit() );
isFirst = false;
}
curve->setWellPath( wellPath );
curve->setWellLogChannelName( wellLog->name() );
curve->setWellLogFile( wellLogFile );
curve->setWellLogChannelName( wellLogChannel->name() );
curve->setWellLog( wellLog );
curve->loadDataAndUpdate( true );
}

View File

@@ -72,7 +72,7 @@ void RicNewWellLogFileCurveFeature::onActionTriggered( bool isChecked )
if ( wellPath->wellLogFiles().size() == 1 )
{
plotCurve->setWellLogFile( wellPath->wellLogFiles().front() );
plotCurve->setWellLog( wellPath->wellLogFiles().front() );
}
plotCurve->updateConnectedEditors();
}

View File

@@ -676,17 +676,16 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve( const RimWellLogCu
}
else if ( wellLogFileCurve != nullptr )
{
RimWellLogFile* const wellLogFile = wellLogFileCurve->wellLogFile();
RimWellLog* const wellLog = wellLogFileCurve->wellLog();
if ( wellLogFile != nullptr )
if ( wellLog != nullptr )
{
const QDateTime date = wellLogFile->date();
const QDateTime date = wellLog->date();
if ( date.isValid() )
{
if ( auto wellLogLasFile = dynamic_cast<RimWellLogLasFile*>( wellLogFile ) )
if ( auto wellLogLasFile = dynamic_cast<RimWellLogLasFile*>( wellLog ) )
{
return RiaRftPltCurveDefinition( RifDataSourceForRftPlt( wellLogLasFile ), wellLogFile->wellName(), date );
return RiaRftPltCurveDefinition( RifDataSourceForRftPlt( wellLogLasFile ), wellLog->wellName(), date );
}
}
}

View File

@@ -692,7 +692,7 @@ void RimWellRftPlot::updateCurvesInPlot( const std::set<RiaRftPltCurveDefinition
plotTrack->addCurve( curve );
curve->setWellPath( wellPath );
curve->setWellLogFile( wellLogFile );
curve->setWellLog( wellLogFile );
curve->setWellLogChannelName( pressureChannel->name() );
curve->setZOrder( 2 );

View File

@@ -645,7 +645,8 @@ RimSummaryCase* RimEnsembleWellLogCurveSet::findMatchingSummaryCase( RimWellLogL
std::vector<RimSummaryCase*> sumCases = summaryCaseCollection->allSummaryCases();
for ( auto sumCase : sumCases )
{
if ( isSameRealization( sumCase, wellLogCurve->wellLogFile() ) )
RimWellLogFile* wellLogFile = dynamic_cast<RimWellLogFile*>( wellLogCurve->wellLog() );
if ( wellLogFile && isSameRealization( sumCase, wellLogFile ) )
{
return sumCase;
}
@@ -794,7 +795,7 @@ void RimEnsembleWellLogCurveSet::updateEnsembleCurves( const std::vector<RimWell
curve->setWellPath( wellPath );
curve->setWellLogChannelName( wellLogChannelName );
curve->setWellLogFile( wellLogFile );
curve->setWellLog( wellLogFile );
curve->setSymbol( m_curveAppearance->symbol() );
curve->setSymbolSize( m_curveAppearance->symbolSize() );

View File

@@ -48,7 +48,6 @@ RimOsduWellLog::RimOsduWellLog()
CAF_PDM_InitFieldNoDefault( &m_name, "Name", "" );
m_name.uiCapability()->setUiReadOnly( true );
RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_name );
m_date.uiCapability()->setUiReadOnly( true );
@@ -126,6 +125,14 @@ caf::PdmFieldHandle* RimOsduWellLog::userDescriptionField()
return &m_name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimOsduWellLog::setName( const QString& name )
{
m_name = name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -46,6 +46,7 @@ public:
RimOsduWellLog();
~RimOsduWellLog() override;
void setName( const QString& name );
QString name() const override;
QString wellName() const override;

View File

@@ -34,6 +34,7 @@
#include "RimTools.h"
#include "RimWellFlowRateCurve.h"
#include "RimWellLogExtractionCurve.h"
#include "RimWellLogFile.h"
#include "RimWellLogLasFileCurve.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotCollection.h"
@@ -528,7 +529,7 @@ void RimWellLogCurveCommonDataSource::applyDataSourceChanges( const std::vector<
if ( !fileCurve->wellLogChannelUiName().isEmpty() )
{
RimWellLogFile* logFile = wellPathToApply()->firstWellLogFileMatchingChannelName( fileCurve->wellLogChannelUiName() );
fileCurve->setWellLogFile( logFile );
fileCurve->setWellLog( logFile );
auto parentPlot = fileCurve->firstAncestorOrThisOfTypeAsserted<RimWellLogPlot>();
plots.insert( parentPlot );
}

View File

@@ -60,7 +60,7 @@ RimWellLogLasFileCurve::RimWellLogLasFileCurve()
CAF_PDM_InitFieldNoDefault( &m_wellLogChannelName, "CurveWellLogChannel", "Well Log Channel" );
CAF_PDM_InitFieldNoDefault( &m_wellLogFile, "WellLogFile", "Well Log File" );
CAF_PDM_InitFieldNoDefault( &m_wellLog, "WellLogFile", "Well Log File" );
m_wellPath = nullptr;
}
@@ -83,9 +83,9 @@ void RimWellLogLasFileCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
auto wellLogPlot = firstAncestorOrThisOfTypeAsserted<RimWellLogPlot>();
if ( m_wellPath && m_wellLogFile )
if ( m_wellPath && m_wellLog )
{
RigWellLogData* wellLogFile = m_wellLogFile->wellLogData();
RigWellLogData* wellLogFile = m_wellLog->wellLogData();
if ( wellLogFile )
{
std::vector<double> values = wellLogFile->values( m_wellLogChannelName );
@@ -287,9 +287,9 @@ void RimWellLogLasFileCurve::setWellLogChannelName( const QString& name )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogLasFileCurve::setWellLogFile( RimWellLogFile* wellLogFile )
void RimWellLogLasFileCurve::setWellLog( RimWellLog* wellLogFile )
{
m_wellLogFile = wellLogFile;
m_wellLog = wellLogFile;
}
//--------------------------------------------------------------------------------------------------
@@ -315,7 +315,7 @@ void RimWellLogLasFileCurve::fieldChangedByUi( const caf::PdmFieldHandle* change
{
loadDataAndUpdate( true );
}
else if ( changedField == &m_wellLogFile )
else if ( changedField == &m_wellLog )
{
loadDataAndUpdate( true );
}
@@ -331,7 +331,7 @@ void RimWellLogLasFileCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiO
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Curve Data" );
curveDataGroup->add( &m_wellPath );
curveDataGroup->add( &m_wellLogFile );
curveDataGroup->add( &m_wellLog );
curveDataGroup->add( &m_wellLogChannelName );
RimStackablePlotCurve::defaultUiOrdering( uiOrdering );
@@ -362,8 +362,8 @@ QList<caf::PdmOptionItemInfo> RimWellLogLasFileCurve::calculateValueOptions( con
{
for ( auto wellPath : wellPathColl->allWellPaths() )
{
// Only include well paths coming from a well log file
if ( !wellPath->wellLogFiles().empty() )
// Only include well paths coming with a well log
if ( !wellPath->wellLogs().empty() )
{
options.push_back( caf::PdmOptionItemInfo( wellPath->name(), wellPath ) );
}
@@ -378,17 +378,12 @@ QList<caf::PdmOptionItemInfo> RimWellLogLasFileCurve::calculateValueOptions( con
if ( fieldNeedingOptions == &m_wellLogChannelName )
{
if ( m_wellPath() )
if ( m_wellPath() && m_wellLog() )
{
if ( m_wellLogFile )
for ( RimWellLogChannel* wellLogChannel : m_wellLog->wellLogChannels() )
{
std::vector<RimWellLogChannel*> fileLogs = m_wellLogFile->wellLogChannels();
for ( size_t i = 0; i < fileLogs.size(); i++ )
{
QString wellLogChannelName = fileLogs[i]->name();
options.push_back( caf::PdmOptionItemInfo( wellLogChannelName, wellLogChannelName ) );
}
QString wellLogChannelName = wellLogChannel->name();
options.push_back( caf::PdmOptionItemInfo( wellLogChannelName, wellLogChannelName ) );
}
}
@@ -398,14 +393,21 @@ QList<caf::PdmOptionItemInfo> RimWellLogLasFileCurve::calculateValueOptions( con
}
}
if ( fieldNeedingOptions == &m_wellLogFile )
if ( fieldNeedingOptions == &m_wellLog )
{
if ( m_wellPath() && !m_wellPath->wellLogFiles().empty() )
if ( m_wellPath() && !m_wellPath->wellLogs().empty() )
{
for ( RimWellLogFile* const wellLogFile : m_wellPath->wellLogFiles() )
for ( RimWellLog* const wellLog : m_wellPath->wellLogs() )
{
QFileInfo fileInfo( wellLogFile->fileName() );
options.push_back( caf::PdmOptionItemInfo( fileInfo.baseName(), wellLogFile ) );
if ( RimWellLogFile* wellLogFile = dynamic_cast<RimWellLogFile*>( wellLog ) )
{
QFileInfo fileInfo( wellLogFile->fileName() );
options.push_back( caf::PdmOptionItemInfo( fileInfo.baseName(), wellLog ) );
}
else
{
options.push_back( caf::PdmOptionItemInfo( wellLog->name(), wellLog ) );
}
}
}
}
@@ -424,7 +426,7 @@ void RimWellLogLasFileCurve::initAfterRead()
if ( m_wellPath->wellLogFiles().size() == 1 )
{
m_wellLogFile = dynamic_cast<RimWellLogLasFile*>( m_wellPath->wellLogFiles().front() );
m_wellLog = dynamic_cast<RimWellLogLasFile*>( m_wellPath->wellLogFiles().front() );
}
}
@@ -457,14 +459,14 @@ QString RimWellLogLasFileCurve::createCurveAutoName()
channelNameAvailable = true;
}
RigWellLogData* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogData() : nullptr;
RigWellLogData* wellLogData = m_wellLog ? m_wellLog->wellLogData() : nullptr;
if ( wellLogFile )
if ( wellLogData )
{
if ( channelNameAvailable )
{
auto wellLogPlot = firstAncestorOrThisOfTypeAsserted<RimWellLogPlot>();
QString unitName = wellLogFile->convertedWellLogChannelUnitString( m_wellLogChannelName, wellLogPlot->depthUnit() );
QString unitName = wellLogData->convertedWellLogChannelUnitString( m_wellLogChannelName, wellLogPlot->depthUnit() );
if ( !unitName.isEmpty() )
{
@@ -472,7 +474,7 @@ QString RimWellLogLasFileCurve::createCurveAutoName()
}
}
QString date = m_wellLogFile->date().toString( RiaQDateTimeTools::dateFormatString() );
QString date = m_wellLog->date().toString( RiaQDateTimeTools::dateFormatString() );
if ( !date.isEmpty() )
{
name.push_back( date );
@@ -498,9 +500,9 @@ QString RimWellLogLasFileCurve::wellLogChannelUiName() const
//--------------------------------------------------------------------------------------------------
QString RimWellLogLasFileCurve::wellLogChannelUnits() const
{
if ( m_wellLogFile && m_wellLogFile->wellLogData() )
if ( m_wellLog && m_wellLog->wellLogData() )
{
return m_wellLogFile->wellLogData()->wellLogChannelUnitString( m_wellLogChannelName );
return m_wellLog->wellLogData()->wellLogChannelUnitString( m_wellLogChannelName );
}
return RiaWellLogUnitTools<double>::noUnitString();
}
@@ -508,9 +510,9 @@ QString RimWellLogLasFileCurve::wellLogChannelUnits() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogFile* RimWellLogLasFileCurve::wellLogFile() const
RimWellLog* RimWellLogLasFileCurve::wellLog() const
{
return m_wellLogFile();
return m_wellLog();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -30,6 +30,7 @@ class RimWellPath;
class RimWellLogChannel;
class RimWellLogFile;
class RigWellLogIndexDepthOffset;
class RimWellLog;
//==================================================================================================
///
@@ -46,7 +47,7 @@ public:
void setWellPath( RimWellPath* wellPath );
RimWellPath* wellPath() const;
void setWellLogChannelName( const QString& name );
void setWellLogFile( RimWellLogFile* wellLogFile );
void setWellLog( RimWellLog* wellLog );
void setIndexDepthOffsets( std::shared_ptr<RigWellLogIndexDepthOffset> depthOffsets );
// Overrides from RimWellLogPlotCurve
@@ -54,7 +55,7 @@ public:
QString wellLogChannelUiName() const override;
QString wellLogChannelUnits() const override;
RimWellLogFile* wellLogFile() const;
RimWellLog* wellLog() const;
protected:
// Overrides from RimWellLogPlotCurve
@@ -75,10 +76,10 @@ protected:
const std::vector<double>& kIndexValues ) const;
protected:
caf::PdmPtrField<RimWellPath*> m_wellPath;
caf::PdmPtrField<RimWellLogFile*> m_wellLogFile;
caf::PdmField<QString> m_wellLogChannelName;
caf::PdmField<QString> m_wellLogChannnelUnit;
caf::PdmPtrField<RimWellPath*> m_wellPath;
caf::PdmPtrField<RimWellLog*> m_wellLog;
caf::PdmField<QString> m_wellLogChannelName;
caf::PdmField<QString> m_wellLogChannnelUnit;
std::shared_ptr<RigWellLogIndexDepthOffset> m_indexDepthOffsets;
};

View File

@@ -22,6 +22,12 @@ RimOsduWellPath::RimOsduWellPath()
CAF_PDM_InitFieldNoDefault( &m_fileId, "FileId", "File Id" );
m_fileId.uiCapability()->setUiReadOnly( true );
// Required, as these settings are set in RimWellPath()
m_name.uiCapability()->setUiReadOnly( false );
m_name.uiCapability()->setUiHidden( false );
m_name.xmlCapability()->setIOReadable( true );
m_name.xmlCapability()->setIOWritable( true );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -25,6 +25,7 @@
#include "RiaSimWellBranchTools.h"
#include "RiaWellNameComparer.h"
#include "RicImportWellLogOsduFeature.h"
#include "RicfCommandObject.h"
#include "RifWellPathFormationsImporter.h"
@@ -38,6 +39,7 @@
#include "RimFishbonesCollection.h"
#include "RimMainPlotCollection.h"
#include "RimMswCompletionParameters.h"
#include "RimOsduWellLog.h"
#include "RimPerforationCollection.h"
#include "RimProject.h"
#include "RimStimPlanModelCollection.h"
@@ -934,7 +936,7 @@ void RimWellPath::addWellLog( RimWellLog* wellLog )
}
}
}
else
else if ( RimOsduWellLog* osduWellLog = dynamic_cast<RimOsduWellLog*>( wellLog ) )
{
m_wellLogs.push_back( osduWellLog );
}