mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5757 Python : Add access to summary values
This commit is contained in:
parent
db54cf993c
commit
903c6ba94b
@ -0,0 +1,18 @@
|
||||
# Load ResInsight Processing Server Client Library
|
||||
import rips
|
||||
# Connect to ResInsight instance
|
||||
resinsight = rips.Instance.find()
|
||||
# Example code
|
||||
print("ResInsight version: " + resinsight.version_string())
|
||||
|
||||
project = resinsight.project
|
||||
|
||||
summary_cases = project.descendants(rips.SummaryCase)
|
||||
|
||||
firstCase = summary_cases[0]
|
||||
|
||||
vector_name = "FOPT"
|
||||
summary_data = firstCase.summary_vector_values(vector_name)
|
||||
|
||||
print("Data for summary vector " + vector_name)
|
||||
print(summary_data.double_values)
|
@ -1,10 +1,14 @@
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryPlotCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryCase.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcDataContainerDouble.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryPlotCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryCase.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcDataContainerDouble.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,34 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- 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 "RimcDataContainerDouble.h"
|
||||
|
||||
#include "cafPdmFieldIOScriptability.h"
|
||||
|
||||
#include "cafPdmObjectScriptability.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimcDataContainerDouble, "DataContainerDouble" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimcDataContainerDouble::RimcDataContainerDouble()
|
||||
{
|
||||
CAF_PDM_InitScriptableObject( "Data Container Double", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_doubleValues, "DoubleValues", "Data Double Values", "", "", "" );
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- 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 "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimcDataContainerDouble : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimcDataContainerDouble();
|
||||
|
||||
caf::PdmField<std::vector<double>> m_doubleValues;
|
||||
};
|
84
ApplicationCode/ProjectDataModelCommands/RimcSummaryCase.cpp
Normal file
84
ApplicationCode/ProjectDataModelCommands/RimcSummaryCase.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- 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 "RimcSummaryCase.h"
|
||||
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimcDataContainerDouble.h"
|
||||
|
||||
#include "cafPdmFieldIOScriptability.h"
|
||||
|
||||
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimcSummaryCase_summaryVectorValues, "SummaryVectorValues" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimcSummaryCase_summaryVectorValues::RimcSummaryCase_summaryVectorValues( caf::PdmObjectHandle* self )
|
||||
: caf::PdmObjectMethod( self )
|
||||
{
|
||||
CAF_PDM_InitObject( "Create Summary Plot", "", "", "Create a new Summary Plot" );
|
||||
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_addressString,
|
||||
"Address",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"Formatted address specifying the summary vector" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObjectHandle* RimcSummaryCase_summaryVectorValues::execute()
|
||||
{
|
||||
QStringList addressStrings = m_addressString().split( ";", QString::SkipEmptyParts );
|
||||
|
||||
auto* summaryCase = self<RimSummaryCase>();
|
||||
RifSummaryReaderInterface* sumReader = summaryCase->summaryReader();
|
||||
|
||||
auto adr = RifEclipseSummaryAddress::fromEclipseTextAddress( m_addressString().toStdString() );
|
||||
|
||||
std::vector<double> values;
|
||||
bool isOk = sumReader->values( adr, &values );
|
||||
|
||||
if ( isOk )
|
||||
{
|
||||
auto dataObject = new RimcDataContainerDouble();
|
||||
dataObject->m_doubleValues = values;
|
||||
|
||||
return dataObject;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimcSummaryCase_summaryVectorValues::resultIsPersistent() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::unique_ptr<caf::PdmObjectHandle> RimcSummaryCase_summaryVectorValues::defaultResult() const
|
||||
{
|
||||
return std::unique_ptr<caf::PdmObjectHandle>( new RimcDataContainerDouble );
|
||||
}
|
43
ApplicationCode/ProjectDataModelCommands/RimcSummaryCase.h
Normal file
43
ApplicationCode/ProjectDataModelCommands/RimcSummaryCase.h
Normal file
@ -0,0 +1,43 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- 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 "cafPdmField.h"
|
||||
#include "cafPdmObjectHandle.h"
|
||||
#include "cafPdmObjectMethod.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <memory>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimcSummaryCase_summaryVectorValues : public caf::PdmObjectMethod
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimcSummaryCase_summaryVectorValues( caf::PdmObjectHandle* self );
|
||||
|
||||
caf::PdmObjectHandle* execute();
|
||||
bool resultIsPersistent() const override;
|
||||
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_addressString;
|
||||
};
|
Loading…
Reference in New Issue
Block a user