#14964: Use correct depth unit when creating RFT plots

Read the summary unit system from SMSPEC INTEHEAD, and fall back to vector
units for ESMRY files without SMSPEC. The unit system is read on first
request to keep summary import fast. Ensembles use the same realization as
for addresses. New RFT plots get the depth unit from their data sources.
This commit is contained in:
Magne Sjaastad authored and GitHub committed 2026-10-19 14:15:55 +02:00
1 parent eb66255a70
commit 9229e48191
12 files changed
+230 -8

No files matched your search

@@ -23,11 +23,14 @@
#include "RiaPreferencesSummary.h"
#include "RiaQStringFormatter.h"
#include "RifEclipseOutputFileTools.h"
#ifdef _MSC_VER
// Disable warning from external library to make sure treat warnings as error works
#pragma warning( disable : 4267 )
#endif
#include "opm/io/eclipse/ESmry.hpp"
#include "opm/io/eclipse/EclFile.hpp"
#include "opm/io/eclipse/ExtESmry.hpp"
#include <QFile>
@@ -222,6 +225,33 @@ bool RifOpmSummaryTools::isEsmryConversionRequired( const QString& fileName )
return false;
}
//--------------------------------------------------------------------------------------------------
/// The unit system is stored in INTEHEAD[0] of the SMSPEC file
//--------------------------------------------------------------------------------------------------
RiaDefines::EclipseUnitSystem RifOpmSummaryTools::readUnitSystem( const QString& smspecFileName )
{
if ( !QFile::exists( smspecFileName ) ) return RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
try
{
Opm::EclIO::EclFile smspecFile( smspecFileName.toStdString() );
if ( smspecFile.hasKey( "INTEHEAD" ) )
{
const auto& intehead = smspecFile.get<int>( "INTEHEAD" );
if ( !intehead.empty() )
{
return RifEclipseOutputFileTools::unitValueToEnum( intehead[0] ).value_or( RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN );
}
}
}
catch ( const std::exception& e )
{
RiaLogging::debug( QString( "Failed to read unit system from %1: %2" ).arg( smspecFileName, e.what() ).toStdString() );
}
return RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------