mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 06:38:13 -05:00
When the summary plot time axis is configured to show time from simulation start, the text produced by Show Plot Data and the ASCII export now reports the same values instead of date and time. The time column header becomes "Time [<unit>]", and each row reports the elapsed time relative to the first time step of the first curve, scaled to the display unit selected on the time axis. Plots using the date based time axis are unchanged. Time in months and years is computed using calendar arithmetic instead of a fixed number of seconds per unit, so a time step exactly N calendar months or years after the simulation start reports exactly N. This makes resampled data report whole numbers also when a leap year is part of the interval. The calendar arithmetic is available as RiaQDateTimeTools::calendarYearsBetween() and calendarMonthsBetween(), and is used both when plotting the curves and when reporting the time column.
46 lines
1.7 KiB
C++
46 lines
1.7 KiB
C++
#include "gtest/gtest.h"
|
|
|
|
#include "RimSummaryTimeAxisProperties.h"
|
|
|
|
#include "RiaQDateTimeTools.h"
|
|
|
|
#include <QDate>
|
|
|
|
namespace
|
|
{
|
|
QDateTime utcTime( int year, int month, int day )
|
|
{
|
|
return RiaQDateTimeTools::createUtcDateTime( QDate( year, month, day ) );
|
|
}
|
|
} // namespace
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
/// MONTHS and YEARS use calendar arithmetic, the shorter units are a plain scaling of the number of
|
|
/// seconds since the simulation start.
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RimSummaryTimeAxisPropertiesTest, TimeFromSimulationStart )
|
|
{
|
|
const QDateTime start = utcTime( 2000, 1, 1 );
|
|
|
|
// 2000 is a leap year, a fixed seconds per year scaling would report 1.002074 years
|
|
EXPECT_NEAR( 1.0,
|
|
RimSummaryTimeAxisProperties::timeFromSimulationStart( start, utcTime( 2001, 1, 1 ), RimSummaryTimeAxisProperties::YEARS ),
|
|
1e-9 );
|
|
|
|
EXPECT_NEAR( 12.0,
|
|
RimSummaryTimeAxisProperties::timeFromSimulationStart( start, utcTime( 2001, 1, 1 ), RimSummaryTimeAxisProperties::MONTHS ),
|
|
1e-9 );
|
|
|
|
EXPECT_NEAR( 366.0,
|
|
RimSummaryTimeAxisProperties::timeFromSimulationStart( start, utcTime( 2001, 1, 1 ), RimSummaryTimeAxisProperties::DAYS ),
|
|
1e-9 );
|
|
|
|
EXPECT_NEAR( 24.0,
|
|
RimSummaryTimeAxisProperties::timeFromSimulationStart( start, utcTime( 2000, 1, 2 ), RimSummaryTimeAxisProperties::HOURS ),
|
|
1e-9 );
|
|
|
|
EXPECT_NEAR( 86400.0,
|
|
RimSummaryTimeAxisProperties::timeFromSimulationStart( start, utcTime( 2000, 1, 2 ), RimSummaryTimeAxisProperties::SECONDS ),
|
|
1e-9 );
|
|
}
|