#2003 Observed Data : Compare first time step when merging

This commit is contained in:
Magne Sjaastad 2017-11-07 12:33:22 +01:00
parent b022492bc1
commit e9a938ce78
2 changed files with 72 additions and 5 deletions

View File

@ -813,17 +813,22 @@ std::vector<TableData> 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<TableData> largeTables;
@ -834,8 +839,31 @@ std::vector<TableData> 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())
{

View File

@ -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());
}