Part II: Petroleum Data Engineering
Chapter 7
Well Log Analysis with Python
Why This Chapter Exists
A well log is the closest thing petroleum engineers have to seeing underground. When a well is drilled, logging tools are lowered into the borehole and pulled back to surface, measuring the physical properties of the rock at every half-foot of depth. The resulting curves — gamma ray, resistivity, density, neutron porosity — encode the answers to the three questions that drive every reservoir decision:
- What kind of rock is down there? (Sand, shale, limestone, or something else.)
- Does it contain hydrocarbons? (Oil, gas, or just water.)
- How much can we produce? (Porosity, permeability, net pay thickness.)
These questions determine whether a company spends $80 million completing a well or walks away. They determine reserve bookings worth billions. They shape field development plans that last decades.
A petrophysicist answers these questions by interpreting log data — applying physics-based equations to convert raw measurements into rock and fluid properties. This chapter teaches you to do that interpretation in Python, from raw LAS file to a complete petrophysical evaluation with net pay determination.
infoWhat You'll Learn
- Understand what each logging tool measures physically and why it matters
- Calculate shale volume from gamma ray logs
- Compute porosity from density and neutron measurements
- Determine water saturation using Archie's equation
- Apply cutoffs to identify net pay zones
- Build a complete petrophysical evaluation pipeline
What Logging Tools Actually Measure
Before writing any equations, you need to understand what each tool is responding to. This is not optional knowledge — if you do not understand the physics behind the measurement, you cannot interpret the results correctly, and no amount of Python will fix that.
Gamma Ray (GR)
Every rock contains trace amounts of radioactive elements — potassium, thorium, and uranium. Shales contain significantly more of these elements than sandstones or limestones. The gamma ray tool measures the natural radioactivity of the formation.
Why it matters: The gamma ray log is the primary tool for distinguishing reservoir rock (sand, with low GR) from non-reservoir rock (shale, with high GR). This distinction is the first step in every petrophysical analysis. If you cannot separate sand from shale, nothing else you calculate is reliable.
Typical values:
- Clean sand: 15–45 GAPI
- Shaly sand: 45–90 GAPI
- Shale: 90–150+ GAPI
Deep Resistivity (RT)
Electrical resistivity measures how strongly the rock resists the flow of electric current. This depends on what fluid is in the pore space.
Why it matters: Water conducts electricity. Oil and gas do not. A rock saturated with salt water has low resistivity. The same rock saturated with oil has high resistivity. By measuring resistivity and knowing the porosity, you can calculate what fraction of the pore space contains water versus hydrocarbons. That fraction — the water saturation — is the single most important number in reservoir evaluation.
Typical values:
- Shale: 1–10 ohm·m
- Water-bearing sand: 2–20 ohm·m
- Oil-bearing sand: 20–2000+ ohm·m
Bulk Density (RHOB)
The density tool emits gamma rays into the formation and measures how many return. Dense rock absorbs more gamma rays, so fewer return. The measurement gives the bulk density of the rock — the combined density of the rock matrix and the fluids in its pores.
Why it matters: If you know the density of the rock matrix (about 2.65 g/cc for quartz sandstone) and the density of the fluid in the pores (about 1.0 g/cc for water, 0.85 g/cc for oil), you can calculate the porosity — the fraction of the rock that is pore space. Porosity determines how much fluid the rock can hold.
Typical values:
- Pure sandstone (zero porosity): 2.65 g/cc
- Porous sandstone (20% porosity): 2.32 g/cc
- Shale: 2.40–2.70 g/cc
- Limestone: 2.71 g/cc
Neutron Porosity (NPHI)
The neutron tool emits fast neutrons into the formation. Hydrogen atoms slow neutrons down most effectively, and hydrogen is primarily found in water and hydrocarbons occupying the pore space. The tool measures the concentration of hydrogen, which is approximately proportional to porosity.
Why it matters: Neutron porosity provides a second, independent estimate of porosity. When density porosity and neutron porosity agree, you have confidence in the result. When they disagree, that disagreement itself carries information — it can indicate the presence of gas (which has less hydrogen per unit volume than oil or water) or the presence of shale (which contains bound water in its clay structure).
Typical values:
- Clean sand with water: porosity matches true porosity
- Gas-bearing sand: neutron porosity reads lower than density porosity (the "gas crossover effect")
- Shale: neutron porosity reads higher than true porosity due to bound water in clays
Setting Up the Data
We will use a synthetic but realistic well log dataset that demonstrates the key features a petrophysicist looks for: clean sand zones, shale intervals, and a transition from water-bearing to oil-bearing reservoir.
Step 1: Shale Volume (Vshale)
The first calculation in any petrophysical analysis is determining how much shale is present at each depth. Shale degrades everything — it reduces effective porosity, traps water in clay minerals, and lowers permeability. You need to quantify it before you can reliably calculate anything else.
The simplest and most common approach is the linear gamma ray method:
where:
- = the gamma ray reading at a given depth
- = the gamma ray reading in the cleanest sand (the lowest GR value in a known sand zone)
- = the gamma ray reading in a pure shale (the highest GR value in a known shale zone)
This gives a value between 0 (pure sand) and 1 (pure shale). Values above 1 or below 0 are possible due to noise and should be clipped.
The shale volumes confirm what we expect: shale zones near 1.0, sand zones near 0.0, with some scatter from measurement noise. If these numbers did not make physical sense — for example, if a known sand zone showed a Vshale of 0.6 — you would revisit your GR endpoints or consider using a non-linear Vshale model (Larionov, Clavier, or Steiber).
Step 2: Porosity
Porosity — the fraction of rock volume that is pore space — determines how much fluid a reservoir can hold. Two independent estimates come from the density and neutron logs.
Density Porosity
For a quartz sandstone with water in the pores:
- = 2.65 g/cc (quartz grain density)
- = 1.0 g/cc (formation water density)
Effective Porosity
Raw porosity calculated from logs includes the pore space occupied by bound water in shale. Since that water is immobile and cannot be produced, it does not contribute to producible reserves. Effective porosity corrects for this:
In the pay zone (7400–7600 ft), effective porosity should be in the range of 0.15–0.25 for a producible sandstone reservoir. Values below 0.08 generally indicate rock too tight to produce economically. Values above 0.35 are uncommon in consolidated sandstones and may indicate a data or calculation error.
Step 3: Water Saturation (Archie's Equation)
This is the critical calculation. Water saturation () tells you what fraction of the pore space contains water. The remainder () is hydrocarbons.
Archie's equation, published by Gus Archie in 1942, relates water saturation to resistivity and porosity:
where:
- = water saturation (fraction)
- = resistivity of formation water (ohm·m) — measured from water samples or calculated from SP logs
- = true formation resistivity from the deep resistivity log (ohm·m)
- = porosity (fraction)
- = tortuosity factor (typically 0.62–1.0)
- = cementation exponent (typically 1.7–2.2)
- = saturation exponent (typically 1.8–2.2)
Why this equation works: In a water-saturated rock, the only conductive pathway for electricity is through the brine in the pore space. As oil replaces water, the conductive pathways become fewer and more tortuous, and resistivity increases. Archie's equation quantifies this relationship.
Why the parameters matter: The exponents and are not universal constants — they depend on the rock type, the pore geometry, and the wetting characteristics of the formation. Using incorrect values produces wrong water saturations, which produces wrong reserve estimates. In practice, these parameters are calibrated against core data when available.
The results should show what the resistivity log already told us: the wet sand zones have high water saturation (Sw near 1.0), and the pay zone has low water saturation (Sw near 0.2–0.4), meaning 60–80% of the pore space is filled with oil.
If the water saturation in a "known" oil zone comes out above 0.6, something is wrong — either the Archie parameters are incorrect, the porosity calculation has errors, or the zone is not actually oil-bearing. This is why petrophysics requires engineering judgment, not just equations.
Step 4: Net Pay Determination
Not all rock with hydrocarbons is worth producing. Net pay is the thickness of reservoir rock that meets minimum quality standards. The industry-standard approach is to apply cutoffs — threshold values that a depth interval must pass to count as pay.
Common cutoffs for a clastic (sandstone) reservoir:
| Parameter | Cutoff | Why |
|---|---|---|
| Vshale | < 0.40 | Too much shale means low permeability |
| Effective porosity | > 0.08 | Too little pore space means too little oil |
| Water saturation | < 0.60 | More than 60% water means oil won't flow preferentially |
These cutoffs are not universal. They depend on the reservoir rock type, the fluid properties, and the economics of the field. A deepwater well with high development costs might require tighter cutoffs than an onshore well.
The Complete Petrophysical Pipeline
Bringing all four steps together into a single, reusable function:
This function encapsulates the entire workflow. For a new well, you load the LAS file (using the pipeline from Chapter 6), pass the DataFrame to petrophysical_evaluation(), and receive a complete analysis in seconds. Parameters can be adjusted per well or per field without rewriting any logic.
Summary
This chapter covered the core workflow of petrophysical analysis:
- Gamma ray logs measure natural radioactivity and distinguish sand from shale. Shale volume (Vshale) is calculated from the GR response relative to clean sand and pure shale baselines.
- Density and neutron logs provide independent porosity estimates. Effective porosity corrects for shale content, giving the porosity available for hydrocarbon storage.
- Archie's equation converts resistivity and porosity into water saturation — the fraction of pore space filled with water. The remainder is hydrocarbons. The equation's parameters (a, m, n, Rw) must be calibrated to the specific reservoir.
- Net pay cutoffs (Vshale, porosity, water saturation) determine which intervals are commercially producible. These cutoffs are engineering judgments, not universal constants.
- A complete pipeline automates the entire workflow, making it repeatable and auditable.
The next chapter uses reservoir fluid properties — bubble point pressure, formation volume factor, viscosity, and gas solubility — to understand how the hydrocarbons we just identified will behave when we produce them.
Exercises
GR Endpoint Sensitivity
Using the well log dataset from this chapter, calculate Vshale using three different GR_clean / GR_shale pairs: 5th/95th percentiles (as we used)Minim...
Non-Linear Vshale Models
The linear GR method tends to overestimate shale volume in the middle range. Implement the Larionov (Tertiary rocks) correction: Vshale=0.083×(23.7×IG...
Density-Neutron Crossplot
Create a crossplot of density porosity (x-axis) vs. neutron porosity (y-axis) for the well. Colour the points by Vshale. In a clean, water-bearing san...
Archie Parameter Sensitivity
Water saturation depends on four parameters: a, m, n, and Rw. For the pay zone in this dataset, calculate Sw using: The base case: a=0.81, m=2.0, n=2....
Net Pay Cutoff Sensitivity
Run the petrophysical evaluation with three different sets of cutoffs: SetVshalePorositySwTight> 0.12Base> 0.08Relaxed> 0.05 Report the net pay for ea...
Multi-Well Comparison
Create log data for three wells (modify the zone depths and properties for each). Run the petrophysical evaluation on all three and produce a summary ...
Pay Zone Statistics
For each continuous pay zone identified in the net pay analysis, calculate: Zone thicknessAverage porosityAverage water saturationHydrocarbon pore thi...
Real LAS File Analysis
Download a real LAS file from the Kansas Geological Survey or the Volve dataset. Apply the complete petrophysical pipeline from this chapter. Document...
Water Saturation from Multiple Methods
Archie's equation is the standard, but it assumes clean (non-shaly) sand. For shaly sands, the Simandoux equation accounts for shale conductivity: 1Rt...
Automated Petrophysical Report
Write a function that takes a LAS file path and produces a complete petrophysical report as a formatted text output, including: Well header informatio...