00 - Orientation and Setup

Open in Colab

Part A - Foundations - Petrophys Curriculum

Welcome. This is the first lesson of the petrophys teaching curriculum. By the end of it you will know what the library is for, how to reach the well-log data that ships inside it, and where each later lesson fits into the bigger picture.

No prior experience with petrophys is assumed - only a working knowledge of basic petrophysics (gamma ray, density, neutron, resistivity, porosity, water saturation).

Learning goals

  • Understand what petrophys is: an open Python library for well-log analysis and formation evaluation, reached through a small front door (pp.read, pp.plot, pp.interpret).

  • Discover the bundled sample data with pp.list_samples(...) and resolve a file with pp.sample(...).

  • Take a guided tour of the two main teaching datasets:

    • GeoLink - North Sea clastic wells (primary teaching well 30/6-5, sample name 30_6-5).

    • COSTA - 17 carbonate wells (HW-3 ... HW-32); each file covers only the Kharaib-2 reservoir interval.

  • Read the curriculum roadmap (quickstart and own-data pages, Parts A and B) so you know where you are going.

  • Know honestly what this curriculum does not cover so you set the right expectations.

Why this matters

Formation evaluation is the discipline of turning raw borehole measurements into answers a subsurface team can act on: How much rock is reservoir? How porous is it? How much of the pore space is hydrocarbon rather than water?

The workflow always starts the same way - get the data in, and understand it - before any physics is applied. This lesson is that starting point. Everything later (clay volume, porosity, saturation, permeability, net pay, lithology solving) builds on the Well and Curve objects you will meet here.

Prerequisites and kernel setup

Use a Python kernel in which Petrophys is installed. Create a virtual environment, install the package with the tutorials extra (Jupyter kernel support), and register the kernel. Run these commands in a terminal, not in the notebook.

Linux / macOS

python3 -m venv .venv
source .venv/bin/activate
python -m pip install "petrophys[tutorials]"
python -m ipykernel install --user --name petrophys

Windows (PowerShell)

py -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install "petrophys[tutorials]"
python -m ipykernel install --user --name petrophys

To work from a source checkout instead, run python -m pip install -e ".[tutorials]" from the repository root in place of the PyPI install.

Then select the petrophys kernel in your notebook editor. The small LAS examples are bundled with the package. Optional lessons need extras: petrophys[ml] for curve imputation, petrophys[dlis] for native DLIS files and petrophys[mcp] for the MCP server. The next cell imports Petrophys and shows the installed version.

import petrophys as pp

pp.__version__
'3.0.0'

Start with a plot, not an interpretation

LAS alone is enough. Formations and lithology are optional, and plotting does not calculate missing SW. pp.plot takes a well file directly; top and bottom set the depth window, here 2800-3000 m around the Brent Group of 30/6-5. The later scientific lessons explain each method; the Quickstart and Your own data pages of the documentation teach the short user-facing workflow.

first_plot = pp.plot(pp.sample("30_6-5"), top=2800, bottom=3000)
first_plot.warnings
[repository]\src\petrophys\preprocessing\standardization\curve_standardizer.py:851: UserWarning: SWC: inferred percent core saturation despite unit 'frac'; divided by 100 to v/v. Verify source units.
  standardize_core_saturation(new_curve, inplace=True)
[repository]\src\petrophys\preprocessing\standardization\curve_standardizer.py:851: UserWarning: SOC: inferred percent core saturation despite unit 'frac'; divided by 100 to v/v. Verify source units.
  standardize_core_saturation(new_curve, inplace=True)
["SWC: inferred percent core saturation despite unit 'frac'; divided by 100 to v/v. Verify source units.",
 "SOC: inferred percent core saturation despite unit 'frac'; divided by 100 to v/v. Verify source units."]
../../_images/29bdb2fea8860383f657758cbe78e822c957c77aaf083a887ac24dbbe25b6c42.png

