2018-06-07 03:50:32 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017- Statoil ASA
|
2019-03-11 05:45:35 -05:00
|
|
|
//
|
2018-06-07 03:50:32 -05:00
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2019-03-11 05:45:35 -05:00
|
|
|
//
|
2018-06-07 03:50:32 -05:00
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
2019-03-11 05:45:35 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-06-07 03:50:32 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RifEnsembleStatisticsReader.h"
|
|
|
|
|
2020-11-10 11:27:29 -06:00
|
|
|
#include "RimEnsembleCurveSet.h"
|
2018-06-07 03:50:32 -05:00
|
|
|
#include "RimEnsembleStatisticsCase.h"
|
2020-11-10 11:27:29 -06:00
|
|
|
#include "RimSummaryCaseCollection.h"
|
2018-06-07 03:50:32 -05:00
|
|
|
|
2018-06-13 06:35:33 -05:00
|
|
|
static const std::vector<time_t> EMPTY_TIME_STEPS_VECTOR;
|
|
|
|
|
2018-06-07 03:50:32 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-11 05:45:35 -05:00
|
|
|
///
|
2018-06-07 03:50:32 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RifEnsembleStatisticsReader::RifEnsembleStatisticsReader( RimEnsembleStatisticsCase* ensStatCase )
|
2018-06-07 03:50:32 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( ensStatCase );
|
2018-06-07 03:50:32 -05:00
|
|
|
|
|
|
|
m_ensembleStatCase = ensStatCase;
|
|
|
|
|
2018-06-25 08:14:47 -05:00
|
|
|
m_allResultAddresses = std::set<RifEclipseSummaryAddress>(
|
2020-11-09 06:44:29 -06:00
|
|
|
{ RifEclipseSummaryAddress::ensembleStatisticsAddress( ENSEMBLE_STAT_P10_QUANTITY_NAME, "" ),
|
|
|
|
RifEclipseSummaryAddress::ensembleStatisticsAddress( ENSEMBLE_STAT_P50_QUANTITY_NAME, "" ),
|
|
|
|
RifEclipseSummaryAddress::ensembleStatisticsAddress( ENSEMBLE_STAT_P90_QUANTITY_NAME, "" ),
|
|
|
|
RifEclipseSummaryAddress::ensembleStatisticsAddress( ENSEMBLE_STAT_MEAN_QUANTITY_NAME, "" ) } );
|
2018-06-07 03:50:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-11 05:45:35 -05:00
|
|
|
///
|
2018-06-07 03:50:32 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
const std::vector<time_t>& RifEnsembleStatisticsReader::timeSteps( const RifEclipseSummaryAddress& resultAddress ) const
|
2018-06-07 03:50:32 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !validateAddress( resultAddress ) ) return EMPTY_TIME_STEPS_VECTOR;
|
2018-06-07 03:50:32 -05:00
|
|
|
return m_ensembleStatCase->timeSteps();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-11 05:45:35 -05:00
|
|
|
///
|
2018-06-07 03:50:32 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
bool RifEnsembleStatisticsReader::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
2018-06-07 03:50:32 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !validateAddress( resultAddress ) ) return false;
|
2018-06-07 03:50:32 -05:00
|
|
|
|
2019-03-11 05:45:35 -05:00
|
|
|
const std::vector<double>* sourceData = nullptr;
|
2022-05-06 09:34:37 -05:00
|
|
|
auto quantityName = resultAddress.ensembleStatisticsVectorName();
|
2018-06-12 07:22:32 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( quantityName == ENSEMBLE_STAT_P10_QUANTITY_NAME )
|
2019-03-11 05:45:35 -05:00
|
|
|
sourceData = &m_ensembleStatCase->p10();
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( quantityName == ENSEMBLE_STAT_P50_QUANTITY_NAME )
|
2019-03-11 05:45:35 -05:00
|
|
|
sourceData = &m_ensembleStatCase->p50();
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( quantityName == ENSEMBLE_STAT_P90_QUANTITY_NAME )
|
2019-03-11 05:45:35 -05:00
|
|
|
sourceData = &m_ensembleStatCase->p90();
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( quantityName == ENSEMBLE_STAT_MEAN_QUANTITY_NAME )
|
2019-03-11 05:45:35 -05:00
|
|
|
sourceData = &m_ensembleStatCase->mean();
|
2018-06-07 03:50:32 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !sourceData ) return false;
|
2018-06-07 03:50:32 -05:00
|
|
|
|
|
|
|
values->clear();
|
2019-09-06 03:40:57 -05:00
|
|
|
values->reserve( sourceData->size() );
|
|
|
|
for ( auto val : *sourceData )
|
|
|
|
values->push_back( val );
|
2018-06-07 03:50:32 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-11 05:45:35 -05:00
|
|
|
///
|
2018-06-07 03:50:32 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::string RifEnsembleStatisticsReader::unitName( const RifEclipseSummaryAddress& resultAddress ) const
|
2018-06-07 03:50:32 -05:00
|
|
|
{
|
2020-11-10 11:27:29 -06:00
|
|
|
std::string retval;
|
|
|
|
|
|
|
|
// The stat case does not have a unit set, so pick up the unit from one of the input cases, if possible
|
|
|
|
auto cases = m_ensembleStatCase->curveSet()->summaryCaseCollection()->allSummaryCases();
|
|
|
|
if ( cases.size() > 0 )
|
|
|
|
{
|
2022-05-06 09:34:37 -05:00
|
|
|
QString qName = QString::fromStdString( resultAddress.vectorName() );
|
2020-11-10 11:27:29 -06:00
|
|
|
std::string orgQName = qName.split( ":" )[1].toStdString();
|
|
|
|
|
|
|
|
RifEclipseSummaryAddress address = RifEclipseSummaryAddress( resultAddress );
|
2022-05-06 09:34:37 -05:00
|
|
|
address.setVectorName( orgQName );
|
2020-11-10 11:27:29 -06:00
|
|
|
|
|
|
|
retval = cases[0]->summaryReader()->unitName( address );
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
2018-06-07 03:50:32 -05:00
|
|
|
}
|
|
|
|
|
2019-07-25 00:38:46 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-01-21 05:58:46 -06:00
|
|
|
RiaDefines::EclipseUnitSystem RifEnsembleStatisticsReader::unitSystem() const
|
2019-07-25 00:38:46 -05:00
|
|
|
{
|
|
|
|
return m_ensembleStatCase->unitSystem();
|
|
|
|
}
|
|
|
|
|
2018-06-07 03:50:32 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-11 05:45:35 -05:00
|
|
|
///
|
2018-06-07 03:50:32 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
bool RifEnsembleStatisticsReader::validateAddress( const RifEclipseSummaryAddress& address ) const
|
2018-06-07 03:50:32 -05:00
|
|
|
{
|
2022-05-06 09:34:37 -05:00
|
|
|
return address.category() == RifEclipseSummaryAddress::SUMMARY_ENSEMBLE_STATISTICS && !address.vectorName().empty();
|
2018-06-07 03:50:32 -05:00
|
|
|
}
|