#4817 #4830 #4832 #4837 #4839 Python commands for WBS creation, well path import and well log file import (#4838)

* Better minimum width for well log tracks

* Fix alignment of scrollbar in Well log plots

* Better Well Log Plot export

* Hide scroll bar before plotting
* Better borders

* Create plots through Python

* #4817 Create WBS plots with Python

* Rebase Summary and WellLogPlot on top of a new RimPlot

* Also Python: Allow setting folder as a parameter to export_snapshots

* #4832 Prepare for well path import command

* Well Path import WIP

* #4830 #4832 Import well paths and well log files from file using Python.

* #4837 Implement import of formation names in Python

* Fix debug build issue

* Fix RiaLogging build issue

* Fix warnings

* Yet another RiaLogging.h import added

* #4839 Import exporting of las and ascii files from well log plots
This commit is contained in:
Gaute Lindkvist
2019-10-09 09:21:28 +02:00
committed by GitHub
parent b24b0932a3
commit 11117383db
106 changed files with 2128 additions and 339 deletions

View File

@@ -110,6 +110,21 @@ void RicAsciiExportWellLogPlotFeature::setupActionLook( QAction* actionToSetup )
actionToSetup->setIcon( QIcon( ":/Save.png" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicAsciiExportWellLogPlotFeature::makeValidExportFileName( const RimWellLogPlot* wellLogPlot,
const QString& folder,
const QString& prefix,
bool capitalizeFileName )
{
QString fileName = folder + "/" + prefix + caf::Utils::makeValidFileBasename( wellLogPlot->description() ) + ".ascii";
if ( capitalizeFileName ) fileName = fileName.toUpper();
QDir dir( folder );
return dir.absoluteFilePath( fileName );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -20,6 +20,8 @@
#include "cafCmdFeature.h"
#include <QString>
class RimWellLogPlot;
//==================================================================================================
@@ -29,11 +31,15 @@ class RicAsciiExportWellLogPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static QString makeValidExportFileName( const RimWellLogPlot* wellLogPlot,
const QString& folder,
const QString& prefix,
bool capitalizeFileName );
static bool exportAsciiForWellLogPlot( const QString& fileName, const RimWellLogPlot* wellLogPlot );
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static bool exportAsciiForWellLogPlot( const QString& fileName, const RimWellLogPlot* wellLogPlot );
};

View File

@@ -68,6 +68,8 @@ void RicNewRftPlotFeature::onActionTriggered( bool isChecked )
QString wellName = selectedWellName();
RimWellRftPlot* rftPlot = new RimWellRftPlot();
RiaApplication::instance()->project()->assignViewIdToView( rftPlot );
rftPlot->setSimWellOrWellPathName( wellName );
RimWellLogTrack* plotTrack = new RimWellLogTrack();

View File

@@ -58,6 +58,63 @@
CAF_CMD_SOURCE_INIT( RicNewWellBoreStabilityPlotFeature, "RicNewWellBoreStabilityPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellBoreStabilityPlot*
RicNewWellBoreStabilityPlotFeature::createPlot( RimGeoMechCase* geoMechCase, RimWellPath* wellPath, int timeStep )
{
caf::ProgressInfo progInfo( 100, "Creating Well Bore Stability Plot" );
RimWellBoreStabilityPlot* plot = RicNewWellLogPlotFeatureImpl::createWellBoreStabilityPlot( false,
"Well Bore Stability" );
{
auto task = progInfo.task( "Creating formation track", 2 );
createFormationTrack( plot, wellPath, geoMechCase );
}
{
auto task = progInfo.task( "Creating well design track", 3 );
createCasingShoeTrack( plot, wellPath, geoMechCase );
}
{
auto task = progInfo.task( "Creating parameters track", 15 );
createParametersTrack( plot, wellPath, geoMechCase, timeStep );
}
{
auto task = progInfo.task( "Creating stability curves track", 60 );
createStabilityCurvesTrack( plot, wellPath, geoMechCase, timeStep );
}
{
auto task = progInfo.task( "Creating angles track", 15 );
createAnglesTrack( plot, wellPath, geoMechCase, timeStep );
}
{
auto task = progInfo.task( "Updating all tracks", 5 );
plot->enableAllAutoNameTags( true );
plot->setPlotTitleVisible( true );
plot->setTrackLegendsVisible( true );
plot->setTrackLegendsHorizontal( true );
plot->setDepthType( RimWellLogPlot::TRUE_VERTICAL_DEPTH );
plot->setDepthAutoZoom( true );
RicNewWellLogPlotFeatureImpl::updateAfterCreation( plot );
}
RiuPlotMainWindowTools::selectAsCurrentItem( plot );
// Make sure the summary plot window is visible
RiuPlotMainWindowTools::showPlotMainWindow();
return plot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -103,54 +160,14 @@ void RicNewWellBoreStabilityPlotFeature::onActionTriggered( bool isChecked )
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>( view );
if ( !geoMechView ) return;
caf::ProgressInfo progInfo( 100, "Creating Well Bore Stability Plot" );
RimGeoMechCase* geoMechCase = geoMechView->geoMechCase();
RimWellBoreStabilityPlot* plot = RicNewWellLogPlotFeatureImpl::createWellBoreStabilityPlot( false,
"Well Bore Stability" );
RimGeoMechCase* geoMechCase = geoMechView->geoMechCase();
if ( !geoMechCase )
{
auto task = progInfo.task( "Creating formation track", 2 );
createFormationTrack( plot, wellPath, geoMechCase );
return;
}
{
auto task = progInfo.task( "Creating well design track", 3 );
createCasingShoeTrack( plot, wellPath, geoMechCase );
}
{
auto task = progInfo.task( "Creating parameters track", 15 );
createParametersTrack( plot, wellPath, geoMechView );
}
{
auto task = progInfo.task( "Creating stability curves track", 60 );
createStabilityCurvesTrack( plot, wellPath, geoMechView );
}
{
auto task = progInfo.task( "Creating angles track", 15 );
createAnglesTrack( plot, wellPath, geoMechView );
}
{
auto task = progInfo.task( "Updating all tracks", 5 );
plot->enableAllAutoNameTags( true );
plot->setPlotTitleVisible( true );
plot->setTrackLegendsVisible( true );
plot->setTrackLegendsHorizontal( true );
plot->setDepthType( RimWellLogPlot::TRUE_VERTICAL_DEPTH );
plot->setDepthAutoZoom( true );
RicNewWellLogPlotFeatureImpl::updateAfterCreation( plot );
}
RiuPlotMainWindowTools::selectAsCurrentItem( plot );
// Make sure the summary plot window is visible
RiuPlotMainWindowTools::showPlotMainWindow();
createPlot( geoMechCase, wellPath, view->currentTimeStep() );
}
//--------------------------------------------------------------------------------------------------
@@ -203,7 +220,8 @@ void RicNewWellBoreStabilityPlotFeature::createCasingShoeTrack( RimWellBoreStabi
//--------------------------------------------------------------------------------------------------
void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabilityPlot* plot,
RimWellPath* wellPath,
RimGeoMechView* geoMechView )
RimGeoMechCase* geoMechCase,
int timeStep )
{
RimWellLogTrack* paramCurvesTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( false,
"WBS Parameters",
@@ -213,7 +231,7 @@ void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabi
paramCurvesTrack->setTickIntervals( 0.5, 0.05 );
paramCurvesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR );
paramCurvesTrack->setFormationWellPath( wellPath );
paramCurvesTrack->setFormationCase( geoMechView->geoMechCase() );
paramCurvesTrack->setFormationCase( geoMechCase );
paramCurvesTrack->setAnnotationType( RiuPlotAnnotationTool::CURVE_ANNOTATIONS );
paramCurvesTrack->setShowRegionLabels( true );
paramCurvesTrack->setVisible( false );
@@ -226,14 +244,15 @@ void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabi
const QString& resultName = resultNames[i];
RigFemResultAddress resAddr( RIG_WELLPATH_DERIVED, resultName.toStdString(), "" );
RimWellLogExtractionCurve* curve = RicWellLogTools::addWellLogExtractionCurve( paramCurvesTrack,
geoMechView,
geoMechCase,
nullptr,
wellPath,
nullptr,
-1,
false,
false );
curve->setGeoMechResultAddress( resAddr );
curve->setCurrentTimeStep( geoMechView->currentTimeStep() );
curve->setCurrentTimeStep( timeStep );
curve->setColor( colors[i % colors.size()] );
curve->setLineThickness( 2 );
curve->loadDataAndUpdate( false );
@@ -247,7 +266,8 @@ void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabi
//--------------------------------------------------------------------------------------------------
void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBoreStabilityPlot* plot,
RimWellPath* wellPath,
RimGeoMechView* geoMechView )
RimGeoMechCase* geoMechCase,
int timeStep )
{
RimWellLogTrack* stabilityCurvesTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( false,
"Stability Curves",
@@ -257,7 +277,7 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore
stabilityCurvesTrack->setTickIntervals( 0.5, 0.05 );
stabilityCurvesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR );
stabilityCurvesTrack->setFormationWellPath( wellPath );
stabilityCurvesTrack->setFormationCase( geoMechView->geoMechCase() );
stabilityCurvesTrack->setFormationCase( geoMechCase );
stabilityCurvesTrack->setAnnotationType( RiuPlotAnnotationTool::NO_ANNOTATIONS );
stabilityCurvesTrack->setShowRegionLabels( true );
@@ -274,14 +294,14 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore
const QString& resultName = resultNames[i];
RigFemResultAddress resAddr( RIG_WELLPATH_DERIVED, resultName.toStdString(), "" );
RimWellLogWbsCurve* curve = RicWellLogTools::addWellLogWbsCurve( stabilityCurvesTrack,
geoMechView,
wellPath,
geoMechCase,
nullptr,
wellPath,
-1,
false,
false );
curve->setGeoMechResultAddress( resAddr );
curve->setCurrentTimeStep( geoMechView->currentTimeStep() );
curve->setCurrentTimeStep( timeStep );
curve->setAutoNameComponents( false, true, false, false, false );
curve->setColor( colors[i % colors.size()] );
curve->setLineThickness( 2 );
@@ -297,7 +317,8 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore
//--------------------------------------------------------------------------------------------------
void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStabilityPlot* plot,
RimWellPath* wellPath,
RimGeoMechView* geoMechView )
RimGeoMechCase* geoMechCase,
int timeStep )
{
RimWellLogTrack* wellPathAnglesTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( false,
"Well Path Angles",
@@ -315,14 +336,15 @@ void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStability
const QString& resultName = resultNames[i];
RigFemResultAddress resAddr( RIG_WELLPATH_DERIVED, resultName.toStdString(), "" );
RimWellLogExtractionCurve* curve = RicWellLogTools::addWellLogExtractionCurve( wellPathAnglesTrack,
geoMechView,
geoMechCase,
nullptr,
wellPath,
nullptr,
-1,
false,
false );
curve->setGeoMechResultAddress( resAddr );
curve->setCurrentTimeStep( geoMechView->currentTimeStep() );
curve->setCurrentTimeStep( timeStep );
curve->setCustomName( resultName );
curve->setColor( colors[i % colors.size()] );
@@ -349,7 +371,7 @@ void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStability
wellPathAnglesTrack->setTickIntervals( 90.0, 30.0 );
wellPathAnglesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR );
wellPathAnglesTrack->setFormationWellPath( wellPath );
wellPathAnglesTrack->setFormationCase( geoMechView->geoMechCase() );
wellPathAnglesTrack->setFormationCase( geoMechCase );
wellPathAnglesTrack->setAnnotationType( RiuPlotAnnotationTool::NO_ANNOTATIONS );
wellPathAnglesTrack->setShowRegionLabels( false );
}

