(#541) Added feature for export of well log plot curves to a LAS file

Did some refactoring/improvements by introducing new class
RigWellLogCurveData.
This commit is contained in:
Pål Hagen 2015-10-15 11:27:12 +02:00
parent 5f92e87070
commit 08573be64b
16 changed files with 476 additions and 68 deletions

View File

@ -47,7 +47,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.h ${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.h
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.h ${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.h
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
# General delete of any object in a child array field # General delete of any object in a child array field
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h ${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h
@ -95,6 +95,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathsDeleteAllFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp
# General delete of any object in a child array field # General delete of any object in a child array field

View File

@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "RicExportToLasFileFeature.h"
#include "RimWellLogPlotCurve.h"
#include "RigWellLogFile.h"
#include "RiuMainWindow.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QFileDialog>
CAF_CMD_SOURCE_INIT(RicExportToLasFileFeature, "RicExportToLasFileFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExportToLasFileFeature::isCommandEnabled()
{
return selectedWellLogPlotCurve() != NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportToLasFileFeature::onActionTriggered(bool isChecked)
{
RimWellLogPlotCurve* curve = selectedWellLogPlotCurve();
if (curve)
{
QString fileName = QFileDialog::getSaveFileName(RiuMainWindow::instance(), tr("Export Curve Data To LAS File"), "", tr("LAS Files (*.las);;All files(*.*)"));
if (!fileName.isEmpty())
{
RigWellLogFile::exportToLasFile(curve, fileName);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportToLasFileFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Export To LAS File...");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlotCurve* RicExportToLasFileFeature::selectedWellLogPlotCurve() const
{
std::vector<RimWellLogPlotCurve*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
if (selection.size() > 0)
{
return selection[0];
}
return NULL;
}

View File

@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "cafCmdFeature.h"
#include <vector>
class RimWellLogPlotCurve;
//==================================================================================================
///
//==================================================================================================
class RicExportToLasFileFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
private:
RimWellLogPlotCurve* selectedWellLogPlotCurve() const;
};

View File

@ -826,6 +826,7 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
} }
else if (dynamic_cast<RimWellLogPlotCurve*>(uiItem)) else if (dynamic_cast<RimWellLogPlotCurve*>(uiItem))
{ {
commandIds << "RicExportToLasFileFeature";
commandIds << "RicDeleteItemFeature"; commandIds << "RicDeleteItemFeature";
} }
else if (dynamic_cast<RimWellLogFileChannel*>(uiItem)) else if (dynamic_cast<RimWellLogFileChannel*>(uiItem))

View File

@ -195,9 +195,8 @@ void RimWellLogExtractionCurve::updatePlotData()
cvf::ref<RigEclipseWellLogExtractor> eclExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, eclipseCase); cvf::ref<RigEclipseWellLogExtractor> eclExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, eclipseCase);
cvf::ref<RigGeoMechWellLogExtractor> geomExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, geomCase); cvf::ref<RigGeoMechWellLogExtractor> geomExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, geomCase);
std::vector<double> filteredValues; std::vector<double> values;
std::vector<double> filteredDepths; std::vector<double> depthValues;
std::vector< std::pair<size_t, size_t> > plotIntervals;
if (eclExtractor.notNull()) if (eclExtractor.notNull())
{ {
@ -205,7 +204,7 @@ void RimWellLogExtractionCurve::updatePlotData()
firstAnchestorOrThisOfType(wellLogPlot); firstAnchestorOrThisOfType(wellLogPlot);
CVF_ASSERT(wellLogPlot); CVF_ASSERT(wellLogPlot);
const std::vector<double>& depthValues = wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH ? eclExtractor->measuredDepth() : eclExtractor->trueVerticalDepth(); depthValues = wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH ? eclExtractor->measuredDepth() : eclExtractor->trueVerticalDepth();
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_eclipseResultDefinition->porosityModel()); RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_eclipseResultDefinition->porosityModel());
m_eclipseResultDefinition->loadResult(); m_eclipseResultDefinition->loadResult();
@ -216,19 +215,10 @@ void RimWellLogExtractionCurve::updatePlotData()
m_timeStep, m_timeStep,
m_eclipseResultDefinition->resultVariable()); m_eclipseResultDefinition->resultVariable());
std::vector<double> values;
if (resAcc.notNull()) if (resAcc.notNull())
{ {
eclExtractor->curveData(resAcc.p(), &values); eclExtractor->curveData(resAcc.p(), &values);
} }
if (values.size() > 0 && values.size() == depthValues.size())
{
RimWellLogCurveImpl::validCurvePointIntervals(depthValues, values, plotIntervals);
RimWellLogCurveImpl::addValuesFromIntervals(depthValues, plotIntervals, &filteredDepths);
RimWellLogCurveImpl::addValuesFromIntervals(values, plotIntervals, &filteredValues);
}
} }
else if (geomExtractor.notNull()) // geomExtractor else if (geomExtractor.notNull()) // geomExtractor
{ {
@ -236,32 +226,22 @@ void RimWellLogExtractionCurve::updatePlotData()
firstAnchestorOrThisOfType(wellLogPlot); firstAnchestorOrThisOfType(wellLogPlot);
CVF_ASSERT(wellLogPlot); CVF_ASSERT(wellLogPlot);
const std::vector<double>& depthValues = wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH ? geomExtractor->measuredDepth() : geomExtractor->trueVerticalDepth(); depthValues = wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH ? geomExtractor->measuredDepth() : geomExtractor->trueVerticalDepth();
m_geomResultDefinition->loadResult(); m_geomResultDefinition->loadResult();
std::vector<double> values;
geomExtractor->curveData(m_geomResultDefinition->resultAddress(), m_timeStep, &values); geomExtractor->curveData(m_geomResultDefinition->resultAddress(), m_timeStep, &values);
if (values.size() > 0 && values.size() == depthValues.size())
{
RimWellLogCurveImpl::validCurvePointIntervals(depthValues, values, plotIntervals);
RimWellLogCurveImpl::addValuesFromIntervals(depthValues, plotIntervals, &filteredDepths);
RimWellLogCurveImpl::addValuesFromIntervals(values, plotIntervals, &filteredValues);
}
} }
m_plotCurve->setSamples(filteredValues.data(), filteredDepths.data(), (int)filteredValues.size()); m_curveData = new RigWellLogCurveData;
std::vector< std::pair<size_t, size_t> > fltrIntervals; if (values.size() == depthValues.size())
RimWellLogCurveImpl::filteredIntervals(plotIntervals, &fltrIntervals);
m_plotCurve->setPlotIntervals(fltrIntervals);
if (filteredValues.size())
{ {
updateTrackAndPlotFromCurveData(); m_curveData->setPoints(values, depthValues);
} }
m_plotCurve->setCurveData(m_curveData.p());
updateTrackAndPlotFromCurveData();
if (m_plot) m_plot->replot(); if (m_plot) m_plot->replot();
} }
} }

