mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2066 Observed Data : Detect scaling
This commit is contained in:
parent
45d3fe5eaa
commit
222bf38d58
@ -54,7 +54,8 @@ bool RifEclipseUserDataParserTools::isLineSkippable(const std::string& line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (line[found] == '1' &&
|
if (line[found] == '1' &&
|
||||||
line.find_first_not_of("1 ") == std::string::npos)
|
found == 0 &&
|
||||||
|
line.find_first_not_of("1 ", 1) == std::string::npos)
|
||||||
{
|
{
|
||||||
// Single 1 at start of file
|
// Single 1 at start of file
|
||||||
|
|
||||||
@ -715,25 +716,48 @@ std::vector<ColumnInfo> RifEclipseUserDataParserTools::columnInfoFromColumnHeade
|
|||||||
{
|
{
|
||||||
std::vector<ColumnInfo> table;
|
std::vector<ColumnInfo> table;
|
||||||
|
|
||||||
|
bool isUnitsDetected = false;
|
||||||
|
bool isScalingDetected = false;
|
||||||
|
|
||||||
|
for (auto columnLines : columnData)
|
||||||
|
{
|
||||||
|
if (columnLines.size() > 1 && isUnitText(columnLines[1]))
|
||||||
|
{
|
||||||
|
isUnitsDetected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (columnLines.size() > 2 && isScalingText(columnLines[2]))
|
||||||
|
{
|
||||||
|
isScalingDetected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto columnLines : columnData)
|
for (auto columnLines : columnData)
|
||||||
{
|
{
|
||||||
if (columnLines.size() == 0) continue;
|
if (columnLines.size() == 0) continue;
|
||||||
|
|
||||||
std::string quantity = columnLines[0];
|
std::string quantity = columnLines[0];
|
||||||
std::string unit;
|
std::string unit;
|
||||||
|
std::string scaling;
|
||||||
|
|
||||||
size_t startIndex = 1;
|
size_t startIndex = 1;
|
||||||
|
|
||||||
if (columnLines.size() > 1 &&
|
if (isUnitsDetected)
|
||||||
isUnitText(columnLines[1]))
|
|
||||||
{
|
{
|
||||||
unit = columnLines[1];
|
unit = columnLines[1];
|
||||||
|
|
||||||
startIndex = 2;
|
startIndex = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isScalingDetected)
|
||||||
|
{
|
||||||
|
scaling = columnLines[2];
|
||||||
|
|
||||||
|
startIndex = 3;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> restOfHeader;
|
std::vector<std::string> restOfHeader;
|
||||||
for (size_t i = 2; i < columnLines.size(); i++)
|
for (size_t i = startIndex; i < columnLines.size(); i++)
|
||||||
{
|
{
|
||||||
restOfHeader.push_back(columnLines[i]);
|
restOfHeader.push_back(columnLines[i]);
|
||||||
}
|
}
|
||||||
@ -848,6 +872,14 @@ bool RifEclipseUserDataParserTools::isUnitText(const std::string& word)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RifEclipseUserDataParserTools::isScalingText(const std::string& word)
|
||||||
|
{
|
||||||
|
return word.find_first_of('*') != std::string::npos;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -152,6 +152,7 @@ public:
|
|||||||
static std::vector<TableData> mergeEqualTimeSteps(const std::vector<TableData>& tables);
|
static std::vector<TableData> mergeEqualTimeSteps(const std::vector<TableData>& tables);
|
||||||
|
|
||||||
static bool isUnitText(const std::string& word);
|
static bool isUnitText(const std::string& word);
|
||||||
|
static bool isScalingText(const std::string& word);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::string trimString(const std::string& s);
|
static std::string trimString(const std::string& s);
|
||||||
|
@ -9,8 +9,7 @@
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
TEST(FixedWidthDataParser, BasicUsage)
|
TEST(FixedWidthDataParser, BasicUsage)
|
||||||
{
|
{
|
||||||
QString data = R"(
|
QString data = R"(1
|
||||||
1
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------
|
||||||
SUMMARY OF RUN NORNE_ATW2013_RFTPLT_V3 ECLIPSE 2016.2 DATESTAMP 13-DEC-2016
|
SUMMARY OF RUN NORNE_ATW2013_RFTPLT_V3 ECLIPSE 2016.2 DATESTAMP 13-DEC-2016
|
||||||
-------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -76,8 +75,7 @@ TEST(FixedWidthDataParser, ColumnData)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
TEST(FixedWidthDataParser, DetectFixedWidth)
|
TEST(FixedWidthDataParser, DetectFixedWidth)
|
||||||
{
|
{
|
||||||
QString data = R"(
|
QString data = R"(1
|
||||||
1
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------
|
||||||
SUMMARY OF RUN NORNE_ATW2013_RFTPLT_V3 ECLIPSE 2016.2 DATESTAMP 13-DEC-2016
|
SUMMARY OF RUN NORNE_ATW2013_RFTPLT_V3 ECLIPSE 2016.2 DATESTAMP 13-DEC-2016
|
||||||
-------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -204,8 +202,7 @@ TEST(FixedWidthDataParser, VaryingTimeStepCount)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
TEST(FixedWidthDataParser, HandlingOfStepType)
|
TEST(FixedWidthDataParser, HandlingOfStepType)
|
||||||
{
|
{
|
||||||
QString data = R"(
|
QString data = R"(1
|
||||||
1
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------
|
||||||
SUMMARY OF RUN NORNE_ATW2013_RFTPLT_V3 ECLIPSE 2016.2 DATESTAMP 13-DEC-2016 USER dtb MACHINE stj-lcb01-01-03
|
SUMMARY OF RUN NORNE_ATW2013_RFTPLT_V3 ECLIPSE 2016.2 DATESTAMP 13-DEC-2016 USER dtb MACHINE stj-lcb01-01-03
|
||||||
-------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -274,8 +271,7 @@ TEST(FixedWidthDataParser, HandlingOfStepType)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
TEST(FixedWidthDataParser, ParsingOfHeaderWithCompletions)
|
TEST(FixedWidthDataParser, ParsingOfHeaderWithCompletions)
|
||||||
{
|
{
|
||||||
QString data = R"(
|
QString data = R"(1
|
||||||
1
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------
|
||||||
SUMMARY OF RUN NORNE_ATW2013_RFTPLT_V3 ECLIPSE 2016.2 DATESTAMP 13-DEC-2016 USER dtb MACHINE stj-lcb01-01-03
|
SUMMARY OF RUN NORNE_ATW2013_RFTPLT_V3 ECLIPSE 2016.2 DATESTAMP 13-DEC-2016 USER dtb MACHINE stj-lcb01-01-03
|
||||||
-------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user