mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1831 SourSimRL: Missing hour minute information from HDF file
Read days as a double value, multiply by seconds in a day and use addSeconds to get corret time (including seconds) from HDF
This commit is contained in:
parent
c736e10ad5
commit
d1dbb89757
@ -117,9 +117,10 @@ std::vector<QDateTime> RifHdf5Reader::timeSteps() const
|
||||
|
||||
std::string dateString = getStringAttribute(mainFile, "/KaseStudy/TransientSections", "initial_date");
|
||||
|
||||
|
||||
QDateTime dtInitial = sourSimDateTimeToQDateTime(dateString);
|
||||
|
||||
int secondsPerDay = 60 * 60 * 24;
|
||||
|
||||
for (size_t i = 0; i < m_timeStepFileNames.size(); i++)
|
||||
{
|
||||
std::string fileName = m_timeStepFileNames[i];
|
||||
@ -128,11 +129,12 @@ std::vector<QDateTime> RifHdf5Reader::timeSteps() const
|
||||
H5::H5File file(fileName.c_str(), H5F_ACC_RDONLY);
|
||||
|
||||
double timeStepValue = getDoubleAttribute(file, timeStepGroup, "timestep"); // Assumes only one time step per file
|
||||
int timeStepDays = cvf::Math::floor(timeStepValue); // NB: open question: unit of SourSimRL time step values, days?
|
||||
int seconds = timeStepValue * secondsPerDay;
|
||||
|
||||
QDateTime dt = dtInitial;
|
||||
dt = dt.addSecs(seconds);
|
||||
|
||||
times.push_back(dt.addDays(timeStepDays)); // NB: open question: unit of SourSimRL time step values, days?
|
||||
times.push_back(dt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -499,14 +499,14 @@ void RifReaderEclipseOutput::setHdf5FileName(const QString& fileName)
|
||||
for (size_t i = 0; i < timeStepInfos.size(); i++)
|
||||
{
|
||||
size_t indexOnFile = timeStepIndexOnFile(i);
|
||||
QString dateStr("yyyy.MMM.ddd hh:mm");
|
||||
QString dateStr("yyyy.MMM.ddd hh:mm:ss");
|
||||
|
||||
if (!isEclipseAndSoursimTimeStepsEqual(hdfTimeSteps[indexOnFile], timeStepInfos[i].m_date))
|
||||
{
|
||||
RiaLogging::error("HDF: Time steps does not match");
|
||||
|
||||
RiaLogging::error(QString("HDF: Eclipse date %1").arg(timeStepInfos[i].m_date.toString(dateStr)));
|
||||
RiaLogging::error(QString("HDF: HDF date %1").arg(hdfTimeSteps[i].toString(dateStr)));
|
||||
RiaLogging::error(QString("HDF: HDF date %1").arg(hdfTimeSteps[indexOnFile].toString(dateStr)));
|
||||
|
||||
isTimeStampsEqual = false;
|
||||
}
|
||||
@ -1973,12 +1973,18 @@ std::vector<RigEclipseTimeStepInfo> RifReaderEclipseOutput::createFilteredTimeSt
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifReaderEclipseOutput::isEclipseAndSoursimTimeStepsEqual(const QDateTime& dt1, const QDateTime& dt2)
|
||||
bool RifReaderEclipseOutput::isEclipseAndSoursimTimeStepsEqual(const QDateTime& eclipseDateTime, const QDateTime& sourSimDateTime)
|
||||
{
|
||||
// Currently, HDF files do not contain hours and minutes
|
||||
// Only compare date, and skip hour/minutes
|
||||
// Compare date down to and including seconds
|
||||
// Compare of complete date time objects will often result in differences
|
||||
|
||||
return dt1.date() == dt2.date();
|
||||
if (eclipseDateTime.date() != sourSimDateTime.date()) return false;
|
||||
|
||||
if (eclipseDateTime.time().hour() != sourSimDateTime.time().hour()) return false;
|
||||
if (eclipseDateTime.time().minute() != sourSimDateTime.time().minute()) return false;
|
||||
if (eclipseDateTime.time().second() != sourSimDateTime.time().second()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -91,7 +91,7 @@ private:
|
||||
|
||||
std::vector<RigEclipseTimeStepInfo> createFilteredTimeStepInfos();
|
||||
|
||||
static bool isEclipseAndSoursimTimeStepsEqual(const QDateTime& dt1, const QDateTime& dt2);
|
||||
static bool isEclipseAndSoursimTimeStepsEqual(const QDateTime& eclipseDateTime, const QDateTime& sourSimDateTime);
|
||||
|
||||
private:
|
||||
QString m_fileName; // Name of file used to start accessing Eclipse output files
|
||||
|
Loading…
Reference in New Issue
Block a user