Add action for downloading and parsing well log from OSDU Wellbore DDMS.

This commit is contained in:
Kristian Bendiksen
2024-05-27 11:24:00 +02:00
parent 5be47b3d2c
commit 23d716754e
20 changed files with 1094 additions and 46 deletions

View File

@@ -102,6 +102,7 @@
#include "RimMultiPlot.h"
#include "RimMultiPlotCollection.h"
#include "RimObservedSummaryData.h"
#include "RimOsduWellPath.h"
#include "RimParameterResultCrossPlot.h"
#include "RimPerforationCollection.h"
#include "RimPerforationInterval.h"
@@ -409,7 +410,9 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
appendCreateCompletions( menuBuilder );
menuBuilder.addSeparator();
appendImportMenu( menuBuilder );
bool addSeparatorBeforeMenu = false;
bool addOsduImportMenuItem = dynamic_cast<RimOsduWellPath*>( firstUiItem ) != nullptr;
appendImportMenu( menuBuilder, addSeparatorBeforeMenu, addOsduImportMenuItem );
menuBuilder.addSeparator();
appendExportCompletions( menuBuilder );
menuBuilder.addSeparator();
@@ -1498,7 +1501,7 @@ void RimContextCommandBuilder::appendScriptItems( caf::CmdFeatureMenuBuilder& me
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimContextCommandBuilder::appendImportMenu( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu )
int RimContextCommandBuilder::appendImportMenu( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu, bool addOsduImportMenuItem )
{
QStringList candidates;
candidates << "RicWellPathsImportFileFeature";
@@ -1507,6 +1510,8 @@ int RimContextCommandBuilder::appendImportMenu( caf::CmdFeatureMenuBuilder& menu
candidates << "RicImportWellLogCsvFileFeature";
candidates << "RicReloadWellPathFormationNamesFeature";
if ( addOsduImportMenuItem ) candidates << "RicImportWellLogOsduFeature";
return appendSubMenuWithCommands( menuBuilder, candidates, "Import", QIcon(), addSeparatorBeforeMenu );
}

View File

@@ -51,7 +51,7 @@ private:
static void appendScriptItems( caf::CmdFeatureMenuBuilder& menuBuilder, RimScriptCollection* scriptCollection );
static void appendPlotTemplateItems( caf::CmdFeatureMenuBuilder& menuBuilder, RimPlotTemplateFolderItem* plotTemplateRoot );
static int appendImportMenu( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu = false );
static int appendImportMenu( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu = false, bool addOsduMenuItem = false );
static int appendCreateCompletions( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu = false );
static int appendExportCompletions( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu = false );
static int appendExportWellPaths( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu = false );

View File

@@ -41,6 +41,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimWellLogExtractionCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogLasFile.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCsvFile.cpp
${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLog.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLog.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogFile.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileUtil.cpp

View File

@@ -0,0 +1,176 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimOsduWellLog.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RiaDateStringParser.h"
#include "RiaFieldHandleTools.h"
#include "RiaQDateTimeTools.h"
#include "RimFileWellPath.h"
#include "RimTools.h"
#include "RimWellLogChannel.h"
#include "RimWellPathCollection.h"
#include "RimWellPlotTools.h"
#include "Riu3DMainWindowTools.h"
#include <QFileInfo>
#include <QString>
#include <QStringList>
CAF_PDM_SOURCE_INIT( RimOsduWellLog, "OsduWellLog" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimOsduWellLog::RimOsduWellLog()
{
CAF_PDM_InitObject( "OSDU Well Log", ":/LasFile16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_name, "Name", "" );
m_name.uiCapability()->setUiReadOnly( true );
RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_name );
m_date.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitFieldNoDefault( &m_wellLogId, "WellLogId", "Well Log Id" );
m_wellLogId.uiCapability()->setUiReadOnly( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimOsduWellLog::~RimOsduWellLog()
{
m_wellLogChannelNames.deleteChildren();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimOsduWellLog::wellName() const
{
return m_wellName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimOsduWellLog::hasFlowData() const
{
return RimWellPlotTools::hasFlowData( this );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::pair<double, double>>
RimOsduWellLog::findMdAndChannelValuesForWellPath( const RimWellPath& wellPath, const QString& channelName, QString* unitString )
{
std::vector<RimOsduWellLog*> wellLogFiles = wellPath.descendantsIncludingThisOfType<RimOsduWellLog>();
for ( RimOsduWellLog* wellLogFile : wellLogFiles )
{
RigOsduWellLogData* fileData = wellLogFile->wellLogData();
std::vector<double> channelValues = fileData->values( channelName );
if ( !channelValues.empty() )
{
if ( unitString )
{
*unitString = fileData->wellLogChannelUnitString( channelName );
}
std::vector<double> depthValues = fileData->depthValues();
CVF_ASSERT( depthValues.size() == channelValues.size() );
std::vector<std::pair<double, double>> depthValuePairs;
for ( size_t i = 0; i < depthValues.size(); ++i )
{
depthValuePairs.push_back( std::make_pair( depthValues[i], channelValues[i] ) );
}
return depthValuePairs;
}
}
return std::vector<std::pair<double, double>>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimOsduWellLog::isDateValid( const QDateTime dateTime )
{
return dateTime.isValid() && dateTime != DEFAULT_DATE_TIME;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimOsduWellLog::userDescriptionField()
{
return &m_name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimOsduWellLog::name() const
{
return m_name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigOsduWellLogData* RimOsduWellLog::wellLogData()
{
return m_wellLogData.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimOsduWellLog::setWellLogData( RigOsduWellLogData* wellLogData )
{
m_wellLogData = wellLogData;
m_wellLogChannelNames.deleteChildren();
for ( const QString& wellLogName : wellLogData->wellLogChannelNames() )
{
RimWellLogChannel* wellLog = new RimWellLogChannel();
wellLog->setName( wellLogName );
m_wellLogChannelNames.push_back( wellLog );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimOsduWellLog::setWellLogId( const QString& wellLogId )
{
m_wellLogId = wellLogId;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimOsduWellLog::wellLogId() const
{
return m_wellLogId;
}

View File

@@ -0,0 +1,74 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimWellLog.h"
#include "RigOsduWellLogData.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
#include <QDateTime>
class RimWellLogChannel;
class RimWellPath;
class QString;
//==================================================================================================
///
///
//==================================================================================================
class RimOsduWellLog : public RimWellLog
{
CAF_PDM_HEADER_INIT;
public:
RimOsduWellLog();
~RimOsduWellLog() override;
QString name() const override;
QString wellName() const override;
RigOsduWellLogData* wellLogData() override;
void setWellLogData( RigOsduWellLogData* wellLogData );
void setWellLogId( const QString& wellLogId );
QString wellLogId() const;
bool hasFlowData() const;
std::vector<std::pair<double, double>>
findMdAndChannelValuesForWellPath( const RimWellPath& wellPath, const QString& channelName, QString* unitString = nullptr ) override;
private:
caf::PdmFieldHandle* userDescriptionField() override;
static bool isDateValid( const QDateTime dateTime );
private:
cvf::ref<RigOsduWellLogData> m_wellLogData;
caf::PdmField<QString> m_wellName;
caf::PdmField<QString> m_name;
caf::PdmField<QString> m_wellLogId;
};

View File

@@ -28,12 +28,14 @@
#include "RiaTextStringTools.h"
#include "RiaWellNameComparer.h"
#include "RifOsduWellLogReader.h"
#include "RifOsduWellPathReader.h"
#include "RifWellPathFormationsImporter.h"
#include "RifWellPathImporter.h"
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RigOsduWellLogData.h"
#include "RigWellPath.h"
#include "RimEclipseCase.h"
@@ -42,6 +44,7 @@
#include "RimFileWellPath.h"
#include "RimModeledWellPath.h"
#include "RimOilField.h"
#include "RimOsduWellLog.h"
#include "RimOsduWellPath.h"
#include "RimPerforationCollection.h"
#include "RimProject.h"
@@ -147,6 +150,17 @@ void RimWellPathCollection::loadDataAndUpdate()
{
caf::ProgressInfo progress( m_wellPaths.size(), "Reading well paths from file" );
auto makeOsduConnector = []( auto app )
{
RiaPreferencesOsdu* osduPreferences = app->preferences()->osduPreferences();
const QString server = osduPreferences->server();
const QString dataPartitionId = osduPreferences->dataPartitionId();
const QString authority = osduPreferences->authority();
const QString scopes = osduPreferences->scopes();
const QString clientId = osduPreferences->clientId();
return std::make_unique<RiaOsduConnector>( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId );
};
readWellPathFormationFiles();
for ( RimWellPath* wellPath : allWellPaths() )
@@ -173,18 +187,8 @@ void RimWellPathCollection::loadDataAndUpdate()
}
else if ( oWPath )
{
RiaApplication* app = RiaApplication::instance();
RiaPreferencesOsdu* osduPreferences = app->preferences()->osduPreferences();
const QString server = osduPreferences->server();
const QString dataParitionId = osduPreferences->dataPartitionId();
const QString authority = osduPreferences->authority();
const QString scopes = osduPreferences->scopes();
const QString clientId = osduPreferences->clientId();
auto osduConnector =
std::make_unique<RiaOsduConnector>( RiuMainWindow::instance(), server, dataParitionId, authority, scopes, clientId );
RiaApplication* app = RiaApplication::instance();
auto osduConnector = makeOsduConnector( app );
auto [wellPathGeometry, errorMessage] = loadWellPathGeometryFromOsdu( osduConnector.get(), oWPath->fileId() );
if ( wellPathGeometry.notNull() )
@@ -199,9 +203,9 @@ void RimWellPathCollection::loadDataAndUpdate()
if ( wellPath )
{
for ( RimWellLogFile* const wellLogFile : wellPath->wellLogFiles() )
for ( RimWellLog* wellLog : wellPath->wellLogs() )
{
if ( wellLogFile )
if ( RimWellLogFile* wellLogFile = dynamic_cast<RimWellLogFile*>( wellLog ) )
{
QString errorMessage;
if ( !wellLogFile->readFile( &errorMessage ) )
@@ -209,6 +213,16 @@ void RimWellPathCollection::loadDataAndUpdate()
RiaLogging::warning( errorMessage );
}
}
else if ( RimOsduWellLog* osduWellLog = dynamic_cast<RimOsduWellLog*>( wellLog ) )
{
RiaApplication* app = RiaApplication::instance();
auto osduConnector = makeOsduConnector( app );
auto [wellLogData, errorMessage] = loadWellLogFromOsdu( osduConnector.get(), osduWellLog->wellLogId() );
if ( wellLogData.notNull() )
{
osduWellLog->setWellLogData( wellLogData.p() );
}
}
}
RimStimPlanModelCollection* stimPlanModelCollection = wellPath->stimPlanModelCollection();
@@ -419,9 +433,9 @@ std::vector<RimWellLogLasFile*> RimWellPathCollection::addWellLogs( const QStrin
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::addWellLog( RimWellLogFile* wellLogFile, RimWellPath* wellPath )
void RimWellPathCollection::addWellLog( RimWellLog* wellLog, RimWellPath* wellPath )
{
wellPath->addWellLog( wellLogFile );
wellPath->addWellLog( wellLog );
sortWellsByName();
updateAllRequiredEditors();
}
@@ -1060,3 +1074,18 @@ std::pair<cvf::ref<RigWellPath>, QString> RimWellPathCollection::loadWellPathGeo
return RifOsduWellPathReader::parseCsv( fileContents );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<cvf::ref<RigOsduWellLogData>, QString> RimWellPathCollection::loadWellLogFromOsdu( RiaOsduConnector* osduConnector,
const QString& wellLogId )
{
auto [fileContents, errorMessage] = osduConnector->requestWellLogParquetDataById( wellLogId );
if ( !errorMessage.isEmpty() )
{
return { nullptr, errorMessage };
}
return RifOsduWellLogReader::readWellLogData( fileContents );
}

View File

@@ -22,6 +22,7 @@
#include "RiaDefines.h"
#include "RigOsduWellLogData.h"
#include "cafAppEnum.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
@@ -41,6 +42,7 @@
class RiaOsduConnector;
class RifWellPathImporter;
class RigWellPath;
class RigOsduWellLogData;
class RimFileWellPath;
class RimEclipseView;
class RimProject;
@@ -49,6 +51,7 @@ class RimWellLogFile;
class RimWellPath;
class RifWellPathFormationsImporter;
class RimWellMeasurementCollection;
class RimWellLog;
class cafTreeNode;
class QString;
@@ -118,7 +121,7 @@ public:
std::vector<RimWellLogLasFile*> addWellLogs( const QStringList& filePaths, QStringList* errorMessages );
void addWellPathFormations( const QStringList& filePaths );
void addWellLog( RimWellLogFile* wellLogFile, RimWellPath* wellPath );
void addWellLog( RimWellLog* wellLog, RimWellPath* wellPath );
void scheduleRedrawAffectedViews();
@@ -134,6 +137,8 @@ public:
static std::pair<cvf::ref<RigWellPath>, QString> loadWellPathGeometryFromOsdu( RiaOsduConnector* osduConnector, const QString& fileId );
static std::pair<cvf::ref<RigOsduWellLogData>, QString> loadWellLogFromOsdu( RiaOsduConnector* osduConnector, const QString& wellLogId );
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;