mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Make Correlation plots work with multiple ensembles
This commit is contained in:
parent
ae7c4d9e31
commit
658cffd8e0
@ -80,7 +80,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EnsembleParameter parameter;
|
QString parameter;
|
||||||
RiaSummaryCurveDefinition curveDef;
|
RiaSummaryCurveDefinition curveDef;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -140,8 +140,8 @@ public:
|
|||||||
double m_correlationAbsSum;
|
double m_correlationAbsSum;
|
||||||
};
|
};
|
||||||
|
|
||||||
using CorrelationMatrixColumn = CorrelationMatrixRowOrColumn<EnsembleParameter, RiaSummaryCurveDefinition>;
|
using CorrelationMatrixColumn = CorrelationMatrixRowOrColumn<QString, RiaSummaryCurveDefinition>;
|
||||||
using CorrelationMatrixRow = CorrelationMatrixRowOrColumn<RiaSummaryCurveDefinition, EnsembleParameter>;
|
using CorrelationMatrixRow = CorrelationMatrixRowOrColumn<RiaSummaryCurveDefinition, QString>;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@ -493,12 +493,12 @@ void RimCorrelationMatrixPlot::createMatrix()
|
|||||||
auto curveDefs = curveDefinitions();
|
auto curveDefs = curveDefinitions();
|
||||||
if ( curveDefs.empty() ) return;
|
if ( curveDefs.empty() ) return;
|
||||||
|
|
||||||
|
QStringList ensembleNames;
|
||||||
|
|
||||||
std::vector<CorrelationMatrixColumn> correlationMatrixColumns;
|
std::vector<CorrelationMatrixColumn> correlationMatrixColumns;
|
||||||
|
|
||||||
for ( QString paramName : m_selectedParametersList() )
|
for ( QString paramName : m_selectedParametersList() )
|
||||||
{
|
{
|
||||||
EnsembleParameter parameter;
|
|
||||||
|
|
||||||
bool anyValidResults = false;
|
bool anyValidResults = false;
|
||||||
std::vector<double> correlations;
|
std::vector<double> correlations;
|
||||||
std::vector<RiaSummaryCurveDefinition> selectedCurveDefs;
|
std::vector<RiaSummaryCurveDefinition> selectedCurveDefs;
|
||||||
@ -513,10 +513,7 @@ void RimCorrelationMatrixPlot::createMatrix()
|
|||||||
std::vector<double> caseValuesAtTimestep;
|
std::vector<double> caseValuesAtTimestep;
|
||||||
std::vector<double> parameterValues;
|
std::vector<double> parameterValues;
|
||||||
|
|
||||||
if ( !parameter.isValid() )
|
EnsembleParameter parameter = ensemble->ensembleParameter( paramName );
|
||||||
{
|
|
||||||
parameter = ensemble->ensembleParameter( paramName );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( parameter.isValid() )
|
if ( parameter.isValid() )
|
||||||
{
|
{
|
||||||
@ -572,12 +569,13 @@ void RimCorrelationMatrixPlot::createMatrix()
|
|||||||
}
|
}
|
||||||
correlations.push_back( correlation );
|
correlations.push_back( correlation );
|
||||||
selectedCurveDefs.push_back( curveDef );
|
selectedCurveDefs.push_back( curveDef );
|
||||||
|
ensembleNames.push_back( ensemble->name() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( anyValidResults )
|
if ( anyValidResults )
|
||||||
{
|
{
|
||||||
correlationMatrixColumns.push_back( CorrelationMatrixColumn( parameter, correlations, selectedCurveDefs ) );
|
correlationMatrixColumns.push_back( CorrelationMatrixColumn( paramName, correlations, selectedCurveDefs ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,13 +604,16 @@ void RimCorrelationMatrixPlot::createMatrix()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ensembleNames.removeDuplicates();
|
||||||
|
QString combinedEnsembleNames = ensembleNames.join( ";; " );
|
||||||
for ( size_t rowIdx = 0u; rowIdx < correlationMatrixRows.size(); ++rowIdx )
|
for ( size_t rowIdx = 0u; rowIdx < correlationMatrixRows.size(); ++rowIdx )
|
||||||
{
|
{
|
||||||
for ( size_t colIdx = 0u; colIdx < correlationMatrixRows[rowIdx].m_correlations.size(); ++colIdx )
|
for ( size_t colIdx = 0u; colIdx < correlationMatrixRows[rowIdx].m_correlations.size(); ++colIdx )
|
||||||
{
|
{
|
||||||
double correlation = correlationMatrixRows[rowIdx].m_correlations[colIdx];
|
double correlation = correlationMatrixRows[rowIdx].m_correlations[colIdx];
|
||||||
auto label = QString( "%1" ).arg( correlation, 0, 'f', 2 );
|
auto label = QString( "%1" ).arg( correlation, 0, 'f', 2 );
|
||||||
cvf::Color3ub color = m_legendConfig->scalarMapper()->mapToColor( correlation );
|
|
||||||
|
cvf::Color3ub color = m_legendConfig->scalarMapper()->mapToColor( correlation );
|
||||||
QColor qColor( color.r(), color.g(), color.b() );
|
QColor qColor( color.r(), color.g(), color.b() );
|
||||||
auto rectangle = RiuQwtPlotTools::createBoxShapeT<CorrelationMatrixShapeItem>( label,
|
auto rectangle = RiuQwtPlotTools::createBoxShapeT<CorrelationMatrixShapeItem>( label,
|
||||||
(double)colIdx,
|
(double)colIdx,
|
||||||
@ -634,9 +635,15 @@ void RimCorrelationMatrixPlot::createMatrix()
|
|||||||
marker->setYValue( rowIdx + 0.5 );
|
marker->setYValue( rowIdx + 0.5 );
|
||||||
rectangle->attach( m_plotWidget );
|
rectangle->attach( m_plotWidget );
|
||||||
marker->attach( m_plotWidget );
|
marker->attach( m_plotWidget );
|
||||||
m_paramLabels[colIdx] = correlationMatrixRows[rowIdx].m_values[colIdx].name;
|
|
||||||
|
m_paramLabels[colIdx] = correlationMatrixRows[rowIdx].m_values[colIdx];
|
||||||
}
|
}
|
||||||
m_resultLabels[rowIdx] = correlationMatrixRows[rowIdx].m_key.curveDefinitionText();
|
// Remove ensemble name from label if we only have one ensemble
|
||||||
|
// If we have multiple ensembles, no labels contain the combined ensemble names.
|
||||||
|
QString resultLabel = correlationMatrixRows[rowIdx].m_key.curveDefinitionText();
|
||||||
|
resultLabel.remove( combinedEnsembleNames + ", " );
|
||||||
|
|
||||||
|
m_resultLabels[rowIdx] = resultLabel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
int topNFilterCount() const;
|
int topNFilterCount() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void matrixCellSelected( const EnsembleParameter&, const RiaSummaryCurveDefinition& );
|
void matrixCellSelected( const QString&, const RiaSummaryCurveDefinition& );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Overridden PDM methods
|
// Overridden PDM methods
|
||||||
|
@ -340,10 +340,14 @@ void RimCorrelationPlot::addDataToChartBuilder( RiuGroupedBarChartBuilder& chart
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimCorrelationPlot::updatePlotTitle()
|
void RimCorrelationPlot::updatePlotTitle()
|
||||||
{
|
{
|
||||||
if ( m_useAutoPlotTitle )
|
if ( m_useAutoPlotTitle && !ensembles().empty() )
|
||||||
{
|
{
|
||||||
m_description =
|
auto ensemble = *ensembles().begin();
|
||||||
QString( "%1 for %2 at %3" ).arg( m_correlationFactor().uiText() ).arg( m_selectedVarsUiField ).arg( timeStepString() );
|
m_description = QString( "%1 for %2, %3 at %4" )
|
||||||
|
.arg( m_correlationFactor().uiText() )
|
||||||
|
.arg( ensemble->name() )
|
||||||
|
.arg( m_selectedVarsUiField )
|
||||||
|
.arg( timeStepString() );
|
||||||
}
|
}
|
||||||
m_plotWidget->setPlotTitle( m_description );
|
m_plotWidget->setPlotTitle( m_description );
|
||||||
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && isMdiWindow() );
|
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && isMdiWindow() );
|
||||||
@ -368,7 +372,7 @@ void RimCorrelationPlot::onPlotItemSelected( QwtPlotItem* plotItem, bool toggle,
|
|||||||
{
|
{
|
||||||
if ( barTitle.text() == param.name )
|
if ( barTitle.text() == param.name )
|
||||||
{
|
{
|
||||||
emit tornadoItemSelected( param, curveDef );
|
emit tornadoItemSelected( param.name, curveDef );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public:
|
|||||||
void setTopNFilterCount( int filterCount );
|
void setTopNFilterCount( int filterCount );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tornadoItemSelected( const EnsembleParameter&, const RiaSummaryCurveDefinition& curveDef );
|
void tornadoItemSelected( const QString&, const RiaSummaryCurveDefinition& curveDef );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Overridden PDM methods
|
// Overridden PDM methods
|
||||||
|
@ -89,12 +89,12 @@ RimCorrelationReportPlot::RimCorrelationReportPlot()
|
|||||||
this->uiCapability()->setUiTreeChildrenHidden( true );
|
this->uiCapability()->setUiTreeChildrenHidden( true );
|
||||||
|
|
||||||
this->connect( m_correlationMatrixPlot(),
|
this->connect( m_correlationMatrixPlot(),
|
||||||
SIGNAL( matrixCellSelected( const EnsembleParameter&, const RiaSummaryCurveDefinition& ) ),
|
SIGNAL( matrixCellSelected( const QString&, const RiaSummaryCurveDefinition& ) ),
|
||||||
SLOT( onDataSelection( const EnsembleParameter&, const RiaSummaryCurveDefinition& ) ) );
|
SLOT( onDataSelection( const QString&, const RiaSummaryCurveDefinition& ) ) );
|
||||||
|
|
||||||
this->connect( m_correlationPlot(),
|
this->connect( m_correlationPlot(),
|
||||||
SIGNAL( tornadoItemSelected( const EnsembleParameter&, const RiaSummaryCurveDefinition& ) ),
|
SIGNAL( tornadoItemSelected( const QString&, const RiaSummaryCurveDefinition& ) ),
|
||||||
SLOT( onDataSelection( const EnsembleParameter&, const RiaSummaryCurveDefinition& ) ) );
|
SLOT( onDataSelection( const QString&, const RiaSummaryCurveDefinition& ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -405,12 +405,12 @@ QList<caf::PdmOptionItemInfo>
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimCorrelationReportPlot::onDataSelection( const EnsembleParameter& param, const RiaSummaryCurveDefinition& curveDef )
|
void RimCorrelationReportPlot::onDataSelection( const QString& paramName, const RiaSummaryCurveDefinition& curveDef )
|
||||||
{
|
{
|
||||||
m_correlationPlot->setCurveDefinitions( {curveDef} );
|
m_correlationPlot->setCurveDefinitions( {curveDef} );
|
||||||
m_correlationPlot->loadDataAndUpdate();
|
m_correlationPlot->loadDataAndUpdate();
|
||||||
m_parameterResultCrossPlot->setCurveDefinitions( {curveDef} );
|
m_parameterResultCrossPlot->setCurveDefinitions( {curveDef} );
|
||||||
m_parameterResultCrossPlot->setEnsembleParameter( param.name );
|
m_parameterResultCrossPlot->setEnsembleParameter( paramName );
|
||||||
m_parameterResultCrossPlot->loadDataAndUpdate();
|
m_parameterResultCrossPlot->loadDataAndUpdate();
|
||||||
if ( m_viewer )
|
if ( m_viewer )
|
||||||
{
|
{
|
||||||
|
@ -79,7 +79,7 @@ private:
|
|||||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||||
bool* useOptionsOnly ) override;
|
bool* useOptionsOnly ) override;
|
||||||
private slots:
|
private slots:
|
||||||
void onDataSelection( const EnsembleParameter& param, const RiaSummaryCurveDefinition& curveDef );
|
void onDataSelection( const QString& paramName, const RiaSummaryCurveDefinition& curveDef );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmProxyValueField<QString> m_plotWindowTitle;
|
caf::PdmProxyValueField<QString> m_plotWindowTitle;
|
||||||
|
@ -300,10 +300,14 @@ void RimParameterResultCrossPlot::createPoints()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimParameterResultCrossPlot::updatePlotTitle()
|
void RimParameterResultCrossPlot::updatePlotTitle()
|
||||||
{
|
{
|
||||||
if ( m_useAutoPlotTitle )
|
if ( m_useAutoPlotTitle && !ensembles().empty() )
|
||||||
{
|
{
|
||||||
m_description =
|
auto ensemble = *ensembles().begin();
|
||||||
QString( "Cross Plot %1 x %2 at %3" ).arg( m_ensembleParameter ).arg( m_selectedVarsUiField ).arg( timeStepString() );
|
m_description = QString( "Cross Plot %1, %2 x %3 at %4" )
|
||||||
|
.arg( ensemble->name() )
|
||||||
|
.arg( m_ensembleParameter )
|
||||||
|
.arg( m_selectedVarsUiField )
|
||||||
|
.arg( timeStepString() );
|
||||||
}
|
}
|
||||||
m_plotWidget->setPlotTitle( m_description );
|
m_plotWidget->setPlotTitle( m_description );
|
||||||
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && isMdiWindow() );
|
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && isMdiWindow() );
|
||||||
|
Loading…
Reference in New Issue
Block a user