Python: Create ensemble curve sets when creating summary plot for ensemble

new_summary_plot() with an ensemble and an address string created an empty
plot. The address filters were applied to an empty list of summary cases, and
no curve sets were created. Use the summary cases of the ensemble, and make
sure the summary addresses are created before the address filters are applied.

Add example script showing how to create summary plots for an ensemble.
This commit is contained in:
Kristian Bendiksen committed 2026-09-04 15:32:09 +02:00
1 parent d575ae504b
commit e2dc024854
2 files changed
+59 -1

No files matched your search

@@ -30,6 +30,8 @@
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RifSummaryReaderInterface.h"
#include "cafPdmAbstractFieldScriptingCapability.h"
#include "cafPdmFieldScriptingCapability.h"
@@ -62,7 +64,15 @@ std::expected<caf::PdmObjectHandle*, QString> RimcSummaryPlotCollection_newSumma
{
if ( !addressStrings.empty() )
{
newPlot = RicSummaryPlotFeatureImpl::createSummaryPlotForEnsemble( std::vector<RimSummaryCase*>(), m_ensemble, addressStrings );
auto summaryCases = m_ensemble->allSummaryCases();
// Summary addresses are created on demand, make sure they are available before applying address filters
for ( auto summaryCase : summaryCases )
{
if ( auto reader = summaryCase ? summaryCase->summaryReader() : nullptr ) reader->createAddressesIfRequired();
}
newPlot = RicSummaryPlotFeatureImpl::createSummaryPlotForEnsemble( summaryCases, m_ensemble, addressStrings );
}
else
{
@@ -0,0 +1,48 @@
###############################################################################
# Create summary plots for an ensemble
#
###############################################################################
import sys
import rips
# Connect to a running ResInsight instance
resinsight = rips.Instance.find()
project = resinsight.project
# Summary ensembles and summary groups are both represented by
# SummaryCaseSubCollection. Use the 'is_ensemble' flag to pick the ensembles.
ensembles = [
collection
for collection in project.descendants(rips.SummaryCaseSubCollection)
if collection.is_ensemble
]
if not ensembles:
print("No summary ensemble found in the current project")
sys.exit(1)
summary_plot_collection = project.descendants(rips.SummaryPlotCollection)[0]
for ensemble in ensembles:
print("Creating plots for ensemble: " + ensemble.summary_collection_name)
# One vector per plot
summary_plot_collection.new_summary_plot(ensemble=ensemble, address="FOPT")
# Multiple vectors in the same plot, separated by ';'
summary_plot_collection.new_summary_plot(
ensemble=ensemble, address="FOPR;FGPR;FWPR"
)
# Wildcards are supported, here all oil production totals for all wells
summary_plot_collection.new_summary_plot(ensemble=ensemble, address="WOPT:*")
# Each call to new_summary_plot() appends a new summary multi plot to the
# project. Adjust the layout of the plots created above if required.
for multi_plot in project.descendants(rips.MultiSummaryPlot):
multi_plot.number_of_columns = 2
multi_plot.rows_per_page = 2
multi_plot.update()