mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
#3213 Observed data import. Add categories to vector table. Modify category identification. Update unit test
This commit is contained in:
parent
1104c336aa
commit
2e8bf5aafe
@ -20,38 +20,14 @@
|
||||
|
||||
#include "RiaStdStringTools.h"
|
||||
|
||||
#include "RiuSummaryVectorDescriptionMap.h"
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QStringList>
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::set<std::string> RifEclipseSummaryAddress::KNOWN_MISC_QUANTITIES =
|
||||
{
|
||||
"CPU",
|
||||
"DATE",
|
||||
"DAY",
|
||||
"ELAPSED",
|
||||
"MLINEARS",
|
||||
"MONTH",
|
||||
"MSUMLINS",
|
||||
"MSUMNEWT",
|
||||
"NEWTON",
|
||||
"STEPTYPE",
|
||||
"TCPU",
|
||||
"TCPUDAY",
|
||||
"TCPUTS",
|
||||
"TELAPLIN",
|
||||
"TIME",
|
||||
"TIMESTEP",
|
||||
"TIMESTRY",
|
||||
"YEAR",
|
||||
"YEARS"
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -307,34 +283,16 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromEclipseTextAddress(const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifEclipseSummaryAddress::SummaryVarCategory RifEclipseSummaryAddress::identifyCategory(const std::string& quantityName)
|
||||
{
|
||||
if (quantityName.size() < 3 ||
|
||||
quantityName.size() > 8 ||
|
||||
(quantityName.size() > 5 && quantityName.size() < 8)) return SUMMARY_INVALID;
|
||||
if (quantityName.size() < 3 || quantityName.size() > 8) return SUMMARY_INVALID;
|
||||
|
||||
QRegExp regexp("^[A-Za-z0-9_\\-]*$");
|
||||
QRegExp regexp("^[A-Za-z0-9_\\-+#]*$");
|
||||
if(!regexp.exactMatch(QString::fromStdString(quantityName))) return SUMMARY_INVALID;
|
||||
|
||||
if (quantityName.size() > 2 && quantityName[0] == 'R' && quantityName[2] == 'F')
|
||||
{
|
||||
return SUMMARY_REGION_2_REGION;
|
||||
}
|
||||
|
||||
if (KNOWN_MISC_QUANTITIES.count(baseQuantityName(quantityName)) > 0) return SUMMARY_MISC;
|
||||
|
||||
char firstLetter = quantityName.at(0);
|
||||
|
||||
if (firstLetter == 'A') return SUMMARY_AQUIFER;
|
||||
if (firstLetter == 'B') return SUMMARY_BLOCK;
|
||||
if (firstLetter == 'C') return SUMMARY_WELL_COMPLETION;
|
||||
if (firstLetter == 'F') return SUMMARY_FIELD;
|
||||
if (firstLetter == 'G') return SUMMARY_WELL_GROUP;
|
||||
if (firstLetter == 'N') return SUMMARY_NETWORK;
|
||||
if (firstLetter == 'R') return SUMMARY_REGION;
|
||||
if (firstLetter == 'S') return SUMMARY_WELL_SEGMENT;
|
||||
if (firstLetter == 'W') return SUMMARY_WELL;
|
||||
|
||||
if (quantityName.size() < 2) return SUMMARY_INVALID;
|
||||
// First, try to lookup vector in vector table
|
||||
auto vectorInfo = RiuSummaryVectorDescriptionMap::instance()->vectorInfo(quantityName);
|
||||
if (vectorInfo.category != SUMMARY_INVALID) return vectorInfo.category;
|
||||
|
||||
// Then check LGR categories
|
||||
std::string firstTwoLetters = quantityName.substr(0, 2);
|
||||
|
||||
if (firstTwoLetters == "LB") return SUMMARY_BLOCK_LGR;
|
||||
|
@ -74,8 +74,6 @@ public:
|
||||
INPUT_VECTOR_NAME,
|
||||
};
|
||||
|
||||
static const std::set<std::string> KNOWN_MISC_QUANTITIES;
|
||||
|
||||
public:
|
||||
|
||||
RifEclipseSummaryAddress() :
|
||||
|
@ -239,7 +239,7 @@ QString RimSummaryPlotYAxisFormatter::autoAxisTitle() const
|
||||
{
|
||||
if (m_axisProperties->showDescription())
|
||||
{
|
||||
quantityNameForDisplay = RiuSummaryVectorDescriptionMap::instance()->fieldInfo(quantityName);
|
||||
quantityNameForDisplay = RiuSummaryVectorDescriptionMap::instance()->vectorLongName(quantityName, true);
|
||||
}
|
||||
|
||||
if (m_axisProperties->showAcronym())
|
||||
|
@ -120,7 +120,7 @@ QString RimSummaryPlotNameHelper::plotTitle() const
|
||||
if (!m_titleQuantity.empty())
|
||||
{
|
||||
if (!title.isEmpty()) title += ", ";
|
||||
title += QString::fromStdString(RiuSummaryVectorDescriptionMap::instance()->fieldInfo(m_titleQuantity));
|
||||
title += QString::fromStdString(RiuSummaryVectorDescriptionMap::instance()->vectorLongName(m_titleQuantity, true));
|
||||
}
|
||||
|
||||
if (title.isEmpty())
|
||||
|
@ -10,14 +10,37 @@ TEST(RiuSummaryVectorDescriptionMap, TestInit)
|
||||
{
|
||||
{
|
||||
std::string s("SRSFC");
|
||||
auto test = RiuSummaryVectorDescriptionMap::instance()->fieldInfo(s);
|
||||
auto test = RiuSummaryVectorDescriptionMap::instance()->vectorInfo(s);
|
||||
|
||||
EXPECT_TRUE(test.category == RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT);
|
||||
EXPECT_TRUE(test.longName == "Reach brine concentration");
|
||||
}
|
||||
|
||||
{
|
||||
std::string s("SRSFC");
|
||||
auto test = RiuSummaryVectorDescriptionMap::instance()->vectorLongName(s);
|
||||
|
||||
EXPECT_TRUE(test == "Reach brine concentration");
|
||||
}
|
||||
|
||||
{
|
||||
std::string s("does not exist");
|
||||
auto test = RiuSummaryVectorDescriptionMap::instance()->fieldInfo(s);
|
||||
auto test = RiuSummaryVectorDescriptionMap::instance()->vectorInfo(s);
|
||||
|
||||
EXPECT_TRUE(test.category == RifEclipseSummaryAddress::SUMMARY_INVALID);
|
||||
EXPECT_TRUE(test.longName == "");
|
||||
}
|
||||
|
||||
{
|
||||
std::string s("does not exist");
|
||||
auto test = RiuSummaryVectorDescriptionMap::instance()->vectorLongName(s);
|
||||
|
||||
EXPECT_TRUE(test == "");
|
||||
}
|
||||
|
||||
{
|
||||
std::string s("does not exist");
|
||||
auto test = RiuSummaryVectorDescriptionMap::instance()->vectorLongName(s, true);
|
||||
|
||||
EXPECT_TRUE(test == s);
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ QList<caf::PdmOptionItemInfo> RiuSummaryCurveDefSelection::calculateValueOptions
|
||||
|
||||
if (isVectorField)
|
||||
{
|
||||
std::string longVectorName = RiuSummaryVectorDescriptionMap::instance()->fieldInfo(itemName);
|
||||
std::string longVectorName = RiuSummaryVectorDescriptionMap::instance()->vectorLongName(itemName, true);
|
||||
displayName = QString::fromStdString(longVectorName);
|
||||
displayName += QString(" (%1)").arg(QString::fromStdString(itemName));
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,10 +18,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
|
||||
class RiuSummaryVectorInfo
|
||||
{
|
||||
public:
|
||||
RiuSummaryVectorInfo() : category(RifEclipseSummaryAddress::SUMMARY_INVALID) {}
|
||||
RiuSummaryVectorInfo(RifEclipseSummaryAddress::SummaryVarCategory category, const std::string& longName)
|
||||
: category(category), longName(longName) {}
|
||||
|
||||
RifEclipseSummaryAddress::SummaryVarCategory category;
|
||||
std::string longName;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -30,12 +43,15 @@ class RiuSummaryVectorDescriptionMap
|
||||
public:
|
||||
static RiuSummaryVectorDescriptionMap* instance();
|
||||
|
||||
std::string fieldInfo(const std::string& field);
|
||||
RiuSummaryVectorInfo vectorInfo(const std::string& vectorName);
|
||||
std::string vectorLongName(const std::string& vectorName,
|
||||
bool returnVectorNameIfNotFound = false);
|
||||
RifEclipseSummaryAddress::SummaryVarCategory vectorCategory(const std::string& vectorName);
|
||||
|
||||
private:
|
||||
RiuSummaryVectorDescriptionMap();
|
||||
void populateFieldToInfoMap();
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> m_summaryToDescMap;
|
||||
std::map<std::string, RiuSummaryVectorInfo> m_summaryToDescMap;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user