View File

@@ -32,6 +32,9 @@ class RicNewWellBoreStabilityPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static RimWellBoreStabilityPlot* createPlot( RimGeoMechCase* geoMechCase, RimWellPath* wellPath, int timeStep );
protected:
// Overrides
bool isCommandEnabled() override;
@@ -39,9 +42,18 @@ protected:
void setupActionLook( QAction* actionToSetup ) override;
private:
void createFormationTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechCase* geoMechCase );
void createCasingShoeTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechCase* geoMechCase );
void createParametersTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechView* geoMechView );
void createStabilityCurvesTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechView* geoMechView );
void createAnglesTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechView* geoMechView );
static void createFormationTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechCase* geoMechCase );
static void createCasingShoeTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechCase* geoMechCase );
static void createParametersTrack( RimWellBoreStabilityPlot* plot,
RimWellPath* wellPath,
RimGeoMechCase* geoMechCase,
int timeStep );
static void createStabilityCurvesTrack( RimWellBoreStabilityPlot* plot,
RimWellPath* wellPath,
RimGeoMechCase* geoMechCase,
int timeStep );
static void createAnglesTrack( RimWellBoreStabilityPlot* plot,
RimWellPath* wellPath,
RimGeoMechCase* geoMechCase,
int timeStep );
};

