Skip to content

Commit

Permalink
Fix import.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriben committed Jan 29, 2024
1 parent a4e9756 commit 4b4920b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 26 deletions.
25 changes: 15 additions & 10 deletions ApplicationLibCode/Commands/RicImportWellLogCsvFileFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,9 @@ void RicImportWellLogCsvFileFeature::onActionTriggered( bool isChecked )

RimWellLogCsvFile* wellLogCsvFile = new RimWellLogCsvFile;
wellLogCsvFile->setFileName( fileName );
QString errorMessage;
if ( !wellLogCsvFile->readFile( &errorMessage ) )
{
delete wellLogCsvFile;
wellLogCsvFile = nullptr;

QString displayMessage = "Errors opening the CSV file: \n" + errorMessage;
RiaLogging::errorInMessageBox( Riu3DMainWindowTools::mainWindowWidget(), "File open error", displayMessage );
return;
}

RimOilField* oilField = RimProject::current()->activeOilField();

if ( oilField == nullptr ) return;

if ( !oilField->wellPathCollection )
Expand All @@ -85,6 +76,20 @@ void RicImportWellLogCsvFileFeature::onActionTriggered( bool isChecked )
}

oilField->wellPathCollection->addWellLog( wellLogCsvFile, wellPath );

QString errorMessage;
if ( !wellLogCsvFile->readFile( &errorMessage ) )
{
wellPath->deleteWellLogFile( wellLogCsvFile );
QString displayMessage = "Errors opening the CSV file: \n" + errorMessage;
RiaLogging::errorInMessageBox( Riu3DMainWindowTools::mainWindowWidget(), "File open error", displayMessage );
return;
}
else
{
wellLogCsvFile->updateConnectedEditors();
}

app->setLastUsedDialogDirectory( pathCacheName, QFileInfo( fileName ).absolutePath() );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "RimViewWindow.h"
#include "RimWellAllocationPlot.h"
#include "RimWellLogLasFile.h"
#include "RimWellLogFile.h"
#include "RimWellLogPlot.h"
#include "RimWellPath.h"
#include "RimWellPltPlot.h"
Expand All @@ -40,7 +40,7 @@ CAF_CMD_SOURCE_INIT( RicWellLogFileCloseFeature, "RicWellLogFileCloseFeature" );
//--------------------------------------------------------------------------------------------------
bool RicWellLogFileCloseFeature::isCommandEnabled() const
{
std::vector<RimWellLogLasFile*> objects = caf::selectedObjectsByType<RimWellLogLasFile*>();
std::vector<RimWellLogFile*> objects = caf::selectedObjectsByType<RimWellLogFile*>();
return !objects.empty();
}