View File

@ -72,6 +72,8 @@ void RimWellLogFileCurve::updatePlotData()
if (isCurveVisibile()) if (isCurveVisibile())
{ {
m_curveData = new RigWellLogCurveData;
if (m_wellPath) if (m_wellPath)
{ {
RimWellLogFile* logFileInfo = m_wellPath->m_wellLogFile; RimWellLogFile* logFileInfo = m_wellPath->m_wellLogFile;
@ -83,25 +85,9 @@ void RimWellLogFileCurve::updatePlotData()
std::vector<double> values = wellLogFile->values(m_wellLogChannnelName); std::vector<double> values = wellLogFile->values(m_wellLogChannnelName);
std::vector<double> depthValues = wellLogFile->depthValues(); std::vector<double> depthValues = wellLogFile->depthValues();
if (values.size() > 0 && depthValues.size() > 0) if (values.size() == depthValues.size())
{
std::vector< std::pair<size_t, size_t> > valuesIntervals;
RimWellLogCurveImpl::calculateIntervalsOfValidValues(values, valuesIntervals);
std::vector<double> filteredValues;
std::vector<double> filteredDepths;
RimWellLogCurveImpl::addValuesFromIntervals(values, valuesIntervals, &filteredValues);
RimWellLogCurveImpl::addValuesFromIntervals(depthValues, valuesIntervals, &filteredDepths);
std::vector< std::pair<size_t, size_t> > fltrIntervals;
RimWellLogCurveImpl::filteredIntervals(valuesIntervals, &fltrIntervals);
m_plotCurve->setSamples(filteredValues.data(), filteredDepths.data(), (int)filteredDepths.size());
m_plotCurve->setPlotIntervals(fltrIntervals);
}
else
{ {
m_plotCurve->setSamples(NULL, NULL, 0); m_curveData->setPoints(values, depthValues);
} }
} }
@ -111,10 +97,8 @@ void RimWellLogFileCurve::updatePlotData()
} }
} }
} }
else
{ m_plotCurve->setCurveData(m_curveData.p());
m_plotCurve->setSamples(NULL, NULL, 0);
}
updateTrackAndPlotFromCurveData(); updateTrackAndPlotFromCurveData();

