mcpField
L
lasio

lasio

github.com/steadfastasartData & databases7365 installsUpdated 6w ago
Repository

About lasio

lasio is a Python library for reading, inspecting, creating, and modifying LAS well-log files. It suits workflows that need direct control over LAS data, headers, and format conversion.

Key features

  1. 01Read and write LAS files
  2. 02Access curves and header metadata
  3. 03Create and modify well-log files
  4. 04Convert curve data to DataFrames
  5. 05Handle header errors and null values

Use cases

  1. 01Inspect curves and well headers
  2. 02Clean null values before analysis
  3. 03Build or edit LAS well-log files
  4. 04Batch-process LAS files or export CSV

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/steadfastasart/geoscience-skills --skill lasio

After installing, type/lasioin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
curve_mnemonics.md
file_structure.md
troubleshooting.md
scripts/
las_to_csv.py
merge_curves.py
validate_las.py

Details

From the project README

lasio - LAS Well Log Files

Quick Reference

import lasio

# Read
las = lasio.read("well.las")

# Access data
df = las.df()                    # DataFrame (depth as index)
gr = las['GR']                   # Single curve as numpy array
depth = las['DEPT']

# Well info
well_name = las.well['WELL'].value
uwi = las.well['UWI'].value

# Write
las.write('output.las')

Key Classes

ClassPurpose
LASFileMain container - holds headers, curves, data
CurveItemSingle curve with mnemonic, unit, data array
HeaderItemHeader entry (mnemonic, unit, value, descr)

Essential Operations

Read and Inspect
las = lasio.read("well.las")
print(las.curves.keys())         # Available curves
print(las.well)                  # Well section headers
print(las.version)               # LAS version info
Access Curve Data
# As numpy arrays
gr = las['GR']
depth = las['DEPT']

# With metadata
curve = las.curves['GR']
print(curve.unit, curve.descr)   # 'GAPI', 'Gamma Ray'
Create New LAS
import numpy as np

las = lasio.LASFile()
las.well['WELL'] = lasio.HeaderItem('WELL', value='Test-1')
las.well['UWI'] = lasio.HeaderItem('UWI', value='12345678901234')

depth = np.arange(1000, 2000, 0.5)
las.append_curve('DEPT', depth, unit='M', descr='Depth')
las.append_curve('GR', gr_data, unit='GAPI', descr='Gamma Ray')
las.write('output.las')
Modify Existing
las = lasio.read("well.las")
las.append_curve('GR_NORM', las['GR'] / 150, unit='V/V')
del las.curves['BAD_CURVE']
las.well['WELL'].value = 'New Name'
las.write('modified.las')
Handle Problematic Files
# Ignore header errors
las = lasio.read("messy.las", ignore_header_errors=True)

# Check null value
null_val = las.well['NULL'].value  # Usually -999.25

Null Value Handling

LAS files use a specific null value (typically -999.25). Always check and handle:

import numpy as np
null_val = float(las.well['NULL'].value)
df = las.df().replace(null_val, np.nan)

Batch Processing

from pathlib import Path

for path in Path('wells/').glob('*.las'):
    las = lasio.read(path)
    df = las.df()
    # Process...

When to Use vs Alternatives

ToolBest For
lasioDirect LAS file I/O, header manipulation, format conversion
wellyHigher-level well analysis, curve processing, multi-well projects
dlisioDLIS/RP66 binary format files (not LAS)

Use lasio when you need low-level control over LAS file reading/writing, need to handle malformed files, or want to programmatically build LAS files.

Use welly instead when you need curve processing (despike, normalize), multi-well project management, or formation tops. Welly uses lasio internally.

Use dlisio instead when your data is in DLIS format. DLIS files are binary, support multi-frame data and array logs -- lasio cannot read them.

Common Workflows

Read, QC, and export well log data
- [ ] Read LAS file with `lasio.read()`, handle encoding if needed
- [ ] Inspect curves: `las.curves.keys()` and well headers
- [ ] Replace null values: `df.replace(null_val, np.nan)`
- [ ] Validate depth range and sample interval
- [ ] Check for missing curves or anomalous values
- [ ] Export to DataFrame with `las.df()` or write cleaned LAS

Common Issues

IssueSolution
Encoding errorslasio.read(f, encoding='latin-1')
Missing curvesCheck las.curves.keys() first
Header errorsUse ignore_header_errors=True
Wrong null valueCheck las.well['NULL'].value

References

Scripts

Comments

Markdown supported