Merge pull request #4871 from OPM/feature-export-contour-map-data

Feature export contour map data
This commit is contained in:
Kristian Bendiksen 2019-10-23 08:43:51 +02:00 committed by GitHub
commit 29fdca3f69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 734 additions and 48 deletions

3
.gitignore vendored
View File

@ -69,3 +69,6 @@ Ankh.NoLoad
/Resinsight_Host.creator
/Resinsight_Host.config
*.RESINSIGHT_IDX
#Python
*.pyc

View File

@ -81,6 +81,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicConvertGroupToEnsembleFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicResampleDialog.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateTemporaryLgrFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDeleteTemporaryLgrsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToTextFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToTextUi.h
)
@ -160,6 +162,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicConvertGroupToEnsembleFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicResampleDialog.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateTemporaryLgrFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDeleteTemporaryLgrsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToTextFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToTextUi.cpp
)

View File

@ -104,6 +104,7 @@ void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream( QTextStre
double endMd = wellPathGeom->measureDepths().back();
RifTextDataTableFormatter formatter( stream );
formatter.setHeaderPrefix( "# " );
formatter.setCommentPrefix( "# " );
formatter.setTableRowPrependText( " " );

View File

@ -0,0 +1,296 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- 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 "RicExportContourMapToTextFeature.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RicExportContourMapToTextUi.h"
#include "RifTextDataTableFormatter.h"
#include "RimContourMapProjection.h"
#include "RimEclipseContourMapProjection.h"
#include "RimEclipseContourMapView.h"
#include "RimGeoMechContourMapProjection.h"
#include "RimGeoMechContourMapView.h"
#include "RimProject.h"
#include "RimViewWindow.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include "cafUtils.h"
#include <QAction>
#include <QFileDialog>
#include <cmath>
RICF_SOURCE_INIT( RicExportContourMapToTextFeature, "RicExportContourMapToTextFeature", "exportContourMapToText" );
RicExportContourMapToTextFeature::RicExportContourMapToTextFeature()
{
RICF_InitFieldNoDefault( &m_exportFileName, "exportFileName", "", "", "", "" );
RICF_InitFieldNoDefault( &m_exportLocalCoordinates, "exportLocalCoordinates", "", "", "", "" );
RICF_InitFieldNoDefault( &m_undefinedValueLabel, "undefinedValueLabel", "", "", "", "" );
RICF_InitFieldNoDefault( &m_excludeUndefinedValues, "excludeUndefinedValues", "", "", "", "" );
RICF_InitField( &m_viewId, "viewId", -1, "View Id", "", "", "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExportContourMapToTextFeature::isCommandEnabled()
{
RimEclipseContourMapView* existingEclipseContourMap = caf::SelectionManager::instance()
->selectedItemOfType<RimEclipseContourMapView>();
RimGeoMechContourMapView* existingGeoMechContourMap = caf::SelectionManager::instance()
->selectedItemOfType<RimGeoMechContourMapView>();
return existingEclipseContourMap || existingGeoMechContourMap;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportContourMapToTextFeature::onActionTriggered( bool isChecked )
{
RimContourMapProjection* contourMapProjection = nullptr;
RimEclipseContourMapView* existingEclipseContourMap = caf::SelectionManager::instance()
->selectedItemOfType<RimEclipseContourMapView>();
RimGeoMechContourMapView* existingGeoMechContourMap = caf::SelectionManager::instance()
->selectedItemOfType<RimGeoMechContourMapView>();
CAF_ASSERT( existingEclipseContourMap || existingGeoMechContourMap );
QString contourMapName;
if ( existingEclipseContourMap )
{
m_viewId = existingEclipseContourMap->id();
contourMapProjection = existingEclipseContourMap->contourMapProjection();
contourMapName = existingEclipseContourMap->createAutoName();
}
else if ( existingGeoMechContourMap )
{
m_viewId = existingGeoMechContourMap->id();
contourMapProjection = existingGeoMechContourMap->contourMapProjection();
contourMapName = existingGeoMechContourMap->createAutoName();
}
CAF_ASSERT( contourMapProjection );
RiaGuiApplication* app = RiaGuiApplication::instance();
CAF_ASSERT( app && "Must be gui mode" );
QString startPath = app->lastUsedDialogDirectoryWithFallbackToProjectFolder( "CONTOUR_EXPORT" );
QString fileBaseName = caf::Utils::makeValidFileBasename( contourMapName );
startPath = startPath + "/" + fileBaseName + ".txt";
RicExportContourMapToTextUi featureUi;
featureUi.setExportFileName( startPath );
caf::PdmUiPropertyViewDialog propertyDialog( nullptr,
&featureUi,
"Export Contour Map to Text",
"",
QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
if ( propertyDialog.exec() == QDialog::Accepted )
{
QString fileName = featureUi.exportFileName();
app->setLastUsedDialogDirectory( "CONTOUR_EXPORT", fileName );
m_exportFileName = fileName;
m_exportLocalCoordinates = featureUi.exportLocalCoordinates();
m_undefinedValueLabel = featureUi.undefinedValueLabel();
m_excludeUndefinedValues = featureUi.excludeUndefinedValues();
RicfCommandResponse response = execute();
QStringList messages = response.messages();
if ( !messages.empty() )
{
QString displayMessage = QString( "Problem exporting contour map:\n%2" ).arg( messages.join( "\n" ) );
if ( response.status() == RicfCommandResponse::COMMAND_ERROR )
{
RiaLogging::error( displayMessage );
}
else
{
RiaLogging::warning( displayMessage );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportContourMapToTextFeature::writeMetaDataToStream( QTextStream& stream,
const RimContourMapProjection* contourMapProjection,
const QString& caseName,
bool exportLocalCoordinates )
{
cvf::Vec2ui numVerticesIJ = contourMapProjection->numberOfVerticesIJ();
stream << "# case name : " << contourMapProjection->caseName() << "\n";
stream << "# sampling points : nx=" << numVerticesIJ.x() << " ny=" << numVerticesIJ.y() << "\n";
stream << "# time and date : " << contourMapProjection->currentTimeStepName() << "\n";
stream << "# property name : " << contourMapProjection->resultDescriptionText() << "\n";
if ( exportLocalCoordinates )
{
stream << "# UTM offset : x=" << contourMapProjection->origin3d().x()
<< " y=" << contourMapProjection->origin3d().y() << "\n";
}
stream << "\n\n";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportContourMapToTextFeature::writeContourMapToStream( QTextStream& stream,
const RimContourMapProjection* contourMapProjection,
bool exportLocalCoordinates,
const QString& undefinedValueLabel,
bool excludeUndefinedValues )
{
RifTextDataTableFormatter formatter( stream );
formatter.setTableRowLineAppendText( "" );
formatter.setTableRowPrependText( "" );
formatter.setCommentPrefix( "#" );
formatter.setHeaderPrefix( "" );
formatter.setDefaultMarker( undefinedValueLabel );
std::vector<RifTextDataTableColumn> header = {
RifTextDataTableColumn( "x" ),
RifTextDataTableColumn( "y" ),
RifTextDataTableColumn( "value" ),
};
formatter.header( header );
cvf::Vec2ui numVerticesIJ = contourMapProjection->numberOfVerticesIJ();
std::vector<double> xVertexPositions = contourMapProjection->xVertexPositions();
std::vector<double> yVertexPositions = contourMapProjection->yVertexPositions();
// Undefined values are positive inf in contour map projection.
double undefined = std::numeric_limits<double>::infinity();
for ( unsigned int j = 0; j < numVerticesIJ.y(); j++ )
{
for ( unsigned int i = 0; i < numVerticesIJ.x(); i++ )
{
double value = contourMapProjection->valueAtVertex( i, j );
if ( !( std::isinf( value ) && excludeUndefinedValues ) )
{
double x = xVertexPositions.at( i );
double y = yVertexPositions.at( j );
if ( !exportLocalCoordinates )
{
x += contourMapProjection->origin3d().x();
y += contourMapProjection->origin3d().y();
}
formatter.add( x );
formatter.add( y );
formatter.addValueOrDefaultMarker( value, undefined );
formatter.rowCompleted();
}
}
}
formatter.tableCompleted();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportContourMapToTextFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Export Contour Map to Text" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfCommandResponse RicExportContourMapToTextFeature::execute()
{
RicfCommandResponse response;
QStringList errorMessages, warningMessages;
RiaApplication* app = RiaApplication::instance();
RimProject* proj = app->project();
CAF_ASSERT( proj );
std::vector<Rim3dView*> allViews;
proj->allViews( allViews );
Rim3dView* myView = nullptr;
for ( auto view : allViews )
{
if ( m_viewId == view->id() )
{
myView = view;
}
}
if ( !myView )
{
response.updateStatus( RicfCommandResponse::COMMAND_ERROR, "No contour map view found" );
return response;
}
RimContourMapProjection* contourMapProjection = nullptr;
RimEclipseContourMapView* existingEclipseContourMap = dynamic_cast<RimEclipseContourMapView*>( myView );
RimGeoMechContourMapView* existingGeoMechContourMap = dynamic_cast<RimGeoMechContourMapView*>( myView );
CAF_ASSERT( existingEclipseContourMap || existingGeoMechContourMap );
QString contourMapName;
if ( existingEclipseContourMap )
{
contourMapProjection = existingEclipseContourMap->contourMapProjection();
contourMapName = existingEclipseContourMap->createAutoName();
}
else if ( existingGeoMechContourMap )
{
contourMapProjection = existingGeoMechContourMap->contourMapProjection();
contourMapName = existingGeoMechContourMap->createAutoName();
}
CAF_ASSERT( contourMapProjection );
QFile exportFile( m_exportFileName );
if ( !exportFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
{
errorMessages << QString( "Export Contour Map to Text : Could not open the file: %1" ).arg( m_exportFileName );
}
else
{
QString tableText;
QTextStream stream( &exportFile );
writeMetaDataToStream( stream, contourMapProjection, contourMapName, m_exportLocalCoordinates.value() );
writeContourMapToStream( stream,
contourMapProjection,
m_exportLocalCoordinates.value(),
m_undefinedValueLabel.value(),
m_excludeUndefinedValues.value() );
}
for ( QString errorMessage : errorMessages )
{
response.updateStatus( RicfCommandResponse::COMMAND_ERROR, errorMessage );
}
return response;
}

View File

@ -0,0 +1,61 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- 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 "CommandFileInterface/Core/RicfCommandObject.h"
#include "cafCmdFeature.h"
#include "cafPdmField.h"
class RimContourMapProjection;
class QTextStream;
//==================================================================================================
///
//==================================================================================================
class RicExportContourMapToTextFeature : public caf::CmdFeature, public RicfCommandObject
{
RICF_HEADER_INIT;
public:
RicExportContourMapToTextFeature();
RicfCommandResponse execute() override;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
static void writeMetaDataToStream( QTextStream& stream,
const RimContourMapProjection* contourMapProjection,
const QString& caseName,
bool exportLocalCoordinates );
static void writeContourMapToStream( QTextStream& stream,
const RimContourMapProjection* contourMapProjection,
bool exportLocalCoordinates,
const QString& undefinedValueLabel,
bool excludeUndefinedValues );
private:
caf::PdmField<QString> m_exportFileName;
caf::PdmField<bool> m_exportLocalCoordinates;
caf::PdmField<QString> m_undefinedValueLabel;
caf::PdmField<bool> m_excludeUndefinedValues;
caf::PdmField<int> m_viewId;
};

View File

@ -0,0 +1,79 @@
#include "RicExportContourMapToTextUi.h"
#include "RiaApplication.h"
#include "cafPdmUiFilePathEditor.h"
CAF_PDM_SOURCE_INIT( RicExportContourMapToTextUi, "RicExportContourMapToTextUi" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportContourMapToTextUi::RicExportContourMapToTextUi()
{
CAF_PDM_InitObject( "Export Contour Map to Text", "", "", "" );
CAF_PDM_InitField( &m_exportFileName, "ExportFileName", QString(), "Export File Name", "", "", "" );
m_exportFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_exportLocalCoordinates, "ExportLocalCoordinates", false, "Export Local Coordinates", "", "", "" );
CAF_PDM_InitField( &m_undefinedValueLabel, "UndefinedValueLabel", QString( "NaN" ), "Undefined Value Label", "", "", "" );
CAF_PDM_InitField( &m_excludeUndefinedValues, "ExcludeUndefinedValues", false, "Exclude Undefined Values", "", "", "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicExportContourMapToTextUi::exportFileName() const
{
return m_exportFileName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportContourMapToTextUi::setExportFileName( const QString& exportFileName )
{
m_exportFileName = exportFileName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExportContourMapToTextUi::exportLocalCoordinates() const
{
return m_exportLocalCoordinates;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicExportContourMapToTextUi::undefinedValueLabel() const
{
return m_undefinedValueLabel;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExportContourMapToTextUi::excludeUndefinedValues() const
{
return m_excludeUndefinedValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportContourMapToTextUi::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_exportFileName )
{
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>( attribute );
if ( myAttr )
{
myAttr->m_selectSaveFileName = true;
}
}
}

View File

@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- 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 "cafPdmField.h"
#include "cafPdmObject.h"
//==================================================================================================
///
//==================================================================================================
class RicExportContourMapToTextUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicExportContourMapToTextUi();
QString exportFileName() const;
void setExportFileName( const QString& exportFileName );
bool exportLocalCoordinates() const;
QString undefinedValueLabel() const;
bool excludeUndefinedValues() const;
protected:
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
private:
caf::PdmField<QString> m_exportFileName;
caf::PdmField<bool> m_exportLocalCoordinates;
caf::PdmField<QString> m_undefinedValueLabel;
caf::PdmField<bool> m_excludeUndefinedValues;
};

View File

@ -33,7 +33,9 @@ RifTextDataTableFormatter::RifTextDataTableFormatter( QTextStream& out )
, m_tableRowPrependText( " " )
, m_tableRowAppendText( " /" )
, m_commentPrefix( "-- " )
, m_headerPrefix( "-- " )
, m_maxDataRowWidth( MAX_ECLIPSE_DATA_ROW_WIDTH )
, m_defaultMarker( "1*" )
{
}
@ -47,6 +49,7 @@ RifTextDataTableFormatter::RifTextDataTableFormatter( const RifTextDataTableForm
, m_tableRowAppendText( rhs.m_tableRowAppendText )
, m_commentPrefix( rhs.m_commentPrefix )
, m_maxDataRowWidth( rhs.m_maxDataRowWidth )
, m_defaultMarker( rhs.m_defaultMarker )
{
}
@ -123,6 +126,22 @@ void RifTextDataTableFormatter::setCommentPrefix( const QString& commentPrefix )
m_commentPrefix = commentPrefix;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RifTextDataTableFormatter::headerPrefix() const
{
return m_headerPrefix;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifTextDataTableFormatter::setHeaderPrefix( const QString& headerPrefix )
{
m_headerPrefix = headerPrefix;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -139,6 +158,22 @@ int RifTextDataTableFormatter::maxDataRowWidth() const
return m_maxDataRowWidth;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifTextDataTableFormatter::setDefaultMarker( const QString& defaultMarker )
{
m_defaultMarker = defaultMarker;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RifTextDataTableFormatter::defaultMarker() const
{
return m_defaultMarker;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -146,7 +181,7 @@ void RifTextDataTableFormatter::outputBuffer()
{
if ( !m_columns.empty() && !isAllHeadersEmpty( m_columns ) )
{
m_out << m_commentPrefix;
m_out << m_headerPrefix;
for ( size_t i = 0u; i < m_columns.size(); ++i )
{
m_out << formatColumn( m_columns[i].title, i );
@ -403,7 +438,7 @@ RifTextDataTableFormatter& RifTextDataTableFormatter::addValueOrDefaultMarker( d
{
if ( value == defaultValue )
{
return add( QString( "1*" ) );
return add( m_defaultMarker );
}
return add( value );
}

View File

@ -119,8 +119,12 @@ public:
void setTableRowLineAppendText( const QString& text );
QString commentPrefix() const;
void setCommentPrefix( const QString& commentPrefix );
QString headerPrefix() const;
void setHeaderPrefix( const QString& headerPrefix );
void setUnlimitedDataRowWidth();
int maxDataRowWidth() const;
void setDefaultMarker( const QString& defaultMarker );
QString defaultMarker() const;
RifTextDataTableFormatter& keyword( const QString& keyword );
RifTextDataTableFormatter& header( std::vector<RifTextDataTableColumn> tableHeader );
@ -167,5 +171,7 @@ private:
QString m_tableRowPrependText;
QString m_tableRowAppendText;
QString m_commentPrefix;
QString m_headerPrefix;
int m_maxDataRowWidth;
QString m_defaultMarker;
};

View File

@ -314,6 +314,15 @@ message ExportWellLogPlotDataRequest
double resampleInterval = 7;
}
message ExportContourMapToTextRequest
{
string exportFileName = 1;
bool exportLocalCoordinates = 2;
string undefinedValueLabel = 3;
bool excludeUndefinedValues = 4;
int32 viewId = 5;
}
/* CommandParams handles both command name and parameters in one.
* The message type and content is used as parameters and
* the name of the variable is used to find the command name. */
@ -325,43 +334,44 @@ message CommandParams
* the FilePathRequest message. */
oneof params
{
FilePathRequest openProject = 1;
Empty closeProject = 2;
FilePathRequest setStartDir = 3;
FilePathRequest loadCase = 4;
ReplaceCaseRequest replaceCase = 5;
ReplaceSourceCasesRequest replaceSourceCases = 6;
ExportMultiCaseRequest exportMultiCaseSnapshots = 7;
ExportSnapshotsRequest exportSnapshots = 8;
ExportPropertyRequest exportProperty = 9;
ExportPropertyInViewsRequest exportPropertyInViews = 10;
ExportWellPathCompRequest exportWellPathCompletions = 11;
ExportSimWellPathFracRequest exportSimWellFractureCompletions = 12;
ExportMswRequest exportMsw = 13;
ExportWellPathRequest exportWellPaths = 14;
ExportVisibleCellsRequest exportVisibleCells = 15;
SetExportFolderRequest setExportFolder = 16;
RunOctaveScriptRequest runOctaveScript = 17;
SetWindowSizeParams setMainWindowSize = 18;
ComputeCaseGroupStatRequest computeCaseGroupStatistics = 19;
SetTimeStepParams setTimeStep = 20;
ScaleFractureTemplateRequest scaleFractureTemplate = 21;
SetFracContainmentRequest setFractureContainment = 22;
CreateMultipleFracRequest createMultipleFractures = 23;
CreateLgrForCompRequest createLgrForCompletions = 24;
CreateSatPressPlotRequest createSaturationPressurePlots = 25;
ReplaceCaseRequests replaceMultipleCases = 26;
CreateGridCaseGroupRequest createGridCaseGroup = 27;
CreateStatisticsCaseRequest createStatisticsCase = 28;
ExportFlowInfoRequest exportFlowCharacteristics = 29;
CreateViewRequest createView = 30;
CloneViewRequest cloneView = 31;
CreateWbsPlotRequest createWellBoreStabilityPlot = 32;
ImportWellPathsRequest importWellPaths = 33;
ImportWellLogFilesRequest importWellLogFiles = 34;
ImportFormationNamesRequest importFormationNames = 35;
ExportWellLogPlotDataRequest exportWellLogPlotData = 36;
SetWindowSizeParams setPlotWindowSize = 37;
FilePathRequest openProject = 1;
Empty closeProject = 2;
FilePathRequest setStartDir = 3;
FilePathRequest loadCase = 4;
ReplaceCaseRequest replaceCase = 5;
ReplaceSourceCasesRequest replaceSourceCases = 6;
ExportMultiCaseRequest exportMultiCaseSnapshots = 7;
ExportSnapshotsRequest exportSnapshots = 8;
ExportPropertyRequest exportProperty = 9;
ExportPropertyInViewsRequest exportPropertyInViews = 10;
ExportWellPathCompRequest exportWellPathCompletions = 11;
ExportSimWellPathFracRequest exportSimWellFractureCompletions = 12;
ExportMswRequest exportMsw = 13;
ExportWellPathRequest exportWellPaths = 14;
ExportVisibleCellsRequest exportVisibleCells = 15;
SetExportFolderRequest setExportFolder = 16;
RunOctaveScriptRequest runOctaveScript = 17;
SetWindowSizeParams setMainWindowSize = 18;
ComputeCaseGroupStatRequest computeCaseGroupStatistics = 19;
SetTimeStepParams setTimeStep = 20;
ScaleFractureTemplateRequest scaleFractureTemplate = 21;
SetFracContainmentRequest setFractureContainment = 22;
CreateMultipleFracRequest createMultipleFractures = 23;
CreateLgrForCompRequest createLgrForCompletions = 24;
CreateSatPressPlotRequest createSaturationPressurePlots = 25;
ReplaceCaseRequests replaceMultipleCases = 26;
CreateGridCaseGroupRequest createGridCaseGroup = 27;
CreateStatisticsCaseRequest createStatisticsCase = 28;
ExportFlowInfoRequest exportFlowCharacteristics = 29;
CreateViewRequest createView = 30;
CloneViewRequest cloneView = 31;
CreateWbsPlotRequest createWellBoreStabilityPlot = 32;
ImportWellPathsRequest importWellPaths = 33;
ImportWellLogFilesRequest importWellLogFiles = 34;
ImportFormationNamesRequest importFormationNames = 35;
ExportWellLogPlotDataRequest exportWellLogPlotData = 36;
SetWindowSizeParams setPlotWindowSize = 37;
ExportContourMapToTextRequest exportContourMapToText = 38;
}
}

View File

@ -0,0 +1,32 @@
# Load ResInsight Processing Server Client Library
import rips
import tempfile
import pathlib
# Connect to ResInsight instance
resInsight = rips.Instance.find()
# Data will be written to temp
tmpdir = pathlib.Path(tempfile.gettempdir())
# Find all eclipse contour maps of the project
contour_maps = resInsight.project.contour_maps(rips.ContourMapType.ECLIPSE)
print("Number of eclipse contour maps:", len(contour_maps))
# Export the contour maps to a text file
for (index, contour_map) in enumerate(contour_maps):
filename = "eclipse_contour_map" + str(index) + ".txt"
filepath = tmpdir / filename
print("Exporting to:", filepath)
contour_map.export_to_text(str(filepath))
# The contour maps is also available for a Case
cases = resInsight.project.cases()
for case in cases:
contour_maps = case.contour_maps(rips.ContourMapType.GEO_MECH)
# Export the contour maps to a text file
for (index, contour_map) in enumerate(contour_maps):
filename = "geomech_contour_map" + str(index) + ".txt"
filepath = tmpdir / filename
print("Exporting to:", filepath)
contour_map.export_to_text(str(filepath))

View File

@ -10,4 +10,5 @@ from rips.instance import Instance
from rips.pdmobject import PdmObject
from rips.view import View
from rips.project import Project
from rips.plot import Plot
from rips.plot import Plot
from rips.contour_map import ContourMap, ContourMapType

View File

@ -18,7 +18,7 @@ import rips.generated.Properties_pb2_grpc as Properties_pb2_grpc
from rips.grid import Grid
from rips.pdmobject import PdmObject
from rips.view import View
from rips.contour_map import ContourMap, ContourMapType
class Case(PdmObject):
"""ResInsight case class
@ -250,6 +250,15 @@ class Case(PdmObject):
self._execute_command(createView=Cmd.CreateViewRequest(
caseId=self.case_id)).createViewResult.viewId)
def contour_maps(self, map_type=ContourMapType.ECLIPSE):
"""Get a list of all contour maps belonging to a project"""
pdm_objects = self.descendants(ContourMapType.get_identifier(map_type))
contour_maps = []
for pdm_object in pdm_objects:
contour_maps.append(ContourMap(pdm_object, self._project, map_type))
return contour_maps
def export_snapshots_of_all_views(self, prefix="", export_folder=""):
""" Export snapshots for all views in the case
@ -764,4 +773,4 @@ class Case(PdmObject):
formation_files = [formation_files]
res = self._execute_command(importFormationNames=Cmd.ImportFormationNamesRequest(formationFiles=formation_files,
applyToCaseId=self.case_id))
applyToCaseId=self.case_id))

View File

@ -0,0 +1,50 @@
"""
ResInsight 3d contour map module
"""
import rips.generated.Commands_pb2 as Cmd
from rips.pdmobject import PdmObject
from rips.view import View
from enum import Enum
class ContourMapType(Enum):
ECLIPSE = 1
GEO_MECH = 2
@staticmethod
def get_identifier(map_type):
if map_type==ContourMapType.ECLIPSE:
return "RimContourMapView"
elif map_type==ContourMapType.GEO_MECH:
return "RimGeoMechContourMapView"
else:
raise Exception("Unknown contour map type: must be ECLIPSE or GEO_MECH")
class ContourMap(View):
"""ResInsight contour map class
Attributes:
view_id(int): View Id corresponding to the View Id in ResInsight project.
"""
def __init__(self, pdm_object, project, map_type):
View.__init__(self, pdm_object, project)
self.view_id = pdm_object.get_value("ViewId")
self.map_type = map_type
def export_to_text(self, export_file_name='', export_local_coordinates=False, undefined_value_label="NaN", exclude_undefined_values=False):
""" Export snapshot for the current view
Arguments:
export_file_name(str): The file location to store results in.
export_local_coordinates(bool): Should we export local coordinates, or UTM.
undefined_value_label(str): Replace undefined values with this label.
exclude_undefined_values(bool): Skip undefined values.
"""
return self._execute_command(
exportContourMapToText=Cmd.ExportContourMapToTextRequest(
exportFileName=export_file_name,
exportLocalCoordinates=export_local_coordinates,
undefinedValueLabel=undefined_value_label,
excludeUndefinedValues=exclude_undefined_values,
viewId=self.view_id))

View File

@ -10,6 +10,7 @@ from rips.gridcasegroup import GridCaseGroup
from rips.pdmobject import PdmObject
from rips.plot import Plot
from rips.view import View
from rips.contour_map import ContourMap, ContourMapType
import rips.generated.Commands_pb2 as Cmd
from rips.generated.Definitions_pb2 import Empty
@ -163,6 +164,15 @@ class Project(PdmObject):
return plot_object
return None
def contour_maps(self, map_type=ContourMapType.ECLIPSE):
"""Get a list of all contour maps belonging to a project"""
pdm_objects = self.descendants(ContourMapType.get_identifier(map_type))
contour_maps = []
for pdm_object in pdm_objects:
contour_maps.append(ContourMap(pdm_object, self._project, map_type))
return contour_maps
def well_paths(self):
"""Get a list of all the well path names in the project"""
pdm_objects = self.descendants("WellPathBase")
@ -307,4 +317,4 @@ class Project(PdmObject):
formation_files = [formation_files]
res = self._execute_command(importFormationNames=Cmd.ImportFormationNamesRequest(formationFiles=formation_files,
applyToCaseId=-1))
applyToCaseId=-1))

View File

@ -170,10 +170,13 @@ void RimWellPltPlot::setPlotXAxisTitles( RimWellLogTrack* plotTrack )
{
case RiaDefines::UNIT_METER:
presentUnitSystems.insert( RiaEclipseUnitTools::UNITS_METRIC );
break;
case RiaDefines::UNIT_FEET:
presentUnitSystems.insert( RiaEclipseUnitTools::UNITS_FIELD );
break;
case RiaDefines::UNIT_NONE:
presentUnitSystems.insert( RiaEclipseUnitTools::UNITS_UNKNOWN );
break;
}
}
}

View File

@ -606,6 +606,7 @@ QString RimGridCrossPlot::asciiDataForPlotExport( int dataSetIndex ) const
RifTextDataTableFormatter formatter( stringStream );
formatter.setCommentPrefix( "" );
formatter.setHeaderPrefix( "" );
formatter.setTableRowPrependText( "" );
formatter.setTableRowLineAppendText( "" );
formatter.setColumnSpacing( 3 );

View File

@ -38,6 +38,7 @@
#include "RimEclipseCase.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseContourMapView.h"
#include "RimEclipseContourMapViewCollection.h"
#include "RimEclipseInputProperty.h"
#include "RimEclipseInputPropertyCollection.h"
@ -61,6 +62,7 @@
#include "RimFractureTemplate.h"
#include "RimFractureTemplateCollection.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechContourMapView.h"
#include "RimGeoMechContourMapViewCollection.h"
#include "RimGeoMechPropertyFilter.h"
#include "RimGeoMechPropertyFilterCollection.h"
@ -174,6 +176,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "Separator";
menuBuilder << "RicCopyReferencesToClipboardFeature";
menuBuilder << "RicExportContourMapToTextFeature";
}
else if ( dynamic_cast<RimEclipseView*>( uiItem ) )
{
@ -186,6 +189,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "Separator";
menuBuilder << "RicCopyReferencesToClipboardFeature";
menuBuilder << "RicExportEclipseInputGridFeature";
menuBuilder << "RicExportContourMapToTextFeature";
menuBuilder << "RicSaveEclipseInputVisibleCellsFeature";
}
else if ( dynamic_cast<RimEclipseContourMapViewCollection*>( uiItem ) )

View File

@ -243,6 +243,34 @@ QString RimContourMapProjection::resultAggregationText() const
return m_resultAggregation().uiText();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimContourMapProjection::caseName() const
{
RimCase* rimCase = baseView()->ownerCase();
if ( !rimCase )
{
return QString();
}
return rimCase->caseUserDescription.value();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimContourMapProjection::currentTimeStepName() const
{
RimCase* rimCase = baseView()->ownerCase();
if ( !rimCase || m_currentResultTimestep == -1 )
{
return QString();
}
return rimCase->timeStepName( m_currentResultTimestep );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1606,7 +1634,7 @@ cvf::Vec2d RimContourMapProjection::origin2d() const
}
//--------------------------------------------------------------------------------------------------
///
/// Vertex positions in local coordinates (add origin2d.x() for UTM x)
//--------------------------------------------------------------------------------------------------
std::vector<double> RimContourMapProjection::xVertexPositions() const
{
@ -1624,7 +1652,7 @@ std::vector<double> RimContourMapProjection::xVertexPositions() const
}
//--------------------------------------------------------------------------------------------------
///
/// Vertex positions in local coordinates (add origin2d.y() for UTM y)
//--------------------------------------------------------------------------------------------------
std::vector<double> RimContourMapProjection::yVertexPositions() const
{

View File

@ -89,6 +89,9 @@ public:
QString resultAggregationText() const;
QString caseName() const;
QString currentTimeStepName() const;
double maxValue() const;
double minValue() const;
@ -110,6 +113,9 @@ public:
void setPickPoint( cvf::Vec2d globalPickPoint );
cvf::Vec3d origin3d() const;
std::vector<double> xVertexPositions() const;
std::vector<double> yVertexPositions() const;
// Pure-virtual public methods which should be overridden by Eclipse and Geo-mechanical contour map implementations
virtual QString resultDescriptionText() const = 0;
virtual RimRegularLegendConfig* legendConfig() const = 0;
@ -190,9 +196,6 @@ protected:
cvf::Vec2d cellCenterPosition( uint i, uint j ) const;
cvf::Vec2d origin2d() const;
std::vector<double> xVertexPositions() const;
std::vector<double> yVertexPositions() const;
cvf::Vec2ui calculateMapSize() const;
double gridEdgeOffset() const;