mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1966 Observed Data : Use first item in DATE column as startdate for YEARS
This commit is contained in:
@@ -66,19 +66,42 @@ bool RifColumnBasedUserData::parse(const QString& data, const QString& customWel
|
||||
|
||||
for (size_t tableIndex = 0; tableIndex < m_parser->tables().size(); tableIndex++)
|
||||
{
|
||||
size_t timeColumnIndex = m_parser->tables()[tableIndex].size();
|
||||
|
||||
// Find time index
|
||||
size_t dateColumnIndex = m_parser->tables()[tableIndex].size();
|
||||
size_t dayOrYearColumnIndex = m_parser->tables()[tableIndex].size();
|
||||
|
||||
for (size_t columIndex = 0; columIndex < m_parser->tables()[tableIndex].size(); columIndex++)
|
||||
{
|
||||
const ColumnInfo& ci = m_parser->tables()[tableIndex][columIndex];
|
||||
if (!ci.isAVector)
|
||||
{
|
||||
timeColumnIndex = columIndex;
|
||||
break;
|
||||
QString unit = QString::fromStdString(ci.unitName).trimmed().toUpper();
|
||||
if (unit == "DATE" ||
|
||||
unit == "DATES")
|
||||
{
|
||||
dateColumnIndex = columIndex;
|
||||
}
|
||||
else if (unit == "DAY" ||
|
||||
unit == "DAYS" ||
|
||||
unit == "YEAR" ||
|
||||
unit == "YEARS")
|
||||
{
|
||||
dayOrYearColumnIndex = columIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t timeColumnIndex = m_parser->tables()[tableIndex].size();
|
||||
if (dayOrYearColumnIndex < m_parser->tables()[tableIndex].size())
|
||||
{
|
||||
timeColumnIndex = dayOrYearColumnIndex;
|
||||
}
|
||||
else if (dateColumnIndex < m_parser->tables()[tableIndex].size())
|
||||
{
|
||||
timeColumnIndex = dateColumnIndex;
|
||||
}
|
||||
|
||||
if (timeColumnIndex == m_parser->tables()[tableIndex].size())
|
||||
{
|
||||
RiaLogging::warning(QString("Failed to find time data for table %1 in file %2").arg(tableIndex));
|
||||
@@ -88,16 +111,23 @@ bool RifColumnBasedUserData::parse(const QString& data, const QString& customWel
|
||||
{
|
||||
const ColumnInfo& ci = m_parser->tables()[tableIndex][timeColumnIndex];
|
||||
QDateTime startDate;
|
||||
QString startDateString = QString::fromStdString(ci.startDate);
|
||||
if (!startDateString.isEmpty())
|
||||
if (ci.startQDateTime.isValid())
|
||||
{
|
||||
QString dateFormatString = "ddMMyyyy";
|
||||
|
||||
startDate = RiaQDateTimeTools::fromString(startDateString, dateFormatString);
|
||||
startDate = ci.startQDateTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
startDate = RiaQDateTimeTools::epoch();
|
||||
QString startDateString = QString::fromStdString(ci.startDateString);
|
||||
if (!startDateString.isEmpty())
|
||||
{
|
||||
QString dateFormatString = "ddMMyyyy";
|
||||
|
||||
startDate = RiaQDateTimeTools::fromString(startDateString, dateFormatString);
|
||||
}
|
||||
else
|
||||
{
|
||||
startDate = RiaQDateTimeTools::epoch();
|
||||
}
|
||||
}
|
||||
|
||||
m_timeSteps.resize(m_timeSteps.size() + 1);
|
||||
|
||||
Reference in New Issue
Block a user