Visualising the distribution of data with histograms

Photo by Marcin Jozwiak on Unsplash


Histograms are a commonly used tool within exploratory data analysis and data science. They are an excellent data visualisation tool and appear similar to bar charts. However, histograms allow us to gain insights about the distribution of the values within a set of data and allow us to display a large range of data in a concise plot. Within the petrophysics and geoscience domains, we can use histograms to identify outliers and also pick key interpretation parameters. For example, clay volume or shale volume end points from a gamma ray.

To create a histogram:

  • We first take a logging curve…

Examples of machine learning to enhance your petrophysical workflow

Photo by Dan Meyers on Unsplash

Several decades of hydrocarbon exploration have led to the acquisition and storage of large quantities of well related measurements, which have been used to characterise the subsurface geology and its hydrocarbon potential. The potential of these large volumes of data has been increasingly exploited over the last couple of decades as computational power and the adoption of new machine learning algorithms increase. Within the petrophysical domain, machine learning has been used to speed up workflows, characterise the geology into discrete electrofacies, make predictions, and much more.

What is Petrophysics?

Petrophysics is a discipline that studies the physical and chemical properties of rocks and…

A Python library dedicated to loading and exploring well log LAS files

Photo by ali elliott on Unsplash

The welly library was developed by Agile Geoscience to help with loading, processing and analysing well log data from a single well or multiple wells. The library allows exploration of the meta data found within the headers of las files and also contains a plotting function to display a typical well log. Additionally, the welly library contains tools for identifying and handling data quality issues.

The Welly library can be found at the Agile Geoscience GitHub at

In this short tutorial we will see how to load a well from the Volve field and exploring some of the functionality…

An example using petrophysical well log measurements

Photo by Tim Mossholder on Unsplash

Data exploration and pre-processing are important steps within any data science or machine learning workflow. When working on tutorial or training datasets it can be the case that they have been engineered in a way to make it easy to work with and allow the algorithm being discussed to be run successfully. However, in the real world, data is messy! It can have erroneous values, incorrect labels and parts of it can be missing.

Missing data is probably one of the most common issues when working with real datasets. Data can be missing for a multitude of reasons, including sensor…

Subdividing the subsurface using Python

Application of unsupervised cluster analysis on well log data to identify lithofacies (Image by Author)

Understanding the subsurface lithology is an important task in geoscience and petrophysics. Using a variety of electrical measurements generated from well logging technology we are able to make inferences about the underlying geology, such as the lithology, facies, porosity, and permeability.

Machine Learning algorithms have routinely been adopted to group well log measurements into distinct lithological groupings, known as facies. This process can be achieved using either unsupervised learning or supervised learning algorithms.

Supervised learning is the most common and practical of machine learning tasks and it is designed to learn from example using input data that has been mapped…

A short tutorial on loading and displaying processed acoustic waveform data using dlisio and matplotlib

matplotlib plot showing a semblance map on the left and waveform data on the right. Image by the author.


There are a number of different formats that well log and petrophysical data can be stored in. In the earlier articles and notebooks of this series, we have mainly focused on loading data from CSV files (here) and LAS files (here and here). Even though LAS files are one of the common formats, they have a flat structure with a header section containing metadata about the well and the file followed by a series of columns containing values for each logging curve. As they are flat, they can’t easily store array data. It is possible, but the individual elements of…

Taking well log plots one step further using Python and matplotlib

Final well log plot generated using Python’s matplotlib library and contains variable fill on the gamma ray, and a neutron-density crossover fill. Image by author.

Well log plots are a common visualization tool within geoscience and petrophysics. They allow easy visualization of data (for example, Gamma Ray, Neutron Porosity, Bulk Density, etc) that has been acquired along the length (depth) of a wellbore.

I have previously covered different aspects of making these plots in the following articles:

In this article, I will show how to combine these different methods into a single…

Appending Multiple LAS Files to a Pandas Dataframe

Crossplots of density vs neutron porosity from multiple wells using the Python library matplotlib. Imagae created by the author.

Log ASCII Standard (LAS) files are a common Oil & Gas industry format for storing and transferring well log data. The data contained within is used to analyze and understand the subsurface, as well as identify potential hydrocarbon reserves. In my previous article: Loading and Displaying Well Log Data, I covered how to load a single LAS file using the LASIO library.

In this article, I expand upon that by showing how to load multiple las files from a subfolder into a single pandas dataframe. Doing this allows us to work with data from multiple wells and visualize the data…

Using fill_betweenx() in matplotlib to add variable color fills and hatches for geological lithology data

Well log plot with gamma ray, neutron porosity and bulk density data plotted alongside lithology data.
Well log plot with gamma ray, neutron porosity and bulk density data plotted alongside lithology data.
Well log plot with gamma ray, neutron porosity and bulk density data plotted alongside lithology data. Image created by the author.

Adding lithology information to a well log plot can enhance a petrophysical or geological interpretation. It can be used to understand why some log responses may behave the way they do. This data may have been sourced from a previous mineralogical interpretation or from mud logs.

In my previous article: Enhancing Visualization of Well Logs With Plot Fills, we saw: how to apply fixed color fill between a curve and the edge of a track, how to apply a density-neutron crossover fill and how to apply a variable fill based upon the value of curve being plotted.

In this article…

Utilizing the power of matplotlib to display wellbore image data

Logging While Drilling image data displayed using matplotlib in Python. Image created by the author.


Borehole image logs are false-color pseudo images of the borehole wall generated from different logging measurements/tools. How borehole images are acquired differs between wireline logging and logging while drilling (LWD). In the wireline environment measurements are made from buttons on pads that are pressed up against the borehole wall and provide limited coverage, but at a high resolution. In contrast, in the LWD environment measurements are made from sensors built into tools that form part of the drillstring/tool assembly, and using the tool rotation, provide full 360-degree coverage. LWD image data is often split into sectors, the number of which…

Andy McDonald

Petrophysicist | Geoscientist | Data Scientist with a strong interest in data analytics, machine learning and artificial intelligence.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store