mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#10210 Reveal Summary Import: map reveal names to eclipse names.
This gives better behavior in summary plot (correct phase colors and better default axis grouping). Fixes #10210.
This commit is contained in:
parent
dd05380039
commit
22e9e7aeb0
@ -85,10 +85,12 @@ RifCsvUserDataParser::~RifCsvUserDataParser()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifCsvUserDataParser::parse( const AsciiDataParseOptions& parseOptions, const std::map<QString, std::pair<QString, double>>& unitMapping )
|
||||
bool RifCsvUserDataParser::parse( const AsciiDataParseOptions& parseOptions,
|
||||
const std::map<QString, QString>& nameMapping,
|
||||
const std::map<QString, std::pair<QString, double>>& unitMapping )
|
||||
{
|
||||
if ( determineCsvLayout() == LineBased ) return parseLineBasedData();
|
||||
return parseColumnBasedData( parseOptions, unitMapping );
|
||||
return parseColumnBasedData( parseOptions, nameMapping, unitMapping );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -305,6 +307,7 @@ RifCsvUserDataParser::CsvLayout RifCsvUserDataParser::determineCsvLayout()
|
||||
bool RifCsvUserDataParser::parseColumnInfo( QTextStream* dataStream,
|
||||
const AsciiDataParseOptions& parseOptions,
|
||||
std::vector<Column>* columnInfoList,
|
||||
const std::map<QString, QString>& nameMapping,
|
||||
const std::map<QString, std::pair<QString, double>>& unitMapping )
|
||||
{
|
||||
bool headerFound = false;
|
||||
@ -396,6 +399,11 @@ bool RifCsvUserDataParser::parseColumnInfo( QTextStream*
|
||||
colName = RiaTextStringTools::trimAndRemoveDoubleSpaces( colName.remove( fullCapture ) );
|
||||
}
|
||||
|
||||
if ( auto it = nameMapping.find( colName ); it != nameMapping.end() )
|
||||
{
|
||||
colName = it->second;
|
||||
}
|
||||
|
||||
if ( iCol < names.size() )
|
||||
{
|
||||
QString name = RiaTextStringTools::trimAndRemoveDoubleSpaces( names[iCol] );
|
||||
@ -440,6 +448,7 @@ bool RifCsvUserDataParser::parseColumnInfo( QTextStream*
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifCsvUserDataParser::parseColumnBasedData( const AsciiDataParseOptions& parseOptions,
|
||||
const std::map<QString, QString>& nameMapping,
|
||||
const std::map<QString, std::pair<QString, double>>& unitMapping )
|
||||
{
|
||||
bool errors = false;
|
||||
@ -454,7 +463,7 @@ bool RifCsvUserDataParser::parseColumnBasedData( const AsciiDataParseOptions&
|
||||
QTextStream* dataStream = openDataStream();
|
||||
|
||||
// Parse header
|
||||
if ( !parseColumnInfo( dataStream, parseOptions, &columnInfoList, unitMapping ) )
|
||||
if ( !parseColumnInfo( dataStream, parseOptions, &columnInfoList, nameMapping, unitMapping ) )
|
||||
{
|
||||
if ( m_errorText ) m_errorText->append( "CSV import: Failed to parse header columns" );
|
||||
return false;
|
||||
|
@ -50,7 +50,9 @@ public:
|
||||
RifCsvUserDataParser( QString* errorText = nullptr );
|
||||
virtual ~RifCsvUserDataParser();
|
||||
|
||||
bool parse( const AsciiDataParseOptions& parseOptions, const std::map<QString, std::pair<QString, double>>& unitMapping = {} );
|
||||
bool parse( const AsciiDataParseOptions& parseOptions,
|
||||
const std::map<QString, QString>& nameMapping = {},
|
||||
const std::map<QString, std::pair<QString, double>>& unitMapping = {} );
|
||||
const TableData& tableData() const;
|
||||
|
||||
const Column* columnInfo( size_t columnIndex ) const;
|
||||
@ -77,8 +79,10 @@ private:
|
||||
bool parseColumnInfo( QTextStream* dataStream,
|
||||
const AsciiDataParseOptions& parseOptions,
|
||||
std::vector<Column>* columnInfoList,
|
||||
const std::map<QString, QString>& nameMapping = {},
|
||||
const std::map<QString, std::pair<QString, double>>& unitMapping = {} );
|
||||
bool parseColumnBasedData( const AsciiDataParseOptions& parseOptions,
|
||||
const std::map<QString, QString>& nameMapping = {},
|
||||
const std::map<QString, std::pair<QString, double>>& unitMapping = {} );
|
||||
bool parseLineBasedData();
|
||||
static QDateTime tryParseDateTime( const std::string& colData, const QString& format );
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "RiaQDateTimeTools.h"
|
||||
|
||||
#include "RifCsvUserDataParser.h"
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
#include "RifEclipseUserDataKeywordTools.h"
|
||||
#include "RifEclipseUserDataParserTools.h"
|
||||
|
||||
@ -79,7 +80,21 @@ bool RifRevealCsvSectionSummaryReader::parse( const QString& text, RifEclipseSum
|
||||
{ "1000Sm3/d", { "SM3/DAY", 1000.0 } },
|
||||
{ "MSm3", { "SM3", 1000000.0 } } };
|
||||
|
||||
if ( !m_parser->parse( parseOptions, unitMapping ) )
|
||||
QString prefix = defaultCategory == RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_FIELD ? "F" : "W";
|
||||
|
||||
std::map<QString, QString> nameMapping = { { "WaterCut", prefix + "WCT" }, { "GOR", prefix + "GOR" },
|
||||
{ "BottomHolePressure", prefix + "BHP" }, { "CumLiquidInjected", prefix + "LIT" },
|
||||
{ "CumWaterInjected", prefix + "WIT" }, { "CumGasInjected", prefix + "GIT" },
|
||||
{ "CumOilInjected", prefix + "OIT" }, { "CumLiquidProduced", prefix + "LPT" },
|
||||
{ "CumWaterProduced", prefix + "WPT" }, { "CumGasProduced", prefix + "GPT" },
|
||||
{ "CumOilProduced", prefix + "OPT" }, { "LiquidProduced", prefix + "LPR" },
|
||||
{ "WaterProduced", prefix + "WPR" }, { "GasProduced", prefix + "GPR" },
|
||||
{ "OilProduced", prefix + "OPR" }, { "LiquidInjected", prefix + "LIR" },
|
||||
{ "WaterInjected", prefix + "WIR" }, { "GasInjected", prefix + "GIR" },
|
||||
{ "OilInjected", prefix + "OIR" }, { "WaterGasRatio", prefix + "WGR" },
|
||||
{ "GasLiftRate", prefix + "GLIR" } };
|
||||
|
||||
if ( !m_parser->parse( parseOptions, nameMapping, unitMapping ) )
|
||||
{
|
||||
RiaLogging::error( QString( "Failed to parse file" ) );
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user