mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-02 09:00:14 -06:00
#8370: Add Project.summary_ensembles and summary_plot_collection
This commit is contained in:
1 parent
fac5eb5f3b
commit
62b040ac42
4 files changed
+104
No files matched your search
@@ -28,6 +28,7 @@
|
|||||||
#include "RiaPreferencesGrid.h"
|
#include "RiaPreferencesGrid.h"
|
||||||
#include "RiaQStringFormatter.h"
|
#include "RiaQStringFormatter.h"
|
||||||
#include "RiaRegressionTestRunner.h"
|
#include "RiaRegressionTestRunner.h"
|
||||||
|
#include "Summary/RiaSummaryTools.h"
|
||||||
|
|
||||||
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
|
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
|
||||||
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
|
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
|
||||||
@@ -54,6 +55,7 @@
|
|||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
#include "RimSummaryCase.h"
|
#include "RimSummaryCase.h"
|
||||||
#include "RimSummaryCaseMainCollection.h"
|
#include "RimSummaryCaseMainCollection.h"
|
||||||
|
#include "RimSummaryEnsemble.h"
|
||||||
#include "RimSurfaceCollection.h"
|
#include "RimSurfaceCollection.h"
|
||||||
#include "RimTools.h"
|
#include "RimTools.h"
|
||||||
#include "RimValveTemplateCollection.h"
|
#include "RimValveTemplateCollection.h"
|
||||||
@@ -132,6 +134,64 @@ QString RimProject_importSummaryCase::classKeywordReturnedType() const
|
|||||||
return RimFileSummaryCase::classKeywordStatic();
|
return RimFileSummaryCase::classKeywordStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_importSummaryEnsemble, "importSummaryEnsemble" );
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RimProject_importSummaryEnsemble::RimProject_importSummaryEnsemble( caf::PdmObjectHandle* self )
|
||||||
|
: PdmObjectCreationMethod( self )
|
||||||
|
{
|
||||||
|
CAF_PDM_InitObject( "Import Summary Ensemble", "", "", "Import summary files as one ensemble" );
|
||||||
|
|
||||||
|
CAF_PDM_InitScriptableFieldNoDefault( &m_fileNames, "FileNames", "", "", "", "Summary files (SMSPEC), one for each realization" );
|
||||||
|
CAF_PDM_InitScriptableFieldNoDefault( &m_ensembleName, "EnsembleName", "", "", "", "Ensemble name. Automatically generated if empty" );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_importSummaryEnsemble::execute()
|
||||||
|
{
|
||||||
|
QStringList summaryFileNames;
|
||||||
|
for ( const QString& fileName : m_fileNames() )
|
||||||
|
{
|
||||||
|
QString absolutePath = fileName;
|
||||||
|
if ( !QFileInfo( absolutePath ).exists() )
|
||||||
|
{
|
||||||
|
absolutePath = QDir( RiaApplication::instance()->startDir() ).absoluteFilePath( fileName );
|
||||||
|
}
|
||||||
|
summaryFileNames.push_back( absolutePath );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( summaryFileNames.isEmpty() ) return std::unexpected( "No summary files specified." );
|
||||||
|
|
||||||
|
RiaEnsembleImportTools::CreateConfig createConfig{ .fileType = RiaDefines::FileType::SMSPEC, .ensembleOrGroup = true, .allowDialogs = false };
|
||||||
|
auto newCases = RiaEnsembleImportTools::createSummaryCasesFromFiles( summaryFileNames, createConfig );
|
||||||
|
if ( newCases.empty() ) return std::unexpected( "Unable to import any of the summary files." );
|
||||||
|
|
||||||
|
auto* mainCollection = RiaSummaryTools::summaryCaseMainCollection();
|
||||||
|
if ( !mainCollection ) return std::unexpected( "No summary case collection found." );
|
||||||
|
|
||||||
|
auto ensemble = mainCollection->addEnsemble( newCases, m_ensembleName(), true );
|
||||||
|
|
||||||
|
// The name template is only used when auto naming is disabled
|
||||||
|
if ( !m_ensembleName().isEmpty() ) ensemble->setAutoName( false );
|
||||||
|
RiaSummaryTools::updateSummaryEnsembleNames();
|
||||||
|
|
||||||
|
mainCollection->updateConnectedEditors();
|
||||||
|
|
||||||
|
return ensemble;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RimProject_importSummaryEnsemble::classKeywordReturnedType() const
|
||||||
|
{
|
||||||
|
return RimSummaryEnsemble::classKeywordStatic();
|
||||||
|
}
|
||||||
|
|
||||||
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_summaryCase, "summaryCase" );
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_summaryCase, "summaryCase" );
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -52,6 +52,24 @@ private:
|
|||||||
caf::PdmField<QString> m_fileName;
|
caf::PdmField<QString> m_fileName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RimProject_importSummaryEnsemble : public caf::PdmObjectCreationMethod
|
||||||
|
{
|
||||||
|
CAF_PDM_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
RimProject_importSummaryEnsemble( caf::PdmObjectHandle* self );
|
||||||
|
|
||||||
|
std::expected<caf::PdmObjectHandle*, QString> execute() override;
|
||||||
|
QString classKeywordReturnedType() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
caf::PdmField<std::vector<QString>> m_fileNames;
|
||||||
|
caf::PdmField<QString> m_ensembleName;
|
||||||
|
};
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ from .exception import RipsError as RipsError # noqa: E402
|
|||||||
from .surface import RegularSurface as RegularSurface # noqa: E402
|
from .surface import RegularSurface as RegularSurface # noqa: E402
|
||||||
from . import well_events as well_events # noqa: F401, E402
|
from . import well_events as well_events # noqa: F401, E402
|
||||||
from . import category_mapping as category_mapping # noqa: F401, E402
|
from . import category_mapping as category_mapping # noqa: F401, E402
|
||||||
|
from . import summary_ensemble as summary_ensemble # noqa: F401, E402
|
||||||
|
|
||||||
__all__: List[str] = []
|
__all__: List[str] = []
|
||||||
for key in class_dict(): # noqa: F405
|
for key in class_dict(): # noqa: F405
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ from .resinsight_classes import (
|
|||||||
SnapshotContentType,
|
SnapshotContentType,
|
||||||
SnapshotFileFormat,
|
SnapshotFileFormat,
|
||||||
SummaryCase,
|
SummaryCase,
|
||||||
|
SummaryEnsemble,
|
||||||
|
SummaryPlotCollection,
|
||||||
WellPath,
|
WellPath,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -624,3 +626,26 @@ def remove_key_values(self, key):
|
|||||||
"""
|
"""
|
||||||
request = KeyValueStore_pb2.KeyValueStoreRemoveRequest(name=key)
|
request = KeyValueStore_pb2.KeyValueStoreRemoveRequest(name=key)
|
||||||
self.__key_value_store_stub.RemoveValue(request)
|
self.__key_value_store_stub.RemoveValue(request)
|
||||||
|
|
||||||
|
|
||||||
|
@add_method(Project)
|
||||||
|
def summary_ensembles(self: Project) -> List[SummaryEnsemble]:
|
||||||
|
"""Get all summary ensembles in the project
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
List[SummaryEnsemble]: Summary case groups flagged as ensembles
|
||||||
|
"""
|
||||||
|
return [group for group in self.descendants(SummaryEnsemble) if group.is_ensemble]
|
||||||
|
|
||||||
|
|
||||||
|
@add_method(Project)
|
||||||
|
def summary_plot_collection(self: Project) -> SummaryPlotCollection:
|
||||||
|
"""Get the summary plot collection of the project
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
SummaryPlotCollection: The collection used to create summary plots
|
||||||
|
"""
|
||||||
|
collections = self.descendants(SummaryPlotCollection)
|
||||||
|
if not collections:
|
||||||
|
raise RipsError("No summary plot collection found in the project")
|
||||||
|
return collections[0]
|
||||||
Reference in new issue
Block a user