mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5757 Python : Add resampling of summary data
This commit is contained in:
parent
ae15122632
commit
54206a42f6
@ -2,6 +2,7 @@
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryPlotCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryCase.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryResampleData.h
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcDataContainerDouble.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcDataContainerString.h
|
||||
@ -11,6 +12,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimcDataContainerTime.h
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryPlotCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryCase.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryResampleData.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcDataContainerDouble.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcDataContainerString.cpp
|
||||
|
@ -18,12 +18,17 @@
|
||||
|
||||
#include "RimcSummaryCase.h"
|
||||
|
||||
#include "RiaQDateTimeTools.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
#include "RiaTimeHistoryCurveResampler.h"
|
||||
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
#include "RimSummaryCase.h"
|
||||
|
||||
#include "RimcDataContainerDouble.h"
|
||||
#include "RimcDataContainerString.h"
|
||||
#include "RimcDataContainerTime.h"
|
||||
#include "RimcSummaryResampleData.h"
|
||||
|
||||
#include "cafPdmFieldIOScriptability.h"
|
||||
|
||||
@ -178,3 +183,109 @@ std::unique_ptr<caf::PdmObjectHandle> RimcSummaryCase_TimeSteps::defaultResult()
|
||||
{
|
||||
return std::unique_ptr<caf::PdmObjectHandle>( new RimcDataContainerTime );
|
||||
}
|
||||
|
||||
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimcSummaryCase_ResampleValues, "ResampleValues" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimcSummaryCase_ResampleValues::RimcSummaryCase_ResampleValues( caf::PdmObjectHandle* self )
|
||||
: caf::PdmObjectMethod( self )
|
||||
{
|
||||
CAF_PDM_InitObject( "Resample Values", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_addressString,
|
||||
"Address",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"Formatted address specifying the summary vector" );
|
||||
|
||||
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_resamplingPeriod, "ResamplingPeriod", "", "", "", "Resampling Period" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObjectHandle* RimcSummaryCase_ResampleValues::execute()
|
||||
{
|
||||
QStringList addressStrings = m_addressString().split( ";", QString::SkipEmptyParts );
|
||||
|
||||
auto* summaryCase = self<RimSummaryCase>();
|
||||
RifSummaryReaderInterface* sumReader = summaryCase->summaryReader();
|
||||
|
||||
auto adr = RifEclipseSummaryAddress::fromEclipseTextAddress( m_addressString().toStdString() );
|
||||
|
||||
std::vector<double> values;
|
||||
bool isOk = sumReader->values( adr, &values );
|
||||
if ( !isOk ) return nullptr;
|
||||
|
||||
auto timeValues = sumReader->timeSteps( adr );
|
||||
DateTimePeriod period = DateTimePeriod::NONE;
|
||||
|
||||
{
|
||||
QString periodString = m_resamplingPeriod().trimmed();
|
||||
|
||||
if ( periodString.compare( RiaQDateTimeTools::TIMESPAN_DAY_NAME, Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
period = DateTimePeriod::DAY;
|
||||
}
|
||||
else if ( periodString.compare( RiaQDateTimeTools::TIMESPAN_WEEK_NAME, Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
period = DateTimePeriod::WEEK;
|
||||
}
|
||||
else if ( periodString.compare( RiaQDateTimeTools::TIMESPAN_MONTH_NAME, Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
period = DateTimePeriod::MONTH;
|
||||
}
|
||||
else if ( periodString.compare( RiaQDateTimeTools::TIMESPAN_QUARTER_NAME, Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
period = DateTimePeriod::QUARTER;
|
||||
}
|
||||
else if ( periodString.compare( RiaQDateTimeTools::TIMESPAN_HALFYEAR_NAME, Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
period = DateTimePeriod::HALFYEAR;
|
||||
}
|
||||
else if ( periodString.compare( RiaQDateTimeTools::TIMESPAN_YEAR_NAME, Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
period = DateTimePeriod::YEAR;
|
||||
}
|
||||
else if ( periodString.compare( RiaQDateTimeTools::TIMESPAN_DECADE_NAME, Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
period = DateTimePeriod::DECADE;
|
||||
}
|
||||
}
|
||||
|
||||
RiaTimeHistoryCurveResampler resampler;
|
||||
resampler.setCurveData( values, timeValues );
|
||||
|
||||
if ( RiaSummaryTools::hasAccumulatedData( adr ) )
|
||||
{
|
||||
resampler.resampleAndComputePeriodEndValues( period );
|
||||
}
|
||||
else
|
||||
{
|
||||
resampler.resampleAndComputeWeightedMeanValues( period );
|
||||
}
|
||||
|
||||
auto dataObject = new RimcSummaryResampleData();
|
||||
dataObject->m_timeValues = resampler.resampledTimeSteps();
|
||||
dataObject->m_doubleValues = resampler.resampledValues();
|
||||
|
||||
return dataObject;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimcSummaryCase_ResampleValues::resultIsPersistent() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::unique_ptr<caf::PdmObjectHandle> RimcSummaryCase_ResampleValues::defaultResult() const
|
||||
{
|
||||
return std::unique_ptr<caf::PdmObjectHandle>( new RimcSummaryResampleData );
|
||||
}
|
||||
|
@ -73,3 +73,22 @@ public:
|
||||
bool resultIsPersistent() const override;
|
||||
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimcSummaryCase_ResampleValues : public caf::PdmObjectMethod
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimcSummaryCase_ResampleValues( caf::PdmObjectHandle* self );
|
||||
|
||||
caf::PdmObjectHandle* execute();
|
||||
bool resultIsPersistent() const override;
|
||||
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_addressString;
|
||||
caf::PdmField<QString> m_resamplingPeriod;
|
||||
};
|
||||
|
@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimcSummaryResampleData.h"
|
||||
|
||||
#include "cafPdmFieldIOScriptability.h"
|
||||
|
||||
#include "cafPdmObjectScriptability.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimcSummaryResampleData, "ResampleData" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimcSummaryResampleData::RimcSummaryResampleData()
|
||||
{
|
||||
CAF_PDM_InitScriptableObject( "Resample Data", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_timeValues, "TimeValues", "Data Time Values", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_doubleValues, "DoubleValues", "Data Double Values", "", "", "" );
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimcSummaryResampleData : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimcSummaryResampleData();
|
||||
|
||||
caf::PdmField<std::vector<double>> m_doubleValues;
|
||||
caf::PdmField<std::vector<time_t>> m_timeValues;
|
||||
};
|
Loading…
Reference in New Issue
Block a user