mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-01 03:37:15 -06:00
Fix Python access to contour maps
This commit is contained in:
parent
86cc2b5c9c
commit
84f5c5d068
@ -10,7 +10,7 @@ resInsight = rips.Instance.find()
|
||||
tmpdir = pathlib.Path(tempfile.gettempdir())
|
||||
|
||||
# Find all eclipse contour maps of the project
|
||||
contour_maps = resInsight.project.contour_maps(rips.ContourMapType.ECLIPSE)
|
||||
contour_maps = resInsight.project.descendants(rips.EclipseContourMap)
|
||||
print("Number of eclipse contour maps:", len(contour_maps))
|
||||
|
||||
# Export the contour maps to a text file
|
||||
@ -23,7 +23,7 @@ for (index, contour_map) in enumerate(contour_maps):
|
||||
# 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)
|
||||
contour_maps = case.descendants(rips.GeoMechContourMap)
|
||||
# Export the contour maps to a text file
|
||||
for (index, contour_map) in enumerate(contour_maps):
|
||||
filename = "geomech_contour_map" + str(index) + ".txt"
|
||||
|
@ -4,14 +4,14 @@ import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'generated'))
|
||||
|
||||
from rips.case import Case
|
||||
from rips.case import Case, EclipseCase, GeoMechCase
|
||||
from rips.grid import Grid
|
||||
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, PlotWindow
|
||||
from rips.contour_map import ContourMap, ContourMapType
|
||||
from rips.contour_map import EclipseContourMap, GeoMechContourMap
|
||||
from rips.well_log_plot import WellLogPlot
|
||||
from rips.well_bore_stability_plot import WellBoreStabilityPlot, WbsParameters
|
||||
from rips.simulation_well import SimulationWell
|
||||
|
@ -1096,4 +1096,4 @@ def nnc_connections_generated_values(self, property_name, time_step):
|
||||
value in this list.
|
||||
"""
|
||||
generator = self.nnc_connections_generated_values_async(property_name, time_step)
|
||||
return self.__nnc_values_generator_to_list(generator)
|
||||
return self.__nnc_values_generator_to_list(generator)
|
||||
|
@ -3,48 +3,43 @@ ResInsight 3d contour map module
|
||||
"""
|
||||
import rips.generated.Commands_pb2 as Cmd
|
||||
|
||||
from rips.pdmobject import PdmObject
|
||||
from rips.pdmobject import PdmObject, add_method
|
||||
from rips.view import View
|
||||
from enum import Enum
|
||||
from rips.generated.pdm_objects import EclipseContourMap, GeoMechContourMap
|
||||
|
||||
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, map_type):
|
||||
View.__init__(self, pdm_object)
|
||||
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
|
||||
@add_method(EclipseContourMap)
|
||||
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.id))
|
||||
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.id))
|
||||
|
||||
@add_method(GeoMechContourMap)
|
||||
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.id))
|
||||
|
||||
|
@ -12,7 +12,6 @@ from rips.pdmobject import PdmObject, add_method, add_static_method
|
||||
from rips.plot import Plot
|
||||
from rips.view import View
|
||||
from rips.wellpath import WellPathBase
|
||||
from rips.contour_map import ContourMap, ContourMapType
|
||||
|
||||
import rips.generated.Commands_pb2 as Cmd
|
||||
from rips.generated.Definitions_pb2 import Empty
|
||||
@ -176,16 +175,6 @@ def plot(self, view_id):
|
||||
return plot_object
|
||||
return None
|
||||
|
||||
@add_method(Project)
|
||||
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, map_type))
|
||||
return contour_maps
|
||||
|
||||
@add_method(Project)
|
||||
def grid_case_groups(self):
|
||||
"""Get a list of all grid case groups in the project"""
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "RimEclipseContourMapView.h"
|
||||
|
||||
#include "RicfCommandObject.h"
|
||||
|
||||
#include "RiuViewer.h"
|
||||
#include "RivContourMapProjectionPartMgr.h"
|
||||
|
||||
@ -51,7 +53,12 @@ const cvf::Mat4d RimEclipseContourMapView::sm_defaultViewMatrix =
|
||||
RimEclipseContourMapView::RimEclipseContourMapView()
|
||||
: m_cameraPositionLastUpdate( cvf::Vec3d::UNDEFINED )
|
||||
{
|
||||
CAF_PDM_InitObject( "Contour Map View", ":/2DMap16x16.png", "", "" );
|
||||
RICF_InitObjectWithScriptNameAndComment( "Contour Map View",
|
||||
":/2DMap16x16.png",
|
||||
"",
|
||||
"",
|
||||
"EclipseContourMap",
|
||||
"A contour map for Eclipse cases" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_contourMapProjection, "ContourMapProjection", "Contour Map Projection", "", "", "" );
|
||||
m_contourMapProjection = new RimEclipseContourMapProjection();
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "RiuViewer.h"
|
||||
#include "RivContourMapProjectionPartMgr.h"
|
||||
|
||||
#include "RicfCommandObject.h"
|
||||
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
@ -49,7 +51,12 @@ const cvf::Mat4d RimGeoMechContourMapView::sm_defaultViewMatrix =
|
||||
RimGeoMechContourMapView::RimGeoMechContourMapView()
|
||||
: m_cameraPositionLastUpdate( cvf::Vec3d::UNDEFINED )
|
||||
{
|
||||
CAF_PDM_InitObject( "GeoMech Contour Map View", ":/2DMap16x16.png", "", "" );
|
||||
RICF_InitObjectWithScriptNameAndComment( "GeoMech Contour Map View",
|
||||
":/2DMap16x16.png",
|
||||
"",
|
||||
"",
|
||||
"GeoMechContourMap",
|
||||
"A contour map for GeoMech cases" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_contourMapProjection, "ContourMapProjection", "Contour Map Projection", "", "", "" );
|
||||
m_contourMapProjection = new RimGeoMechContourMapProjection();
|
||||
|
Loading…
Reference in New Issue
Block a user