View File

@ -291,3 +291,11 @@ void RimWellLogPlotCurve::updateOptionSensitivity()
{ {
m_curveName.uiCapability()->setUiReadOnly(m_autoName); m_curveName.uiCapability()->setUiReadOnly(m_autoName);
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigWellLogCurveData* RimWellLogPlotCurve::curveData() const
{
return m_curveData.p();
}

View File

@ -23,8 +23,11 @@
#include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfColor.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
#include "RigWellLogCurveData.h"
#include <vector> #include <vector>
class RigWellLogCurveData;
class RiuWellLogTrackPlot; class RiuWellLogTrackPlot;
class RiuWellLogPlotCurve; class RiuWellLogPlotCurve;
class QwtPlotCurve; class QwtPlotCurve;
@ -51,8 +54,10 @@ public:
bool isCurveVisibile(); bool isCurveVisibile();
QwtPlotCurve* plotCurve() const; QwtPlotCurve* plotCurve() const;
const RigWellLogCurveData* curveData() const;
QString name() const { return m_curveName; }
void updateCurveName(); void updateCurveName();
void updatePlotTitle(); void updatePlotTitle();
@ -73,8 +78,9 @@ protected:
virtual void initAfterRead(); virtual void initAfterRead();
RiuWellLogTrackPlot* m_plot; RiuWellLogTrackPlot* m_plot;
RiuWellLogPlotCurve* m_plotCurve; RiuWellLogPlotCurve* m_plotCurve;
cvf::ref<RigWellLogCurveData> m_curveData;
caf::PdmField<bool> m_showCurve; caf::PdmField<bool> m_showCurve;
caf::PdmField<QString> m_curveName; caf::PdmField<QString> m_curveName;

View File

@ -36,7 +36,7 @@ ${CEE_CURRENT_LIST_DIR}RigResultAccessor2d.h
${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h ${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h
${CEE_CURRENT_LIST_DIR}RigNativeStatCalc.h ${CEE_CURRENT_LIST_DIR}RigNativeStatCalc.h
${CEE_CURRENT_LIST_DIR}RigMultipleDatasetStatCalc.h ${CEE_CURRENT_LIST_DIR}RigMultipleDatasetStatCalc.h
${CEE_CURRENT_LIST_DIR}RigWellLogFile.h ${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.h
) )
set (SOURCE_GROUP_SOURCE_FILES set (SOURCE_GROUP_SOURCE_FILES
@ -67,7 +67,7 @@ ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.cpp
${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp ${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp
${CEE_CURRENT_LIST_DIR}RigNativeStatCalc.cpp ${CEE_CURRENT_LIST_DIR}RigNativeStatCalc.cpp
${CEE_CURRENT_LIST_DIR}RigMultipleDatasetStatCalc.cpp ${CEE_CURRENT_LIST_DIR}RigMultipleDatasetStatCalc.cpp
${CEE_CURRENT_LIST_DIR}RigWellLogFile.cpp ${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.cpp
) )
list(APPEND CODE_HEADER_FILES list(APPEND CODE_HEADER_FILES

View File

@ -7,11 +7,13 @@ endif()
set (SOURCE_GROUP_HEADER_FILES set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RigGeoMechWellLogExtractor.h ${CEE_CURRENT_LIST_DIR}RigGeoMechWellLogExtractor.h
${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapper.h ${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapper.h
${CEE_CURRENT_LIST_DIR}RigWellLogFile.h
) )
set (SOURCE_GROUP_SOURCE_FILES set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RigGeoMechWellLogExtractor.cpp ${CEE_CURRENT_LIST_DIR}RigGeoMechWellLogExtractor.cpp
${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapper.cpp ${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapper.cpp
${CEE_CURRENT_LIST_DIR}RigWellLogFile.cpp
) )
list(APPEND CODE_HEADER_FILES list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,187 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "RigWellLogCurveData.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellLogCurveData::RigWellLogCurveData()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellLogCurveData::~RigWellLogCurveData()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellLogCurveData::setPoints(const std::vector<double>& xValues, const std::vector<double>& yValues)
{
CVF_ASSERT(xValues.size() == yValues.size());
m_xValues = xValues;
m_yValues = yValues;
calculateValidPointIntervals();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RigWellLogCurveData::xValues() const
{
return m_xValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RigWellLogCurveData::yValues() const
{
return m_yValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector< std::pair<size_t, size_t> >& RigWellLogCurveData::intervals() const
{
return m_validPointIntervals;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RigWellLogCurveData::validXValues() const
{
std::vector<double> filteredValues;
addValuesFromIntervals(m_xValues, m_validPointIntervals, &filteredValues);
return filteredValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RigWellLogCurveData::validYValues() const
{
std::vector<double> filteredValues;
addValuesFromIntervals(m_yValues, m_validPointIntervals, &filteredValues);
return filteredValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector< std::pair<size_t, size_t> > RigWellLogCurveData::validPointsIntervals() const
{
std::vector< std::pair<size_t, size_t> > intervals;
filteredIntervals(m_validPointIntervals, &intervals);
return intervals;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellLogCurveData::calculateValidPointIntervals()
{
calculateIntervalsOfValidValues(m_xValues, &m_validPointIntervals);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellLogCurveData::calculateIntervalsOfValidValues(const std::vector<double>& values, std::vector< std::pair<size_t, size_t> >* intervals)
{
CVF_ASSERT(intervals);
int startIdx = -1;
size_t vIdx = 0;
size_t valueCount = values.size();
while (vIdx < valueCount)
{
double value = values[vIdx];
if (value == HUGE_VAL || value == -HUGE_VAL || value != value)
{
if (startIdx >= 0)
{
intervals->push_back(std::make_pair(startIdx, vIdx - 1));
startIdx = -1;
}
}
else if (startIdx < 0)
{
startIdx = (int)vIdx;
}
vIdx++;
}
if (startIdx >= 0 && startIdx < ((int)valueCount))
{
intervals->push_back(std::make_pair(startIdx, valueCount - 1));
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellLogCurveData::addValuesFromIntervals(const std::vector<double>& values, const std::vector< std::pair<size_t, size_t> >& intervals, std::vector<double>* filteredValues)
{
CVF_ASSERT(filteredValues);
for (size_t intIdx = 0; intIdx < intervals.size(); intIdx++)
{
for (size_t vIdx = intervals[intIdx].first; vIdx <= intervals[intIdx].second; vIdx++)
{
filteredValues->push_back(values[vIdx]);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellLogCurveData::filteredIntervals(const std::vector< std::pair<size_t, size_t> >& intervals, std::vector< std::pair<size_t, size_t> >* fltrIntervals)
{
CVF_ASSERT(fltrIntervals);
const size_t intervalCount = intervals.size();
if (intervalCount < 1) return;
size_t index = 0;
for (size_t intIdx = 0; intIdx < intervalCount; intIdx++)
{
size_t intervalSize = intervals[intIdx].second - intervals[intIdx].first + 1;
fltrIntervals->push_back(std::make_pair(index, index + intervalSize - 1));
index += intervalSize;
}
}

View File

@ -0,0 +1,57 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "cvfBase.h"
#include "cvfObject.h"
#include <vector>
//==================================================================================================
///
//==================================================================================================
class RigWellLogCurveData : public cvf::Object
{
public:
RigWellLogCurveData();
virtual ~RigWellLogCurveData();
void setPoints(const std::vector<double>& xValues, const std::vector<double>& yValues);
const std::vector<double>& xValues() const;
const std::vector<double>& yValues() const;
const std::vector< std::pair<size_t, size_t> >& intervals() const;
std::vector<double> validXValues() const;
std::vector<double> validYValues() const;
std::vector< std::pair<size_t, size_t> > validPointsIntervals() const;
private:
void calculateValidPointIntervals();
static void calculateIntervalsOfValidValues(const std::vector<double>& values, std::vector< std::pair<size_t, size_t> >* intervals);
static void addValuesFromIntervals(const std::vector<double>& values, const std::vector< std::pair<size_t, size_t> >& intervals, std::vector<double>* filteredValues);
static void filteredIntervals(const std::vector< std::pair<size_t, size_t> >& intervals, std::vector< std::pair<size_t, size_t> >* fltrIntervals);
private:
std::vector<double> m_xValues;
std::vector<double> m_yValues;
std::vector< std::pair<size_t, size_t> > m_validPointIntervals;
};

View File

@ -19,6 +19,8 @@
#include "RigWellLogFile.h" #include "RigWellLogFile.h"
#include "RimWellLogPlotCurve.h"
#include "well.hpp" #include "well.hpp"
#include "laswell.hpp" #include "laswell.hpp"
@ -234,3 +236,43 @@ QString RigWellLogFile::wellLogChannelUnit(const QString& wellLogChannelName) co
return unit; return unit;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigWellLogFile::exportToLasFile(const RimWellLogPlotCurve* curve, const QString& fileName)
{
CVF_ASSERT(curve);
const RigWellLogCurveData* curveData = curve->curveData();
if (!curveData)
{
return false;
}
double minX, maxX;
curve->valueRange(&minX, &maxX);
// Might want to use a different way to find an absent/"null" value, maybe use the default if possible
double absentValue = ((size_t) maxX) + 1000;
std::vector<double> wellLogValues = curveData->xValues();
for (size_t vIdx = 0; vIdx < wellLogValues.size(); vIdx++)
{
double value = wellLogValues[vIdx];
if (value == HUGE_VAL || value == -HUGE_VAL || value != value)
{
wellLogValues[vIdx] = absentValue;
}
}
NRLib::LasWell lasFile;
lasFile.AddLog("DEPTH", "m", "Depth [m]", curveData->yValues());
lasFile.AddLog(curve->name().trimmed().toStdString(), "NO_UNIT", "PARAMETERINFO", wellLogValues);
lasFile.SetMissing(absentValue);
std::vector<std::string> commentHeader;
lasFile.WriteToFile(fileName.toStdString(), commentHeader);
return true;
}

View File

@ -30,6 +30,7 @@ namespace NRLib
class Well; class Well;
} }
class RimWellLogPlotCurve;
//================================================================================================== //==================================================================================================
/// ///
@ -51,6 +52,8 @@ public:
QString depthUnit() const; QString depthUnit() const;
QString wellLogChannelUnit(const QString& wellLogChannelName) const; QString wellLogChannelUnit(const QString& wellLogChannelName) const;
static bool exportToLasFile(const RimWellLogPlotCurve* curve, const QString& fileName);
private: private:
void close(); void close();

View File

@ -19,6 +19,9 @@
#include "RiuWellLogPlotCurve.h" #include "RiuWellLogPlotCurve.h"
#include "RigWellLogCurveData.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -33,14 +36,6 @@ RiuWellLogPlotCurve::~RiuWellLogPlotCurve()
{ {
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlotCurve::setPlotIntervals(const std::vector<std::pair<size_t, size_t> >& intervals)
{
m_intervals = intervals;
};
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -58,3 +53,17 @@ void RiuWellLogPlotCurve::drawCurve(QPainter* p, int style,
} }
else QwtPlotCurve::drawCurve(p, style, xMap, yMap, canvasRect, from, to); else QwtPlotCurve::drawCurve(p, style, xMap, yMap, canvasRect, from, to);
}; };
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlotCurve::setCurveData(const RigWellLogCurveData* curveData)
{
CVF_ASSERT(curveData);
std::vector<double> validXValues = curveData->validXValues();
std::vector<double> validYValues = curveData->validYValues();
setSamples(validXValues.data(), validYValues.data(), (int) validXValues.size());
m_intervals = curveData->validPointsIntervals();
}

View File

@ -23,6 +23,8 @@
#include <vector> #include <vector>
class RigWellLogCurveData;
//================================================================================================== //==================================================================================================
/// ///
/// ///
@ -30,10 +32,11 @@
class RiuWellLogPlotCurve : public QwtPlotCurve class RiuWellLogPlotCurve : public QwtPlotCurve
{ {
public: public:
RiuWellLogPlotCurve(); RiuWellLogPlotCurve();
virtual ~RiuWellLogPlotCurve(); virtual ~RiuWellLogPlotCurve();
void setPlotIntervals(const std::vector<std::pair<size_t, size_t> >& intervals); void setCurveData(const RigWellLogCurveData* curveData);
protected: protected:
@ -42,5 +45,5 @@ protected:
const QRectF& canvasRect, int from, int to) const; const QRectF& canvasRect, int from, int to) const;
private: private:
std::vector< std::pair<size_t, size_t> > m_intervals; std::vector< std::pair<size_t, size_t> > m_intervals;
}; };