#2003 Observed Data : If YEARX is present, use this as basis for the time step

This commit is contained in:
Magne Sjaastad
2017-11-03 16:59:59 +01:00
parent f50760bb35
commit 7d3a547ad6
2 changed files with 22 additions and 20 deletions

View File

@@ -142,6 +142,7 @@ void RifColumnBasedUserData::buildTimeStepsFromTables()
// Find time index
size_t dateColumnIndex = tableData.columnInfos().size();
size_t dayOrYearColumnIndex = tableData.columnInfos().size();
size_t yearXColumnIndex = tableData.columnInfos().size();
for (size_t columIndex = 0; columIndex < tableData.columnInfos().size(); columIndex++)
{
@@ -151,11 +152,18 @@ void RifColumnBasedUserData::buildTimeStepsFromTables()
{
dateColumnIndex = columIndex;
}
else if (dayOrYearColumnIndex == tableData.columnInfos().size() &&
if (dayOrYearColumnIndex == tableData.columnInfos().size() &&
RifEclipseUserDataParserTools::hasTimeUnit(ci.unitName))
{
dayOrYearColumnIndex = columIndex;
}
if (yearXColumnIndex == tableData.columnInfos().size() &&
ci.summaryAddress.quantityName() == "YEARX")
{
yearXColumnIndex = columIndex;
}
}
if (dateColumnIndex == tableData.columnInfos().size() &&
@@ -181,6 +189,16 @@ void RifColumnBasedUserData::buildTimeStepsFromTables()
timeSteps.push_back(dt.toTime_t());
}
}
else if (yearXColumnIndex != tableData.columnInfos().size())
{
const ColumnInfo& ci = tableData.columnInfos()[yearXColumnIndex];
for (const auto& timeStepValue : ci.values)
{
QDateTime dateTime = RiaQDateTimeTools::fromYears(timeStepValue);
timeSteps.push_back(dateTime.toTime_t());
}
}
else
{
QDateTime startDate = RiaQDateTimeTools::epoch();
@@ -216,7 +234,6 @@ void RifColumnBasedUserData::buildTimeStepsFromTables()
timeSteps.push_back(dateTime.toTime_t());
}
}
}
}

View File

@@ -10,6 +10,7 @@
#include <QTextStream>
#include <QDebug>
#include "RifEclipseUserDataKeywordTools.h"
#include "RiaQDateTimeTools.h"
//--------------------------------------------------------------------------------------------------
///
@@ -738,25 +739,9 @@ TEST(RifKeywordBasedRsmspecParserTest, TestTimeSteps)
columnBasedUserdata.parse(data);
std::vector<time_t> timeSteps = columnBasedUserdata.timeSteps(address);
for (auto t : timeSteps)
{
QDateTime dt = QDateTime::fromTime_t(t);
QDateTime firstDate = RiaQDateTimeTools::fromYears(2014.32);
qDebug() << dt;
}
QDateTime startDate = QDateTime::fromString("01012004", "ddMMyyyy");
startDate.setTimeSpec(Qt::UTC);
QDateTime qDay1 = startDate.addDays(3043);
time_t day1 = qDay1.toTime_t();
ASSERT_EQ(size_t(18), timeSteps.size());
//EXPECT_EQ("Tue May 1 00:00:00 2012\n", (std::string)asctime(gmtime(&day1)));
//EXPECT_EQ("Tue May 1 00:00:00 2012\n", (std::string)asctime(gmtime(&timeSteps[0])));
EXPECT_EQ(day1, timeSteps[0]);
EXPECT_TRUE(firstDate == QDateTime::fromTime_t(timeSteps[0]));
}
//--------------------------------------------------------------------------------------------------