View File

@@ -74,7 +74,7 @@ void RicNewWellLogCurveExtractionFeature::onActionTriggered( bool isChecked )
RimWellLogTrack* wellLogPlotTrack = caf::SelectionManager::instance()->selectedItemOfType<RimWellLogTrack>();
if ( wellLogPlotTrack )
{
RicWellLogTools::addWellLogExtractionCurve( wellLogPlotTrack, nullptr, nullptr, nullptr, -1, true );
RicWellLogTools::addWellLogExtractionCurve( wellLogPlotTrack, nullptr, nullptr, nullptr, nullptr, -1, true );
}
else
{
@@ -108,12 +108,15 @@ void RicNewWellLogCurveExtractionFeature::onActionTriggered( bool isChecked )
newWellLogPlotTrack->setFormationBranchDetection( useBranchDetection );
}
RimCase* ownerCase = nullptr;
if ( view )
{
ownerCase = view->ownerCase();
newWellLogPlotTrack->setFormationCase( view->ownerCase() );
}
RimWellLogExtractionCurve* plotCurve = RicWellLogTools::addWellLogExtractionCurve( newWellLogPlotTrack,
ownerCase,
view,
wellPath,
simWell,

View File

@@ -53,12 +53,8 @@ bool RicNewWellLogPlotFeature::isCommandEnabled()
void RicNewWellLogPlotFeature::onActionTriggered( bool isChecked )
{
RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
RimWellLogExtractionCurve* curve = RicWellLogTools::addWellLogExtractionCurve( plotTrack,
nullptr,
nullptr,
nullptr,
-1,
true );
RimWellLogExtractionCurve* curve =
RicWellLogTools::addWellLogExtractionCurve( plotTrack, nullptr, nullptr, nullptr, nullptr, -1, true );
curve->loadDataAndUpdate( true );
RimWellLogPlot* plot = nullptr;
plotTrack->firstAncestorOrThisOfTypeAsserted( plot );

View File

@@ -53,6 +53,7 @@ RimWellBoreStabilityPlot*
RimWellBoreStabilityPlot* plot = new RimWellBoreStabilityPlot();
plot->setAsPlotMdiWindow();
RiaApplication::instance()->project()->assignViewIdToView( plot );
wellLogPlotColl->wellLogPlots().push_back( plot );
@@ -87,6 +88,7 @@ RimWellLogPlot* RicNewWellLogPlotFeatureImpl::createWellLogPlot( bool showAfterC
RimWellLogPlot* plot = new RimWellLogPlot();
plot->setAsPlotMdiWindow();
RiaApplication::instance()->project()->assignViewIdToView( plot );
wellLogPlotColl->wellLogPlots().push_back( plot );

View File

@@ -66,7 +66,7 @@ void RicNewWellLogPlotTrackFeature::onActionTriggered( bool isChecked )
plotTrack->setDescription( QString( "Track %1" ).arg( wellLogPlot->trackCount() ) );
RiuPlotMainWindow* plotWindow = RiaGuiApplication::instance()->getOrCreateMainPlotWindow();
RiuWellLogPlot* viewWidget = dynamic_cast<RiuWellLogPlot*>( wellLogPlot->viewWidget() );
RicWellLogTools::addWellLogExtractionCurve( plotTrack, nullptr, nullptr, nullptr, -1, true );
RicWellLogTools::addWellLogExtractionCurve( plotTrack, nullptr, nullptr, nullptr, nullptr, -1, true );
plotWindow->setWidthOfMdiWindow( viewWidget, viewWidget->preferredWidth() );
wellLogPlot->updateConnectedEditors();

View File

@@ -20,6 +20,9 @@
#include "RicWellLogsImportFileFeature.h"
#include "RiaApplication.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RimProject.h"
#include "Riu3DMainWindowTools.h"
@@ -27,9 +30,38 @@
#include <QAction>
#include <QFileDialog>
#include <QMessageBox>
CAF_CMD_SOURCE_INIT( RicWellLogsImportFileFeature, "RicWellLogsImportFileFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellLogFile*> RicWellLogsImportFileFeature::importWellLogFiles( const QStringList& wellLogFilePaths,
QStringList* errorMessages )
{
RiaApplication* app = RiaApplication::instance();
// Remember the path to next time
app->setLastUsedDialogDirectory( "WELL_LOGS_DIR", QFileInfo( wellLogFilePaths.last() ).absolutePath() );
std::vector<RimWellLogFile*> wellLogFiles = app->addWellLogsToModel( wellLogFilePaths, errorMessages );
caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors();
return wellLogFiles;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RicWellLogsImportFileFeature::wellLogFileNameFilters()
{
QStringList nameFilters;
nameFilters << "*.las";
return nameFilters;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -44,21 +76,29 @@ bool RicWellLogsImportFileFeature::isCommandEnabled()
void RicWellLogsImportFileFeature::onActionTriggered( bool isChecked )
{
// Open dialog box to select well path files
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->lastUsedDialogDirectory( "WELL_LOGS_DIR" );
QStringList wellLogFilePaths = QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(),
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->lastUsedDialogDirectory( "WELL_LOGS_DIR" );
QString nameFilterString = QString( "Well Logs (%1);;All Files (*.*)" ).arg( wellLogFileNameFilters().join( " " ) );
QStringList wellLogFilePaths = QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(),
"Import Well Logs",
defaultDir,
"Well Logs (*.las);;All Files (*.*)" );
nameFilterString );
if ( wellLogFilePaths.size() < 1 ) return;
if ( wellLogFilePaths.size() >= 1 )
{
QStringList errorMessages;
importWellLogFiles( wellLogFilePaths, &errorMessages );
if ( !errorMessages.empty() )
{
QString displayMessage = "Errors opening the LAS files: \n" + errorMessages.join( "\n" );
// Remember the path to next time
app->setLastUsedDialogDirectory( "WELL_LOGS_DIR", QFileInfo( wellLogFilePaths.last() ).absolutePath() );
app->addWellLogsToModel( wellLogFilePaths );
caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors();
if ( RiaGuiApplication::isRunning() )
{
QMessageBox::warning( Riu3DMainWindowTools::mainWindowWidget(), "File open error", displayMessage );
}
RiaLogging::warning( displayMessage );
}
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -21,12 +21,19 @@
#include "cafCmdFeature.h"
#include <vector>
class RimWellLogFile;
//==================================================================================================
///
//==================================================================================================
class RicWellLogsImportFileFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
static std::vector<RimWellLogFile*> importWellLogFiles( const QStringList& wellLogFilePaths,
QStringList* errorMessages );
static QStringList wellLogFileNameFilters();
protected:
// Overrides