Visualising Well Paths on 3D Line Plots with Plotly Express | by Andy McDonald | Jun, 2023


Working With Plotly Express 3D Line Plots

3D Well path visualisation with Plotly Express. Image by the author.

Visualisation is one of the critical tasks we use to understand well log data and the subsurface. This includes viewing data on well log plots, scatter plots and histograms. By doing this, we can gain a solid understanding of our data. However, working with 2D plots is sometimes not enough and we need that extra dimension by going to 3D.

One excellent use case for 3D visualisations within petrophysics and geoscience is to visualise the path of a well.

In the early days of oil and gas exploration, wells were drilled vertically into the subsurface. However, as technology advanced, the industry shifted from vertical to horizontal drilling and eventually to drilling complex well paths facilitated by using the innovation of geosteering.

This evolution in well path geometry underscores the importance of visualising well paths in three dimensions. Doing so allows us to gain a better understanding of how wells have penetrated the geological layers, and to plan future wells to avoid collisions or issues.

Within this article, we will look at how we can take well survey data, which records the position of a well, and display it using a 3D line plot from Plotly Express.

For this short tutorial, we are going to be using surveys from eight wells located in the Dutch Sector of the North Sea. This data has been sourced from the NLOG.nl website, which provides free-to-use well log data that has been acquired over the past several decades.

These files contain the following columns:

  • MD: Measured Depth (m)
  • INC: Borehole Inclination (degrees)
  • AZI: Borehole Azimuth (degrees)
  • TVD: True Vertical Depth (m)
  • XOFFSET: Position of the well in the X direction (m)
  • YOFFSET: Position of the well in the Y direction (m)

To make data loading easier, the column names in each file are the same.

Full details of the dataset can be found at the end of the article.

Additionally, all of the wells used in this tutorial share the same origin. I will be covering how we can convert the XOFFSET and YOFFSET to grid coordinates in a future article.

First, we need to import a number of libraries. For this article, we will keep it relatively simple by importing pandas — to read our csv data and Plotly Express to create our visualisation and os to allow us to read our directory with the files.

import pandas as pd
import plotly.express as px

import os

We can load the data into Python and Pandas in a few ways.

To simplify things, I have kept the code in long-form to help those new to Python understand what is happening.

First, we need to create an empty list to store our file paths in.

# Create empty list to store file paths
survey_data = []

Next, we will create a variable to store the file path location of our CSV files that contain the survey data.

# Set up the file path location. This can be a relative or absolute path
file_path = 'Data/Notebook 43/'

Finally, we can loop through each file within the file_path directory and check for any files with a .csv extension. Once it finds these files, the full file path is then appended onto the file_path list.

# Loop through each file within the file_path location
for f in os.listdir(file_path):
# Check for CSV files
if f.endswith('.csv'):
# Add CSV file location to the survey_data list
survey_data.append(f'{file_path}{f}')

survey_data

When we view the survey_data list we get back the following:

['Data/Notebook 43/NLOG - A12-A-01 - Survey.csv',
'Data/Notebook 43/NLOG - A12-A-06 - Survey.csv',
'Data/Notebook 43/NLOG - A12-A-07 - Survey.csv',
'Data/Notebook 43/NLOG - A12-A-02 - Survey.csv',
'Data/Notebook 43/NLOG - A12-A-05 - Survey.csv',
'Data/Notebook 43/NLOG - A12-A-07-ST1 - Survey.csv',
'Data/Notebook 43/NLOG - A12-A-04 - Survey.csv',
'Data/Notebook 43/NLOG - A12-A-03 - Survey.csv']

Once we have the file paths, we need to combine them into a single pandas dataframe using .concat from pandas and the map function.

df = pd.concat(map(pd.read_csv, survey_data))

When we view the dataframe (df) we will get back the following.

Dataframe of the combined well survey data from eight Dutch Sector oil and gas wells. Image by the author.

Alternatively, if you are a more advanced Python user and are looking for something more efficient to load multiple files directly into a pandas dataframe, then you can use the following function.

As you can see, it is much more condensed.

# Alternatively:
import glob
df = pd.concat(map(pd.read_csv, glob.glob('Data/Notebook 43/*.csv')))

To confirm that we have all of the wells loaded, we can call upon the WELL column and view the unique values within it.

df['WELL'].unique()

Which returns an array containing 8 wells.:

array(['A12-A-01', 'A12-A-06', 'A12-A-07', 'A12-A-02', 'A12-A-05',
'A12-A-07-ST1', 'A12-A-04', 'A12-A-03'], dtype=object)

For this example, we will use the 3D line plot from Plotly Express rather than using matplotlib’s 3D plot. From my experience, generating and working with 3D plots this way seems quicker, more efficient, and easier.

To create our 3D Line plot with Plotly Express, we first need to create a figure and assign it to px.line_3d().

Within this function, we will pass in our XOFFSET, YOFFSET, TVD and WELL columns.

This will allow us to plot the X, Y and TVD (True Vertical Depth) position of each well, an differentiate them with colour using the WELL column.

fig = px.line_3d(x=df.XOFFSET, 
y=df.YOFFSET,
z=df.TVD,
color=df.WELL)
fig.show()

Once we run the above code, we get back the following figure.

Plotly Express 3D Line plot showing well paths prior to making adjustments to scales and lines. Image by the author.

It is obvious from the figure that we need to tweak this to get something that is much better.

There are a few issues with this plot that we need to address:

  • the overall figure is small
  • the line widths are very thin
  • the well paths are upside down

We can resolve this with a few tweaks.

First, we will update the layout of the plot and define a width & height parameter.

Then we will update the z-axis, which contains the TVD measurement, and we will set it so the scale is in reverse.

Finally, we can make the lines thicker by using the call to update_traces().

fig = px.line_3d(x=df.XOFFSET, 
y=df.YOFFSET,
z=df.TVD,
color=df.WELL)

fig.update_layout(width=800,
height=800,
autosize=False,
scene={'zaxis':{'autorange':'reversed'}})

fig.update_traces(line={'width':10})

fig.show()

When we run the above code, we get back the following interactive figure.

Plotly Express 3D Line plot showing well paths after to making adjustments to scales and lines. Image by the author.

We can see that our well paths are now orientated correctly, and we have a slightly bigger figure to work with.

Visualising data this way allows us to see where the wells are going and if there are any sidetracks from any of the wells. If we were focusing on planning future wells, we would be able to identify any potential issues early on in the process.

Visualising well paths is an excellent way to understand where your well is. Not only where it is located in the subsurface but also in relation to other nearby wells.

Within this short tutorial, we have seen how we can utilise Python and the Plotly Express library to visualise multiple well paths on an interactive 3D plot. This allows us to gain a solid understanding of where our wells are located in an easy-to-use way.

Give it a try on your next project.

The data used within this tutorial was downloaded from NLOG.nl, which is a website that contains well logging data for the entire Dutch sector of the North Sea. The data is free to download and use. Full details of the data licence can be found here, but a summary of the usage is provided here from the Intellectual Property Rights section:

NLOG.NL does not claim any rights (except domain names, trademark rights, patents and other intellectual property rights) in respect of information provided on or through this website. Users are permitted to copy, to download and to disclose in any way, to distribute or to simplify the information provided on this website without the prior written permission of NLOG.NL or the lawful consent of the entitled party. Users are also permitted to copy, duplicate, process or edit the information and/or layout, provided NLOG.NL is quoted as the source.



Source link

Leave a Comment