#8316 Summary vector names: Use stripped quantity name to find category

This commit is contained in:
Magne Sjaastad 2021-11-25 17:42:03 +01:00
parent fe93d437ec
commit 5d96a98b06
5 changed files with 39 additions and 19 deletions

View File

@ -160,18 +160,20 @@ RifEclipseSummaryAddress::SummaryVarCategory RifEclipseSummaryAddress::identifyC
{
if ( quantityName.size() < 3 || quantityName.size() > 8 ) return SUMMARY_INVALID;
auto strippedQuantityName = baseQuantityName( quantityName );
// First, try to lookup vector in vector table
auto category = RiuSummaryQuantityNameInfoProvider::instance()->categoryFromQuantityName( quantityName );
auto category = RiuSummaryQuantityNameInfoProvider::instance()->categoryFromQuantityName( strippedQuantityName );
if ( category != SUMMARY_INVALID ) return category;
// Then check LGR categories
std::string firstTwoLetters = quantityName.substr( 0, 2 );
std::string firstTwoLetters = strippedQuantityName.substr( 0, 2 );
if ( firstTwoLetters == "LB" ) return SUMMARY_BLOCK_LGR;
if ( firstTwoLetters == "LC" ) return SUMMARY_WELL_COMPLETION_LGR;
if ( firstTwoLetters == "LW" ) return SUMMARY_WELL_LGR;
if ( quantityName[0] == 'N' ) return SUMMARY_NETWORK;
if ( strippedQuantityName[0] == 'N' ) return SUMMARY_NETWORK;
return SUMMARY_INVALID;
}
@ -721,7 +723,7 @@ bool RifEclipseSummaryAddress::hasAccumulatedData() const
quantityForInspection = quantityForInspection.mid( quantityForInspection.indexOf( ":" ) + 1 );
}
QString qBaseName = baseQuantityName( quantityForInspection );
QString qBaseName = QString::fromStdString( baseQuantityName( quantityForInspection.toStdString() ) );
if ( qBaseName.endsWith( "WCT" ) || qBaseName.endsWith( "WCTH" ) )
{
@ -904,19 +906,19 @@ bool RifEclipseSummaryAddress::isValidEclipseCategory() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RifEclipseSummaryAddress::baseQuantityName( const QString& quantityName )
std::string RifEclipseSummaryAddress::baseQuantityName( const std::string& quantityName )
{
QString qBaseName = quantityName;
auto tmpString = quantityName;
if ( qBaseName.size() == 8 ) qBaseName.chop( 3 );
if ( tmpString.size() == 8 ) tmpString = tmpString.substr( 0, 5 );
auto indexToUnderScore = qBaseName.indexOf( "_" );
if ( indexToUnderScore > 0 )
auto indexToUnderscore = tmpString.find_first_of( '_' );
if ( indexToUnderscore > 0 )
{
qBaseName = qBaseName.left( indexToUnderScore );
tmpString = tmpString.substr( 0, indexToUnderscore );
}
return qBaseName;
return tmpString;
}
//--------------------------------------------------------------------------------------------------

View File

@ -208,7 +208,7 @@ public:
bool hasAccumulatedData() const;
static QString baseQuantityName( const QString& quantityName );
static std::string baseQuantityName( const std::string& quantityName );
private:
static RifEclipseSummaryAddress fromTokens( const std::vector<std::string>& tokens );

View File

@ -392,9 +392,18 @@ std::pair<std::set<RifEclipseSummaryAddress>, std::map<RifEclipseSummaryAddress,
std::set<RifEclipseSummaryAddress> addresses;
std::map<RifEclipseSummaryAddress, std::string> addressToNodeIndexMap;
std::vector<std::string> invalidKeywords;
for ( const auto& keyword : keywords )
{
auto eclAdr = RifEclipseSummaryAddress::fromEclipseTextAddress( keyword );
if ( !eclAdr.isValid() )
{
invalidKeywords.push_back( keyword );
// If a category is not found, use the MISC category
eclAdr = RifEclipseSummaryAddress::miscAddress( keyword );
}
if ( eclAdr.isValid() )
{
@ -403,5 +412,14 @@ std::pair<std::set<RifEclipseSummaryAddress>, std::map<RifEclipseSummaryAddress,
}
}
// DEBUG code
// Used to print keywords not being categorized correctly
/*
for ( const auto& kw : invalidKeywords )
{
RiaLogging::warning( QString::fromStdString( kw ) );
}
*/
return { addresses, addressToNodeIndexMap };
}

View File

@ -299,27 +299,27 @@ TEST( RifEclipseSummaryAddressTest, TestQuantityNameManipulations )
{
{
auto s = RifEclipseSummaryAddress::baseQuantityName( "FOPT" );
EXPECT_EQ( "FOPT", s.toStdString() );
EXPECT_EQ( "FOPT", s );
}
{
auto s = RifEclipseSummaryAddress::baseQuantityName( "FOPT_1" );
EXPECT_EQ( "FOPT", s.toStdString() );
EXPECT_EQ( "FOPT", s );
}
{
auto s = RifEclipseSummaryAddress::baseQuantityName( "FOPR" );
EXPECT_EQ( "FOPR", s.toStdString() );
EXPECT_EQ( "FOPR", s );
}
{
auto s = RifEclipseSummaryAddress::baseQuantityName( "FOPR_1" );
EXPECT_EQ( "FOPR", s.toStdString() );
EXPECT_EQ( "FOPR", s );
}
{
// https://github.com/OPM/ResInsight/issues/6481
auto s = RifEclipseSummaryAddress::baseQuantityName( "FCMIT_1" );
EXPECT_EQ( "FCMIT", s.toStdString() );
EXPECT_EQ( "FCMIT", s );
}
}

View File

@ -37,9 +37,9 @@ def test_summary_data(rips_instance, initialize_test):
assert summary_case.id == 1
addresses = summary_case.available_addresses()
# Summary reader type is controlled from Preferences. libecl reports 343 vectors, opm_common (ESMRY) reports 310.
# Summary reader type is controlled from Preferences. libecl reports 343 vectors, opm_common (ESMRY) reports 339.
# As this configuration can be different, allow both variants
assert len(addresses.values) == 343 or len(addresses.values) == 310
assert len(addresses.values) == 343 or len(addresses.values) == 339
summary_data = summary_case.summary_vector_values("FOPT")
assert len(summary_data.values) == 60