The plot cell prints two diagnostics, and both come from the bundled file itself: 30/6-5 stores core water saturation (SWC) and core oil saturation (SOC) in percent although its LAS header labels them frac. Petrophys detects this, converts display copies to fractions and asks you to verify the source units; both messages are kept in first_plot.warnings. The file on disk is unchanged. The viewer draws SOC as “So Core” dots in the saturation track, on a 0-1 scale that puts each point where 1 - So falls on the Sw scale; pp.interpret (lesson 06) reports the same two curves when it reads the core data. Lesson 02 shows the evidence behind the conversion and how to declare units explicitly.

1. What is petrophys?

petrophys is a Python library for well-log analysis and formation evaluation. It covers the path from a raw LAS/DLIS file to interpreted reservoir properties, and groups its functionality into focused sub-packages. A high-level tour:

Module

Purpose

petrophys (imported as pp)

Front door: pp.read, pp.plot, pp.interpret, pp.sample, pp.list_samples

petrophys.io

Format-specific readers and writers (read_las, read_dlis, read_csv, exporters)

petrophys.model

Core data model: the Well and Curve objects, formation tops

petrophys.preprocessing

Quality control: standardization, bad-hole, value-range, normalization

petrophys.interpretation.clay_volume

Shale/clay volume from GR, SP, neutron-density

petrophys.interpretation

Porosity, saturation, permeability, cementation

petrophys.interpretation.lithology

Multi-mineral solving

petrophys.evaluation

Net pay, BVW, rock-quality index, flow units

petrophys.evaluation.summaries

Hydrocarbon pore volume, OOIP/OGIP, zone summaries

petrophys.workflow

The dynamic workflow behind pp.interpret, with a step-by-step trace

petrophys.visualization

Log viewers, triple-combo, crossplots, Pickett plots

petrophys.reporting

Structured context export for reports and LLMs (lesson 19)

petrophys.mcp

MCP server that lets LLM agents drive Petrophys (lesson 20)

We will meet many of these across the curriculum. The important idea for a start is that every one of them consumes the same Well object - so learning to load and inspect a well (Part A) unlocks everything else.

2. Accessing bundled data

Two functions are all you need to reach the sample data:

  • pp.list_samples(kind=None) - returns the names of the bundled samples, all of them or one kind: 'logs' (well logs: the GeoLink North Sea wells, the COSTA carbonate wells, a Kansas Geological Survey well, the Cheal-1 and Tuhua-7 wells of Taranaki, New Zealand, and two Teapot Dome wells, Wyoming), 'nmr' (Daydream 1 CMR logs and NMR tables), 'pressure' (formation-pressure tests), 'core' (core measurements and capillary-pressure data), 'geology' (formation tops and lithology intervals) and 'templates' (blank input templates for your own data). A collection name such as 'geolink' or 'costa' also works.

  • pp.sample(name) - returns the full path of that bundled file on your machine. Feed a well-log path straight into pp.read(...) or pp.plot(...).

Because the data lives inside the installed package, this works on any machine with no setup - no downloads, no credentials, no path juggling.

pp.list_samples("logs")
['1046123714',
 '15_9-14',
 '16_7-1',
 '25_5-1',
 '30_6-5',
 'HW-10',
 'HW-24',
 'HW-25',
 'HW-26',
 'HW-27',
 'HW-28',
 'HW-29',
 'HW-3',
 'HW-30',
 'HW-31',
 'HW-32',
 'HW-4',
 'HW-5',
 'HW-6',
 'HW-7',
 'HW-8',
 'HW-9',
 'cheal-1',
 'ede_01_composite',
 'teapot_17-wx-21',
 'teapot_44-mdx-10',
 'tuhua-7']
pp.list_samples("geolink"), pp.list_samples("costa")
(['15_9-14', '16_7-1', '25_5-1', '30_6-5'],
 ['HW-10',
  'HW-24',
  'HW-25',
  'HW-26',
  'HW-27',
  'HW-28',
  'HW-29',
  'HW-3',
  'HW-30',
  'HW-31',
  'HW-32',
  'HW-4',
  'HW-5',
  'HW-6',
  'HW-7',
  'HW-8',
  'HW-9'])

