From e9a938ce78c75cb739932d887d4d91d17bd64210 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 7 Nov 2017 12:33:22 +0100 Subject: [PATCH] #2003 Observed Data : Compare first time step when merging --- .../RifEclipseUserDataParserTools.cpp | 38 +++++++++++++++--- .../UnitTests/FixedWidthDataParser-Test.cpp | 39 +++++++++++++++++++ 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseUserDataParserTools.cpp b/ApplicationCode/FileInterface/RifEclipseUserDataParserTools.cpp index 15a3516621..e2be0b1a19 100644 --- a/ApplicationCode/FileInterface/RifEclipseUserDataParserTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseUserDataParserTools.cpp @@ -813,17 +813,22 @@ std::vector RifEclipseUserDataParserTools::mergeEqualTimeSteps(const if (tables[0].columnInfos().size() == 0) return tables; - ColumnInfo* dateColumn = nullptr; + QDateTime firstTableStartTime; for (auto c : tables[0].columnInfos()) { if (c.summaryAddress.quantityName() == "DATE") { - dateColumn = &c; + if (c.stringValues.size() > 0) + { + firstTableStartTime = RiaDateStringParser::parseDateString(c.stringValues[0]); + } } } - // Support only merge of tables with the DATE column present - if (!dateColumn) return tables; + if (!firstTableStartTime.isValid()) + { + return tables; + } std::vector largeTables; @@ -834,8 +839,31 @@ std::vector RifEclipseUserDataParserTools::mergeEqualTimeSteps(const for (size_t i = 1; i < tables.size(); i++) { + bool isDatesEqual = true; + + if (firstTableStartTime.isValid()) + { + QDateTime tableFirstTime; + for (auto& c : tables[i].columnInfos()) + { + if (c.summaryAddress.quantityName() == "DATE") + { + if (c.stringValues.size() > 0) + { + tableFirstTime = RiaDateStringParser::parseDateString(c.stringValues[0]); + } + } + } + + if (firstTableStartTime != tableFirstTime) + { + isDatesEqual = false; + } + } + if (tables[i].columnInfos().size() > 0 && - tables[i].columnInfos()[0].itemCount() == itemsInFirstTable) + tables[i].columnInfos()[0].itemCount() == itemsInFirstTable && + isDatesEqual) { for (auto& c : tables[i].columnInfos()) { diff --git a/ApplicationCode/UnitTests/FixedWidthDataParser-Test.cpp b/ApplicationCode/UnitTests/FixedWidthDataParser-Test.cpp index e7bea917d3..276c9d9003 100644 --- a/ApplicationCode/UnitTests/FixedWidthDataParser-Test.cpp +++ b/ApplicationCode/UnitTests/FixedWidthDataParser-Test.cpp @@ -331,3 +331,42 @@ TEST(FixedWidthDataParser, ParsingOfHeaderWithCompletions) EXPECT_EQ(size_t(10), colHeaders.size()); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(FixedWidthDataParser, DifferentStartDate) +{ + QString data = + "1 \n" + " -------------------------------------------------------------------------------------------------------------------------------\n" + " SUMMARY OF RUN NORNE_ATW2013_RFTPLT_V3 ECLIPSE 2016.2 DATESTAMP 13-DEC-2016 \n" + " -------------------------------------------------------------------------------------------------------------------------------\n" + " DATE YEARS NEWTON MLINEARS DAY MONTH YEAR NEWTON TCPU ELAPSED \n" + " YEARS SECONDS SECONDS \n" + " \n" + " \n" + " -------------------------------------------------------------------------------------------------------------------------------\n" + " 6-NOV-1997 0 0 0 6 11 1997 0 4.880000 9.720000 \n" + " 7-NOV-1997 0.002738 3 28 7 11 1997 3 5.240000 10.11000 \n" + " 8-NOV-1997 0.006556 4 42 8 11 1997 4 5.730000 10.60000 \n" + "1 \n" + " -------------------------------------------------------------------------------------------------------------------------------\n" + " SUMMARY OF RUN NORNE_ATW2013_RFTPLT_V3 ECLIPSE 2016.2 DATESTAMP 13-DEC-2016 \n" + " -------------------------------------------------------------------------------------------------------------------------------\n" + " DATE RGIR RGPR RGIPG RGIPL RGIT RGPT RWIR RWPR RWPT \n" + " SM3/DAY SM3/DAY SM3 SM3 SM3 SM3 SM3/DAY SM3/DAY SM3 \n" + " *10**3 *10**3 *10**3 *10**3 \n" + " \n" + " 1 1 1 1 1 1 1 1 1 \n" + " -------------------------------------------------------------------------------------------------------------------------------\n" + " 7-NOV-1997 0 2396930. 5424424. 591498.1 0 2396.930 0 -21.6173 -21.6173 \n" + " 8-NOV-1997 0 -250487. 5423940. 591966.2 0 2047.598 0 -11124.0 -15535.3 \n" + " 9-NOV-1997 0 2829432. 5421400. 591952.3 0 4812.102 0 -17.8744 -15552.8 \n" + ; + + RifColumnBasedUserDataParser parser(data); + auto tables = parser.tableData(); + EXPECT_EQ(size_t(2), tables.size()); +} +