I’ve been spending some time recently revisiting some of my earlier python workflows and articles, particularly those that focus on data loading and file formats. When I went back to my original LAS article, it became clear that parts of it were a bit haphazard and not as clearly explained as they could have been.
Part of this was simply about updating and improving the content. But, it’s also part of a broader effort to gradually reorganise and consolidate material for a new e-book I’ve been working towards for some time: Python for Well Log Data Analysis and Visualisation. That’s still very much a work in progress.
LAS is an old and deliberately simple file format for storing and transferring well log data. And yet it still underpins a huge amount of subsurface work. If you’re using Python with well log data, chances are you’re relying on LAS files whether you think about them or not.
This article takes a step back to look at what LAS files actually are, how they’re structured, and how I use lasio to read and inspect them properly in Python before moving on to anything more involved.
What is a LAS file?
At its core, a LAS file is simply a plain-text file designed to store well log data in a way that can be shared between companies, software packages, and decades of technology change.
The name comes from the Log ASCII Standard. That last bit matters: this isn’t a binary or fancy proprietary format. It’s raw text, which makes it human readable, scriptable, and durable.
This also means that they are flat files that can easily be opened and read within a simple text editor allowing you to read the contents without any specialised software.
This simplicity is the reason LAS has survived for so long, and also the reason it sometimes feels a bit too simplistic, especially when it comes to working with multi-dimensional arrays.
A typical LAS file contains:
Metadata about the well, including field name, well name, location, and company
Sometimes more detailed well metadata including information about mud types and processing parameters
Information about each log curve, including units, descriptions and mnemonics
Depth or time indexed logging measurements
A short history of LAS
The LAS standard emerged in the late 1980s, championed by industry groups like the Canadian Well Logging Society. At the time, the problem was painfully simple: companies were exchanging well logs on floppy disks, magnetic tapes, even printed listings. Without a solid standard, data would get mangled in transit, curves renamed, units lost, depth references shifted.
So the industry codified something basic, but workable across a variety of platforms. The idea wasn’t to build a full data model, it was to reduce the risk of information loss every time data changed hands.
Over the years a few versions of LAS have appeared:
LAS 1.2: The oldest variant released in 1989. It’s rigid and minimal. Many older files still in circulation are LAS 1.2.
LAS 2.0: The most commonly used today and released in 1992. It introduces more flexibility, better curve headers, clearer units, slightly more formal metadata handling. LAS 2.0 remains the most dominant version in use today.
LAS 3.0: Ambitious and richer version of LAS, with support for objects and more complex metadata released in 1999. In principle it modernises what LAS can express, but in practice adoption has been limited. Many tools and workflows still treat LAS 3.0 support as optional or partial.
In practice, the real world of LAS is messy: the standard sets the intended structure, but files from different vendors or vintage wells often bend those rules. Part of working with LAS (especially in code) is recognising that reality.
Why LAS endures
Despite its age and quirks, LAS is still the lingua franca of well logs for a few reasons:
It’s text. You don’t need special software to inspect it.
It’s ubiquitous. Virtually every subsurface package supports the basics.
It’s simple. There’s only so much you can do wrong before a human notices.
That doesn’t make it perfect, but it just makes it practical. And that’s why libraries like lasio exist: to bridge between this old-school format and modern Python workflows.
The LAS 2.0 format
Most LAS files you’ll encounter today follow LAS version 2.0. Understanding what LAS 2.0 expects helps explain both why files are structured the way they are.
At a high level, a LAS 2.0 file is a structured ASCII text file. It contains:
A header made up of multiple sections
Followed by a single block of log data
LAS 2.0 is deliberately conservative about character encoding. It allows:
Carriage return (ASCII 13) and line feed (ASCII 10) for new lines
Standard printable ASCII characters (ASCII 32 to ASCII 126)
Having this standard matters, as LAS files were designed to survive being moved between operating systems, software packages, and even through decades. If a LAS file breaks, it’s usually because something ignored this rule or there has been .
One continuous interval per file
A key constraint in LAS 2.0 is that each file contains only one continuous data interval.
In practical terms:
A main pass and a repeat pass should be separate files
You shouldn’t expect multiple depth intervals stitched together in one
~Asection
Real data doesn’t always behave, but this assumption is baked into many tools — including how libraries like lasio interpret the file.
File naming and recognition
LAS files conventionally end with .las.
Sections and the tilde rule
A LAS file is divided into multiple sections, each introduced by a line beginning with a tilde (~) as the first non-space character.
The character immediately after the tilde identifies the section type. In LAS 2.0, the reserved section identifiers are:
~V— Version information: This tells you what version the LAS file is written in and how the rest of the file should be interpreted.~W— Well information: This section contains metadata about the well and the logging run, not the logs themselves. This includes the location of the well, start and stop depth of the file, field name.~C— Curve information: This section defines what each curve actually is and is split into: Curve Mnemonic, Units and a Short Description~P— Parameters: This section provides information about run-level parameters, tool settings, environmental corrections and processing constants. However, this section is not always present.~O— Other information: This section can include processing comments, notes from the logging engineer, remarks. This section may also be left blank or absent from the file.~A— ASCII data: This is the section that contains all of the measurements for the curves listed in the~Csection. Each row represents one depth level. In some instances data rows can be wrapped to reduce the amount of horizontal scrolling required.
Each of these sections may appear only once per file.
Custom sections are allowed, but they must appear:
After the
~VsectionBefore the final
~Asection
This ordering is important.
Comments and control characters
LAS uses two special characters at the start of a line:
#marks a comment~marks the start of a section
Everything else is treated as content.
Header line structure
Several header sections — VERSION, WELL, CURVE, and PARAMETER use a specific line structure built around delimiters.
Each line is split using:
The first dot (
.)The first space after that dot
The final colon (
:)
This gives you, in order:
A mnemonic
Units
A value
A description
You don’t need to memorise the delimiters, but it helps to know they exist. When headers look odd, or units go missing, it’s usually because one of these delimiters has been missed.
Reading LAS Files with Python Using LASIO
There are a number of Python libraries available that can work with LAS files, but the most common is lasio.
lasio library developed by Kent Inverarity, to load a las file into Python and then explore its contents.
Loading and Checking Data
After understanding how LAS files are structured, the next step is load the data into Python in a way that can preserve this structure without flattening it into an anonymous table..
1. Installing and importing lasio
If you don’t already have lasio installed, it’s available via pip:
pip install lasioOnce installed, it is common to work with lasio alongside numpy and pandas:
import pandas as pd
import matplotlib.pyplot as plt
import lasio2. Reading a LAS file
Reading a LAS file is very simple, and can be done using the .read() method from lasio:
las = lasio.read("path/to/well.las")At this point lasio has simply parsed the file according to the LAS standard and exposed its contents. There is no resampling to changing of the data happening.
If you are working with older files or vendor exports, you may occasionally need to specify an encoding explicitly:
las = lasio.read("path/to/well.las", encoding="latin-1")3. A Quick Contents Check
Before touching the las data, it’s worth asking a basic question: what did I actually load?
You can do that in a few simple ways.
A simple print statement will return back the lasio object
print(las)
<lasio.las.LASFile object at 0x000001383BA7E100>Which doesn’t not reveal very much, but shows that a lasio LASFile object has been created.
To see what curves are available:
[c.mnemonic for c in las.curves]['DEPTH',
‘LFP_AI’,
‘LFP_AI_B’,
‘LFP_AI_G’,
‘LFP_AI_LOG’,
‘LFP_AI_O’,
‘LFP_AI_V’,
‘LFP_API’,
‘LFP_BADDATA’,
‘LFP_BVWE’,
‘LFP_BVWT’,
‘LFP_CALI’,
‘LFP_COAL’,
‘LFP_DT’,
‘LFP_DT_B’,
‘LFP_DT_G’,
‘LFP_DT_LOG’,
‘LFP_DT_O’,
‘LFP_DT_SYNT’,
‘LFP_DT_V’,
‘LFP_DTCORFSFLAG’,
‘LFP_DTLOGFLAG’,
‘LFP_DTS’,
‘LFP_DTS_B’,
‘LFP_DTS_G’,
...
‘LFP_VSHDRY’,
‘LFP_VSHDRYC’,
‘LFP_VSHDRYWC’,
‘LFP_VSHGR’,
‘LFP_WATER’]And to inspect curve names, units, and descriptions together:
for c in las.curves:
print(f"{c.mnemonic} {c.unit} {c.descr}")DEPTH M Measured Depth
LFP_AI kPa.s/m v1
LFP_AI_B kPa.s/m v1
LFP_AI_G kPa.s/m v1
LFP_AI_LOG kPa.s/m v1
LFP_AI_O kPa.s/m v1
LFP_AI_V kPa.s/m v1
LFP_API g/cm3 v1
LFP_BADDATA unitless v1
LFP_BVWE v/v_decimal v1
LFP_BVWT v/v_decimal v1
LFP_CALI inches v1
LFP_COAL unitless v1
LFP_DT us/ft v0 (auto-composite)
LFP_DT_B us/ft v1
LFP_DT_G us/ft v1
LFP_DT_LOG us/ft v0 (auto-composite)
LFP_DT_O us/ft v1
LFP_DT_SYNT us/ft v1
LFP_DT_V us/ft v1
LFP_DTCORFSFLAG unitless v1
LFP_DTLOGFLAG unitless v1
LFP_DTS us/ft v0 (auto-composite)
LFP_DTS_B us/ft v1
LFP_DTS_G us/ft v1
...
LFP_VSHDRYC v/v_decimal v1
LFP_VSHDRYWC v/v_decimal v1
LFP_VSHGR v/v_decimal v1
LFP_WATER unitless v1This is often the first place you discover duplicated curves, unexpected units, or naming inconsistencies.
4. Understanding the index curve
LAS files typically use depth (or time) as an index. lasio makes this explicit:
las.index
las.index_unitarray([3500.0183, 3500.1707, 3500.323 , ..., 4094.6831, 4094.8354,
4094.9878])
‘M’Knowing the index curve and its units early avoids subtle mistakes later, especially when combining data from multiple wells.
5. Inspecting Header Metadata
We can also inspect the header metadata from the LAS file, for example the well section (~W):
for item in las.well:
print(item.mnemonic, item.unit, item.value, "-", item.descr)STRT M 3500.0183 - START DEPTH
STOP M 4094.9878 - STOP DEPTH
STEP M 0.1524 - STEP
NULL -999.25 - NULL VALUE
COMP STATOIL PETROLEUM AS - COMPANY
WELL 15/9-19 - WELL
FLD VOLVE - FIELD
LOC UNKNOWN - LOCATION
CNTY UNKNOWN - COUNTY
STAT UNKNOWN - STATE
CTRY Norway - COUNTRY
SRVC UNKNOWN - SERVICE COMPANY
DATE UNKNOWN - LOG DATE
UWI NO 15/9-19 A - UNIQUE WELL ID
XCOORD 1.928158 - SURFACE X
YCOORD 58.435286 - SURFACE Y
LAT 58.435286 - LATITUDE
LON 1.928158 - LONGITUDE
ELEV M 25.0 - SURFACE ELEV
ELEV_TYPE KB - ELEV TYPEThe header is where you’ll often find:
Start and stop depths
Step size
Field name
Company name
Well Location
The NULL value used in the file
That NULL value is particularly important:
null_item = las.well.get("NULL")
null_itemHeaderItem(mnemonic="NULL", unit="", value="-999.25", descr="NULL VALUE")6. Accessing Curve Data
You can access individual curves by mnemonic:
las["GR"]array([36.621, 36.374, 30.748, ..., nan, nan, nan])Or pull multiple curves together into a numpy array:
curves = ["DEPTH”, "GR", "DTS"]
data = np.vstack([np.asarray(las[c]) for c in curves]).Tarray([[3500.0183, 36.621 , 157.1754],
[3500.1707, 36.374 , 158.9566],
[3500.323 , 30.748 , 159.7642],
...,
[4094.6831, nan, 128.407 ],
[4094.8354, nan, 127.217 ],
[4094.9878, nan, 127.758 ]])Depth values are available separately via the index:
depth = np.asarray(las.index)array([3500.0183, 3500.1707, 3500.323 , ..., 4094.6831, 4094.8354,
4094.9878])At this stage you are working with raw numerical arrays, but still tied back to curve definitions and metadata.
Displaying LAS File Data in Other Forms
Displaying curve data and information using pandas
For the majority of data analysis tasks, a pandas DataFrame is a common and is also often the the most convenient way to represent tabular data.
lasio provides a way to convert the data section to a DataFrame directly:
df = las.df()
df.head()
LAS Curve Data represented as a DataFrame using lasio.
By default:
The index is depth or time
Columns are curve mnemonics
If you prefer the index as a column:
df = df.reset_index()In addition to creating DataFrames of the curve data, we can quickly and easily construct them using the other metadata. For example, if we want to present the Curve Information section as a DataFrame:
curve_table = pd.DataFrame(
[{"mnemonic": c.mnemonic, "unit": c.unit, "description": c.descr}
for c in las.curves]
)
curve_tableDisplaying curve information as a rich table
Once you start inspecting LAS files regularly, printing curve metadata line by line gets old quickly. It works, but it’s not especially readable, particularly when you’re dealing with dozens of curves or comparing files.
This is where the rich library comes in handy. It lets you display structured information in the terminal in a way that’s clear, readable, and surprisingly effective for quick sanity checks.
I covered rich and a number of other libraries in my recent article:
Tables, Pretty Prints, and Sanity: Python Output for Geoscience Data | by Andy McDonald | Python in Plain English
If you don’t already have it installed:
pip install richThen import the bits we need:
from rich.console import Console
from rich.table import TableWe can take the curve metadata already exposed by lasio and render it as a formatted table:
console = Console()
table = Table(title="LAS Curve Summary")
table.add_column("Mnemonic", style="cyan", no_wrap=True)
table.add_column("Unit", style="green")
table.add_column("Description", style=”white”)
for c in las.curves:
table.add_row(
c.mnemonic,
c.unit or "",
c.descr or ""
)
console.print(table)What you get is a clean, scrollable summary of:
Curve mnemonics
Units
Descriptions
All in one place, without having to mentally align columns of printed text.
Summary
LAS files are a simple, tried and tested well log data storage format that has been used for decades. Even though the format is showing it’s age, and other formats are starting to become more popular like JSON, we will still have to deal with LAS files from legacy databases.
The lasio library is a great little Python library that can help you read the contents of a LAS file and parse it’s contents out to other formats. It also gives you a faithful representation of what is actually in the file and exposes that structure clearly in Python. Used well, it encourages a healthier workflow: inspect first, decide what’s usable, then move on to analysis, visualisation, or modelling.