4. Tour - dataset two: COSTA (carbonate)

The COSTA dataset is a public carbonate reservoir benchmark; Petrophys bundles 17 of its wells (HW-3 through HW-32). Carbonate petrophysics differs from clastics (complex pore systems, different lithology solving, Archie parameters a, m, n that vary with texture), so having carbonate wells lets the curriculum contrast the two rock types.

Each COSTA LAS file covers only the Kharaib-2 reservoir interval, not the whole well: the logged depth range is the Kharaib-2 reservoir zone. The bundled formations_costa table records that interval for every well. The files are leaner and more uniform than 30/6-5 - a realistic multi-well set for teaching normalization across a field. Let us load HW-3 and look up its interval.

w_car = pp.read(pp.sample("HW-3"))
print(w_car.info())
Well: HW-3
UWI: HW-3
Field: COSTA
Depth range: 7805 - 8020 ft
Step: 0.5 ft
Number of curves: 8
Number of samples: 431

Curves:
  GR: gAPI, 431 valid
  RHOB: g/cm3, 431 valid
  NPHI: ft3/ft3, 431 valid
  DT: us/ft, 356 valid
  PHIE_CC: ft3/ft3, 351 valid
  RT: ohm.m, 431 valid
  SW_INPUT: v/v, 321 valid
  PERM_CC: mD, 355 valid
pp.read_formations(pp.sample("formations_costa"), well=w_car)
formation_name top_depth bottom_depth lithology rank well depth_unit
0 KHARAIB-2 7805.0 8020.0 Carbonate formation HW-3 ft

Contrast with the GeoLink well:

  • Depth here is in feet (ft), as is usual in North America and the Middle East. Mixed depth units across datasets is exactly why unit awareness (lesson 02) matters.

  • The file spans 7805-8020 ft because it holds only the Kharaib-2 interval, the same range as its row in formations_costa; the 30/6-5 file spans the whole logged well.

  • The COSTA curve set is compact: GR, RHOB, NPHI, DT (sonic), RT (true resistivity), plus the interpretation-input curves PHIE_CC (core-corrected effective porosity), PERM_CC (core-corrected permeability) and SW_INPUT (the source water saturation). These are continuous log curves supplied with the dataset, not core-plug measurements.

  • No caliper/bit-size here - so bad-hole detection (lesson 02) will be demonstrated on the GeoLink well, and normalization on the COSTA wells.

5. A first look at the logs

To make the two wells concrete, here is the gamma-ray log from each, plotted against depth (log convention: depth increasing downward). curves=["GR"] draws only that curve. GR distinguishes clean reservoir (low GR) from shale/clay (high GR). The 30/6-5 plot covers 2800-3000 m around the Brent Group, the HW-3 plot its whole Kharaib-2 file. Both use the same 0-150 API scale, and the difference is striking: the Brent sands read about 20-40 API between shales above 100 API, while the Kharaib-2 carbonate stays below about 30 API throughout. That contrast is real lithology, not a tool artifact. Multi-well normalization (lesson 02) solves a different problem: correcting well-to-well calibration bias between wells of the same field.

pp.plot(w_geo, curves=["GR"], top=2800, bottom=3000, figsize=(4, 9))
pp.plot(w_car, curves=["GR"], figsize=(4, 9));
[repository]\src\petrophys\preprocessing\standardization\curve_standardizer.py:851: UserWarning: SWC: inferred percent core saturation despite unit 'frac'; divided by 100 to v/v. Verify source units.
  standardize_core_saturation(new_curve, inplace=True)
[repository]\src\petrophys\preprocessing\standardization\curve_standardizer.py:851: UserWarning: SOC: inferred percent core saturation despite unit 'frac'; divided by 100 to v/v. Verify source units.
  standardize_core_saturation(new_curve, inplace=True)
../../_images/d1830ff5c6bbff58cd761f6ecb1b78fb2c57816e87a41f77fe70dbea85d25c59.png ../../_images/3065b3b4af079275cdc7a943578009ce06e67c68bd62fbfa685fc1370fa53735.png