Expand All @@ -49,7 +49,7 @@ bool RicWellLogFileCloseFeature::isCommandEnabled() const
//--------------------------------------------------------------------------------------------------
void RicWellLogFileCloseFeature::onActionTriggered( bool isChecked )
{
std::vector<RimWellLogLasFile*> objects = caf::selectedObjectsByType<RimWellLogLasFile*>();
std::vector<RimWellLogFile*> objects = caf::selectedObjectsByType<RimWellLogFile*>();

if ( objects.empty() ) return;

Expand Down Expand Up @@ -85,7 +85,7 @@ void RicWellLogFileCloseFeature::setupActionLook( QAction* actionToSetup )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RimViewWindow*> RicWellLogFileCloseFeature::referringWellLogPlots( const RimWellLogLasFile* wellLogFile )
std::set<RimViewWindow*> RicWellLogFileCloseFeature::referringWellLogPlots( const RimWellLogFile* wellLogFile )
{
// Remove all curves displaying data from the specified wellLogFile
std::vector<caf::PdmObjectHandle*> referringObjects = wellLogFile->objectsWithReferringPtrFields();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "cafCmdFeature.h"
#include <set>

class RimWellLogLasFile;
class RimWellLogFile;
class RimViewWindow;

//==================================================================================================
Expand All @@ -37,5 +37,5 @@ class RicWellLogFileCloseFeature : public caf::CmdFeature
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;

std::set<RimViewWindow*> referringWellLogPlots( const RimWellLogLasFile* wellLogFile );
std::set<RimViewWindow*> referringWellLogPlots( const RimWellLogFile* wellLogFile );
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "RimWellLogCsvFile.h"

#include "RiaFieldHandleTools.h"
#include "RiaLogging.h"

#include "RigWellLogCsvFile.h"

Expand Down Expand Up @@ -73,12 +74,15 @@ bool RimWellLogCsvFile::readFile( QString* errorMessage )
auto wellPath = firstAncestorOrThisOfType<RimFileWellPath>();
if ( !wellPath )
{
RiaLogging::error( "No well path found" );
return false;
}

if ( !m_wellLogDataFile->open( m_fileName().path(), wellPath->wellPathGeometry(), errorMessage ) )
{
m_wellLogDataFile = nullptr;
RiaLogging::error( "Failed to open file." );

return false;
}

Expand Down
4 changes: 2 additions & 2 deletions ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ void RimWellPath::addWellLogFile( RimWellLogFile* logFileInfo )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::deleteWellLogFile( RimWellLogLasFile* logFileInfo )
void RimWellPath::deleteWellLogFile( RimWellLogFile* logFileInfo )
{
detachWellLogFile( logFileInfo );
delete logFileInfo;
Expand All @@ -928,7 +928,7 @@ void RimWellPath::deleteWellLogFile( RimWellLogLasFile* logFileInfo )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::detachWellLogFile( RimWellLogLasFile* logFileInfo )
void RimWellPath::detachWellLogFile( RimWellLogFile* logFileInfo )
{
auto pdmObject = dynamic_cast<caf::PdmObjectHandle*>( logFileInfo );
for ( size_t i = 0; i < m_wellLogFiles.size(); i++ )
Expand Down
6 changes: 3 additions & 3 deletions ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RigWellPath;
class RigWellPathFormations;

class RimProject;
class RimWellLogLasFile;
class RimWellLogFile;
class RimFractureTemplateCollection;
class RimStimPlanModelCollection;
class RimFishbonesCollection;
Expand Down Expand Up @@ -106,8 +106,8 @@ class RimWellPath : public caf::PdmObject, public RimWellPathComponentInterface
double uniqueEndMD() const;

void addWellLogFile( RimWellLogFile* logFileInfo );
void deleteWellLogFile( RimWellLogLasFile* logFileInfo );
void detachWellLogFile( RimWellLogLasFile* logFileInfo );
void deleteWellLogFile( RimWellLogFile* logFileInfo );
void detachWellLogFile( RimWellLogFile* logFileInfo );
std::vector<RimWellLogFile*> wellLogFiles() const;
RimWellLogFile* firstWellLogFileMatchingChannelName( const QString& channelName ) const;

Expand Down
19 changes: 16 additions & 3 deletions ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool RigWellLogCsvFile::open( const QString& fileName, RigWellPath* wellPath, QS
{
m_wellLogChannelNames.clear();

RifCsvUserDataFileParser parser( fileName );
RifCsvUserDataFileParser parser( fileName, errorMessage );

AsciiDataParseOptions parseOptions;
parseOptions.useCustomDateTimeFormat = true;
Expand Down Expand Up @@ -89,14 +89,21 @@ bool RigWellLogCsvFile::open( const QString& fileName, RigWellPath* wellPath, QS
}
}

std::vector<double> readTvds = readValues[m_tvdMslLogName];
if ( m_tvdMslLogName.isEmpty() )
{
QString message = "CSV file does not have TVD values.";
RiaLogging::error( message );
if ( errorMessage ) *errorMessage = message;
return false;
}

m_values[m_depthLogName] = wellPath->measuredDepths();
std::vector<double> readTvds = readValues[m_tvdMslLogName];

for ( auto [channelName, readValues] : readValues )
{
if ( channelName == m_tvdMslLogName )
{
// Use TVD from well path.
m_values[m_tvdMslLogName] = wellPath->trueVerticalDepths();
}
else
Expand All @@ -106,6 +113,8 @@ bool RigWellLogCsvFile::open( const QString& fileName, RigWellPath* wellPath, QS
auto wellPathMds = wellPath->measuredDepths();
auto wellPathTvds = wellPath->trueVerticalDepths();

// Interpolate values for the well path depths (from TVD).
// Assumes that the well channel values is dependent on TVD only (MD is not considered).
std::vector<double> values;
for ( auto tvd : wellPathTvds )
{
Expand All @@ -117,6 +126,10 @@ bool RigWellLogCsvFile::open( const QString& fileName, RigWellPath* wellPath, QS
}
}

// Use MD from well path.
m_depthLogName = "DEPTH";
m_values[m_depthLogName] = wellPath->measuredDepths();

return true;
}

Expand Down
3 changes: 1 addition & 2 deletions ApplicationLibCode/ReservoirDataModel/RigWellLogCsvFile.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
// Copyright (C) 2024- 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
Expand Down

0 comments on commit 4b4920b

Please sign in to comment.