RFT Plot - make sure we handle feet vs. meters in well log type plots (#6551)

* Fix the meter <-> feet conversion (it was backwards)

* Make sure we refresh the plots after changing the depth axis unit

* Make sure formation overlays etc. also gets converted to correct depth unit (correct as in the same unit any loaded Eclipse Result case use)
This commit is contained in:
jonjenssen
2020-09-25 11:14:56 +02:00
committed by GitHub
parent 49be87e38a
commit 5c4498db9f
7 changed files with 163 additions and 19 deletions

View File

@@ -47,15 +47,24 @@ public:
static std::vector<FloatType> convertDepths( const std::vector<FloatType>& depthsIn,
RiaDefines::DepthUnitType unitsIn,
RiaDefines::DepthUnitType unitsOut );
static bool convertValues( const std::vector<FloatType>& tvdRKBs,
const std::vector<FloatType>& valuesIn,
std::vector<FloatType>* valuesOut,
const QString& unitsIn,
const QString& unitsOut );
static bool convertValues( std::vector<std::pair<FloatType, FloatType>>* measuredDepthsAndValues,
const QString& unitsIn,
const QString& unitsOut,
const RigWellPath* wellPath );
static std::vector<std::pair<FloatType, FloatType>>
convertDepths( const std::vector<std::pair<FloatType, FloatType>>& depthsIn,
RiaDefines::DepthUnitType unitsIn,
RiaDefines::DepthUnitType unitsOut );
static FloatType
convertDepth( FloatType depthIn, RiaDefines::DepthUnitType unitsIn, RiaDefines::DepthUnitType unitsOut );
static bool convertValues( const std::vector<FloatType>& tvdRKBs,
const std::vector<FloatType>& valuesIn,
std::vector<FloatType>* valuesOut,
const QString& unitsIn,
const QString& unitsOut );
static bool convertValues( std::vector<std::pair<FloatType, FloatType>>* measuredDepthsAndValues,
const QString& unitsIn,
const QString& unitsOut,
const RigWellPath* wellPath );
static std::vector<FloatType> tvdRKBs( const std::vector<FloatType>& measuredDepths, const RigWellPath* wellPath );

View File

@@ -140,15 +140,64 @@ std::vector<FloatType> RiaWellLogUnitTools<FloatType>::convertDepths( const std:
{
if ( unitsOut == RiaDefines::DepthUnitType::UNIT_METER && unitsIn == RiaDefines::DepthUnitType::UNIT_FEET )
{
return multiply( depthsIn, RiaEclipseUnitTools::feetPerMeter() );
return multiply( depthsIn, RiaEclipseUnitTools::meterPerFeet() );
}
else if ( unitsOut == RiaDefines::DepthUnitType::UNIT_FEET && unitsIn == RiaDefines::DepthUnitType::UNIT_METER )
{
return multiply( depthsIn, RiaEclipseUnitTools::meterPerFeet() );
return multiply( depthsIn, RiaEclipseUnitTools::feetPerMeter() );
}
return depthsIn;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename FloatType>
FloatType RiaWellLogUnitTools<FloatType>::convertDepth( FloatType depthIn,
RiaDefines::DepthUnitType unitsIn,
RiaDefines::DepthUnitType unitsOut )
{
FloatType factor = 1.0;
if ( unitsOut == RiaDefines::DepthUnitType::UNIT_METER && unitsIn == RiaDefines::DepthUnitType::UNIT_FEET )
{
factor = RiaEclipseUnitTools::meterPerFeet();
}
else if ( unitsOut == RiaDefines::DepthUnitType::UNIT_FEET && unitsIn == RiaDefines::DepthUnitType::UNIT_METER )
{
factor = RiaEclipseUnitTools::feetPerMeter();
}
return depthIn * factor;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename FloatType>
std::vector<std::pair<FloatType, FloatType>>
RiaWellLogUnitTools<FloatType>::convertDepths( const std::vector<std::pair<FloatType, FloatType>>& depthsIn,
RiaDefines::DepthUnitType unitsIn,
RiaDefines::DepthUnitType unitsOut )
{
std::vector<std::pair<FloatType, FloatType>> convertedDepths( depthsIn.size() );
double factor = 1.0;
if ( unitsOut == RiaDefines::DepthUnitType::UNIT_METER && unitsIn == RiaDefines::DepthUnitType::UNIT_FEET )
{
factor = RiaEclipseUnitTools::meterPerFeet();
}
else if ( unitsOut == RiaDefines::DepthUnitType::UNIT_FEET && unitsIn == RiaDefines::DepthUnitType::UNIT_METER )
{
factor = RiaEclipseUnitTools::feetPerMeter();
}
int i = 0;
for ( auto& p : depthsIn )
{
convertedDepths[i++] = std::make_pair( factor * p.first, factor * p.second );
}
return convertedDepths;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -26,8 +26,12 @@
#include "RigWellPath.h"
#include "RimEclipseCase.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseResultCase.h"
#include "RimGeoMechCase.h"
#include "RimOilField.h"
#include "RimPlot.h"
#include "RimProject.h"
#include "RimWellAllocationPlot.h"
#include "RimWellLogCurve.h"
#include "RimWellLogCurveCommonDataSource.h"
@@ -379,6 +383,38 @@ void RimDepthTrackPlot::visibleDepthRange( double* minimumDepth, double* maximum
*maximumDepth = m_maxVisibleDepth;
}
RiaDefines::DepthUnitType RimDepthTrackPlot::caseDepthUnit() const
{
RimEclipseResultCase* thecase = dynamic_cast<RimEclipseResultCase*>( commonDataSource()->caseToApply() );
if ( thecase == nullptr )
{
// no suitable case found, look in the project to see if there is a eclipse case with units defined loaded
RimProject* p = RiaApplication::instance()->project();
for ( RimEclipseCase* aCase : p->activeOilField()->analysisModels()->cases() )
{
thecase = dynamic_cast<RimEclipseResultCase*>( aCase );
if ( thecase ) break;
}
}
if ( thecase )
{
switch ( thecase->unitSystem() )
{
case RiaEclipseUnitTools::UnitSystem::UNITS_FIELD:
return RiaDefines::DepthUnitType::UNIT_FEET;
case RiaEclipseUnitTools::UnitSystem::UNITS_METRIC:
return RiaDefines::DepthUnitType::UNIT_METER;
default:
break;
}
}
return RiaDefines::DepthUnitType::UNIT_NONE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -797,7 +833,7 @@ void RimDepthTrackPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel
else if ( changedField == &m_depthUnit )
{
m_isAutoScaleDepthEnabled = true;
updateZoom();
onLoadDataAndUpdate();
}
else if ( changedField == &m_subTitleFontSize || changedField == &m_axisTitleFontSize ||
changedField == &m_axisValueFontSize )

View File

@@ -125,6 +125,8 @@ public:
int axisTitleFontSize() const;
int axisValueFontSize() const;
RiaDefines::DepthUnitType caseDepthUnit() const;
protected:
QImage snapshotWindowContent() override;

View File

@@ -315,6 +315,14 @@ bool RimEclipseResultCase::openAndReadActiveCellData( RigEclipseCaseData* mainEc
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaEclipseUnitTools::UnitSystemType RimEclipseResultCase::unitSystem()
{
return m_unitSystem();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -61,6 +61,8 @@ public:
bool openAndReadActiveCellData( RigEclipseCaseData* mainEclipseCase );
void readGridDimensions( std::vector<std::vector<int>>& gridDimensions );
RiaEclipseUnitTools::UnitSystemType unitSystem();
// Overrides from RimCase
QString locationOnDisc() const override;
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override;

View File

@@ -2489,6 +2489,9 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
RimDepthTrackPlot* plot = nullptr;
firstAncestorOrThisOfTypeAsserted( plot );
RiaDefines::DepthUnitType fromDepthUnit = plot->caseDepthUnit();
RiaDefines::DepthUnitType toDepthUnit = plot->depthUnit();
if ( m_formationSource() == WELL_PICK_FILTER )
{
if ( m_formationWellPathForSourceWellPath == nullptr ) return;
@@ -2520,7 +2523,10 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
}
}
m_annotationTool->attachWellPicks( m_plotWidget, formationNamesToPlot, yValues );
std::vector<double> convertedYValues =
RiaWellLogUnitTools<double>::convertDepths( yValues, fromDepthUnit, toDepthUnit );
m_annotationTool->attachWellPicks( m_plotWidget, formationNamesToPlot, convertedYValues );
}
else
{
@@ -2587,10 +2593,14 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
const caf::ColorTable waterAndRockColors = RiaColorTables::waterAndRockPaletteColors();
const std::vector<std::pair<double, double>> waterAndRockIntervals =
waterAndRockRegions( plot->depthType(), extractor );
const std::vector<std::pair<double, double>> convertedYValues =
RiaWellLogUnitTools<double>::convertDepths( waterAndRockIntervals, fromDepthUnit, toDepthUnit );
m_annotationTool->attachNamedRegions( m_plotWidget,
{"Sea Level", ""},
xRange,
waterAndRockIntervals,
convertedYValues,
m_regionAnnotationDisplay(),
waterAndRockColors,
( ( 100 - m_colorShadingTransparency ) * 255 ) / 100,
@@ -2628,11 +2638,14 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
const std::pair<double, double> xRange = std::make_pair( m_visibleXRangeMin(), m_visibleXRangeMax() );
std::vector<std::pair<double, double>> convertedYValues =
RiaWellLogUnitTools<double>::convertDepths( yValues, fromDepthUnit, toDepthUnit );
caf::ColorTable colorTable( m_colorShadingLegend->colorArray() );
m_annotationTool->attachNamedRegions( m_plotWidget,
formationNamesToPlot,
xRange,
yValues,
convertedYValues,
m_regionAnnotationDisplay(),
colorTable,
( ( 100 - m_colorShadingTransparency ) * 255 ) / 100,
@@ -2649,6 +2662,9 @@ void RimWellLogTrack::updateResultPropertyNamesOnPlot()
RimDepthTrackPlot* plot = nullptr;
firstAncestorOrThisOfTypeAsserted( plot );
RiaDefines::DepthUnitType fromDepthUnit = plot->caseDepthUnit();
RiaDefines::DepthUnitType toDepthUnit = plot->depthUnit();
RigEclipseWellLogExtractor* eclWellLogExtractor =
RiaExtractionTools::wellLogExtractorEclipseCase( m_formationWellPathForSourceCase,
dynamic_cast<RimEclipseCase*>( m_formationCase() ) );
@@ -2705,6 +2721,10 @@ void RimWellLogTrack::updateResultPropertyNamesOnPlot()
std::vector<std::pair<double, double>> yValues;
RimWellLogTrack::findRegionNamesToPlot( curveData, namesVector, plot->depthType(), &namesToPlot, &yValues );
// convert to plot depth unit
std::vector<std::pair<double, double>> convertedYValues =
RiaWellLogUnitTools<double>::convertDepths( yValues, fromDepthUnit, toDepthUnit );
// TODO: unecessarily messy!
// Need to map colors to names (since a category can be used several times)
for ( QString nameToPlot : namesToPlot )
@@ -2726,7 +2746,7 @@ void RimWellLogTrack::updateResultPropertyNamesOnPlot()
m_annotationTool->attachNamedRegions( m_plotWidget,
namesToPlot,
xRange,
yValues,
convertedYValues,
m_regionAnnotationDisplay(),
colorTable,
( ( 100 - m_colorShadingTransparency ) * 255 ) / 100,
@@ -2743,6 +2763,9 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot()
this->firstAncestorOrThisOfType( wellBoreStabilityPlot );
if ( wellBoreStabilityPlot )
{
RiaDefines::DepthUnitType fromDepthUnit = wellBoreStabilityPlot->caseDepthUnit();
RiaDefines::DepthUnitType toDepthUnit = wellBoreStabilityPlot->depthUnit();
wellBoreStabilityPlot->updateCommonDataSource();
RimGeoMechCase* geoMechCase =
dynamic_cast<RimGeoMechCase*>( wellBoreStabilityPlot->commonDataSource()->caseToApply() );
@@ -2789,10 +2812,15 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot()
wellBoreStabilityPlot->depthType(),
&sourceNamesToPlot,
&yValues );
// convert to plot depth unit
std::vector<std::pair<double, double>> convertedYValues =
RiaWellLogUnitTools<double>::convertDepths( yValues, fromDepthUnit, toDepthUnit );
m_annotationTool->attachNamedRegions( m_plotWidget,
sourceNamesToPlot,
xRange,
yValues,
convertedYValues,
m_regionAnnotationDisplay(),
colorTable,
( ( ( 100 - m_colorShadingTransparency ) * 255 ) / 100 ) / 3,
@@ -2815,10 +2843,15 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot()
wellBoreStabilityPlot->depthType(),
&sourceNamesToPlot,
&yValues );
// convert to plot depth unit
std::vector<std::pair<double, double>> convertedYValues =
RiaWellLogUnitTools<double>::convertDepths( yValues, fromDepthUnit, toDepthUnit );
m_annotationTool->attachNamedRegions( m_plotWidget,
sourceNamesToPlot,
xRange,
yValues,
convertedYValues,
m_regionAnnotationDisplay(),
colorTable,
( ( ( 100 - m_colorShadingTransparency ) * 255 ) / 100 ) / 3,
@@ -2840,10 +2873,15 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot()
wellBoreStabilityPlot->depthType(),
&sourceNamesToPlot,
&yValues );
// convert to plot depth unit
std::vector<std::pair<double, double>> convertedYValues =
RiaWellLogUnitTools<double>::convertDepths( yValues, fromDepthUnit, toDepthUnit );
m_annotationTool->attachNamedRegions( m_plotWidget,
sourceNamesToPlot,
xRange,
yValues,
convertedYValues,
m_regionAnnotationDisplay(),
colorTable,
( ( ( 100 - m_colorShadingTransparency ) * 255 ) / 100 ) / 3,