6. Curriculum roadmap

Two short pages of the documentation sit in front of the lessons:

  • Quickstart - read, plot and interpret one bundled well with the front-door API, then inspect the decisions.

  • Your own data - LAS, CSV/TSV and Excel inputs, optional formation and lithology tables, depth metadata and diagnostics.

The lessons are split into two parts.

Part A - Foundations & Core Science (you are here)

#

Lesson

What you learn

00

Orientation and setup

This lesson: purpose, data, roadmap

01

Loading and inspecting data

The Well / Curve data model in depth

02

QA/QC and standardization

Conditioning: aliases, units, bad-hole, normalization

03

Clay volume

Vcl from GR (linear/Larionov/Stieber/Clavier), SP, neutron-density

04

Porosity

Density/neutron/sonic; total vs effective; hydrocarbon correction

05

Lithology and mineral solver

N-D/PEF crossplots; 2- and 3-mineral least-squares solving

06

Formation water and environment

Rw (SP/salinity), Rmf, temperature profile, invasion

07

Water saturation

Archie + shaly-sand models; Pickett m/n; model selection

08

Permeability

Timur/Coates; core poro-perm calibration

09

Reservoir quality and net pay

RQI/FZI/flow units; BVW/MHI; net pay; HCPV/OOIP/OGIP

Part B - Integrated & Advanced Workflows

Building on the foundations from Part A, Part B covers the integrated and specialist workflows:

#

Lesson

What you learn

10

Dynamic workflow (glass box)

Auto method selection, the ordered workflow steps (listed below), step traces, overrides

11

Formation and interval analysis

Tops, zones/subzones, per-interval and formation summaries

12

Core calibration and digital core

Core-to-log calibration; digital-core facies, XRF, geomechanics

13

ML curve imputation

Rebuild missing curve samples from the other logs with pp.impute

14

NMR petrophysics

T2 bins; SDR and Coates permeability; BVI/FFI

15

Capillary pressure and saturation-height

J-function, Brooks-Corey fitting, Pc-height conversion

16

Borehole image (FMI)

Pads to oriented image, equalization, azimuthal coverage

17

Visualization masterclass

XML templates, adaptive viewer, crossplots, batch export

18

Multiwell field study

COSTA 17-well batch, normalization, portfolio summary

19

LLM context generation

Export structured, size-limited context from interpreted wells

20

Petrophys for LLM agents (MCP)

Drive loading, interpretation, summaries and plots from an MCP client

21

Custom workflows

Build, validate and save your own reusable Workflow recipe

Each lesson consumes exactly the Well object you learn to build here in Part A.

The dynamic workflow behind pp.interpret is organized as an ordered catalogue of steps. Each run records which steps executed and which were skipped, with a reason, so the catalogue is not a promise that every step runs on every well:

import pandas as pd
from petrophys.workflow import workflow_steps

pd.set_option("display.max_colwidth", None)   # show each description in full
pd.DataFrame(workflow_steps())
name description
0 normalization Canonical curve aliases and units; implausible-value screening
1 temperature Formation temperature profile from BHT or a gradient
2 bad_hole Washout and density-correction quality flags
3 spectral_gamma Not run by pp.interpret; call petrophys.interpretation.geochemistry.interpret_spectral_gamma directly
4 elemental_spectroscopy Not run by pp.interpret; call petrophys.interpretation.geochemistry.interpret_elemental_spectroscopy directly
5 vclay Clay volume (VCL) from gamma ray, SP and neutron-density
6 rcl Clay resistivity from shale intervals
7 rmf Mud-filtrate resistivity at formation temperature
8 hc_correction Neutron-density hydrocarbon correction (opt-in)
9 porosity Density, neutron, sonic, total (PHIT) and effective (PHIE) porosity
10 lithology Mineral volumes: clastic multi-mineral or carbonate solve
11 porosity_refinement Not run by pp.interpret; porosity is computed once, in the porosity step
12 core_correction Porosity and permeability calibrated to core data
13 rw Formation water resistivity at formation temperature
14 invasion Invasion profile from shallow and deep resistivity
15 saturation Water (SW) and flushed-zone (SXO) saturation
16 permeability Core-calibrated or empirical permeability (PERM)
17 rock_quality Reservoir quality index (RQI), flow zone indicator (FZI)
18 bvw Bulk volume water
19 mhi Moveable hydrocarbon index
20 net_pay Net rock, net reservoir and net pay flags

7. What this curriculum does not cover

To set honest expectations, the curriculum focuses on wireline log analysis and formation evaluation. The following are outside its scope:

  • Seismic and AVO - no seismic inversion, amplitude-versus-offset, or rock-physics-to-seismic tie.

  • Geomechanics - beyond limited digital-core mechanical properties, no full wellbore stability / stress modelling.

  • Unconventionals / TOC - no organic-richness (total organic carbon) or source-rock workflows.

  • 4D (time-lapse) - no repeat-survey / production monitoring.

  • Monte-Carlo uncertainty - results in these lessons are deterministic. The library has a Monte-Carlo propagator (petrophys.evaluation.monte_carlo, shown in the analysis-tools page of the documentation), but no lesson teaches it.

Knowing the boundary is part of using any tool responsibly.

Pitfalls and good habits

  • Mind the depth unit. GeoLink is in metres, COSTA in feet. Always read w.depth_unit before comparing depths or thicknesses across wells.

  • Know what interval a file covers. 30/6-5 spans the whole logged well; each COSTA file spans only the Kharaib-2 reservoir interval.

  • Use sample() for paths, never hard-code them. The bundled data path differs by machine; pp.sample(name) resolves it for you.

  • Non-ASCII header fields happen. Header text such as the Oseberg Øst field name can carry non-ASCII characters; keep that in mind when you export headers to systems that expect plain ASCII.

  • Read warnings. A diagnostic such as the SWC percent-versus-fraction message is a finding about the data, not noise to hide.

  • Core curves are precious. When a well carries core measurements (*_CORE, PHIC), use them to validate your log-derived answers. *_CC curves are core-corrected log curves: useful, but not independent core data.

Recap

  • petrophys is a well-log / formation-evaluation library; every sub-package consumes the same Well object, and pp.read, pp.plot and pp.interpret are the front door.

  • pp.list_samples(...) lists the bundled samples (LAS and DLIS logs, CSV and Excel tables); pp.sample(name) gives the file path to feed pp.read(...) or pp.plot(...), and well.info() prints what a well holds.

  • Two main teaching datasets: GeoLink North Sea clastics (primary well 30/6-5, metres, core-rich, Brent Group 2841-2958 m) and COSTA carbonates (HW-3 ... HW-32, feet, each file only the Kharaib-2 interval).

  • The curriculum starts with the quickstart and own-data pages, then runs Part A (lessons 00-09: loading and QA/QC through saturation, permeability and net pay) and Part B (lessons 10-21: integrated workflows, specialist data, multiwell studies, LLM integration and custom workflows).

  • Seismic/AVO, full geomechanics, unconventionals/TOC and 4D are outside the curriculum, and no lesson teaches Monte-Carlo uncertainty.

  • Start with read/plot; add pp.interpret only when ready to review its assumptions and trace. It works on a copy of the well.

Try it yourself

Exercise 1. Load a second COSTA well (e.g. HW-10) and a second GeoLink well (e.g. 25_5-1) and call info() on each. Do all COSTA wells share the same curve set? Does the Kharaib-2 interval sit at the same depth in every COSTA well?

Exercise 2. For any well, list which curves contain the substring CORE or CC (core measurements, or log curves corrected to core). Which of the two datasets carries actual core-plug measurements?

Hint: pp.read takes a list of files, e.g. pp.read([pp.sample(name) for name in pp.list_samples("costa")]).

What’s next

Continue with 01_loading_and_inspecting_data.ipynb, where we open up the Well and Curve objects properly: headers, per-curve statistics, DataFrame export, depth slicing, and the difference between the curve sets of a clastic and a carbonate well.