Visualization and reporting¶
Whether pp.interpret or your own workflow produced it, an interpretation is delivered as plots and files.
Every plot takes a Well or an interpretation result and finds curves by their standard names; tracks without data are left out.
This page shows each plot type on the bundled wells, then every export format.
The examples interpret 30/6-5 once, with Rw 0.07 ohm.m at 230 °F and the bundled formation-scale lithology table (one lithology per formation, so the lithology track shows the Brent Group as sandstone; the LAS file’s own lithology log is finer). Its core SWC and SOC are percent values labelled as fractions. Petrophys converts them and warns; this page hides that warning.
import petrophys as pp
well = pp.read(pp.sample("30_6-5"), formations=pp.sample("formations_30_6-5"),
lithology=pp.sample("lithology_30_6-5"))
result = pp.interpret(well, rw=0.07, rw_meas_temp="230 degF")
pp.plot(result, top=2800, bottom=3000)
Figure style and export¶
Library plots share DejaVu Sans typography, white backgrounds and PNG export defaults. Curve colours, lithology patterns and specialist colour scales retain their scientific meaning. Importing the library does not change Matplotlib’s global settings.
For custom Matplotlib figures in the same notebook, call
petrophys.visualization.use_plot_style() once. For temporary overrides, use
with petrophys.visualization.plot_style({"font.size": 10}): around your plotting
code. Existing axes and explicit curve styling remain under your control.
Save any figure with petrophys.visualization.save_figure(fig, "plot.png").
Exports use 150 dpi, a white background and tight margins; pass dpi=300 for
higher-resolution raster output, or use a .pdf or .svg extension for vectors.
Viewer .save(...) methods use the same defaults.
Log plot templates¶
pp.plot builds its tracks from the curves present (template="auto", above).
A named template gives a fixed layout instead: raw, triple_combo, petrophysics,
interpretation, minerals, comprehensive and a few more. The examples below show
the Brent Group (2841-2958 m) with a margin.
The petrophysics template keeps the interpretation tracks:
pp.plot(result, top=2830, bottom=2970, template="petrophysics")
comprehensive adds the mineral volumes of the multi-mineral solution and a seal flag:
pp.plot(result, top=2830, bottom=2970, template="comprehensive")
triple_combo is the classic first look at gamma ray, resistivity and density-neutron
(triple_combo() draws the same):
pp.plot(result, top=2830, bottom=2970, template="triple_combo")
A well plots before any interpretation; only the measured curves are drawn:
pp.plot(well, top=2830, bottom=2970)
Crossplots¶
One call draws every crossplot: pp.crossplot(data, x, y). The pair of curves picks the
chart, in either order and by the well’s own names or standard ones: "NPHI", "RHOB"
draws the neutron-density chart, "PEF", "RHOB" the density-PEF chart, "N", "M" the
M-N plot, "DTMAA", "RHOMAA" the MID plot, a porosity and a deep resistivity the Pickett
plot (chart="hingle" the Hingle plot), a porosity and Sw the Buckles plot,
"PHI_Z", "RQI" the flow units and core porosity with core permeability the poro-perm
chart. Any other pair is drawn as points, coloured by color=. top= and bottom= set
the depth window, as in pp.plot.
Each of these charts, data over the lines of a chart, is also a function of its own in
petrophys.visualization.charts, on pp as well, with the usual curves as defaults:
pp.nd_plot, pp.pef_plot, pp.mn_plot, pp.mid_plot, pp.pickett_plot,
pp.hingle_plot, pp.buckles_plot, pp.flow_unit_plot, pp.poro_perm_plot and
pp.saturation_height_plot. pp.pickett_plot(result) is
pp.crossplot(result, "PHIE", "RDEP"); the examples below use the named charts.
Crossplots convert declared compatible units before plotting and leave the source well unchanged. Unknown or incompatible units raise a named error; missing units warn before assuming the chart unit. Pickett, Hingle and Buckles accept xlim= and ylim=; a note counts finite points outside the displayed range.
Each crossplot answers one question. The lithology plots use the interval where PEF and sonic are both logged (2784-3176 m); the resistivity plots use the Statfjord water leg (3223-3556 m), where the clean sands plot near the water line (Sw 80-100 %).
Neutron-density shows lithology and gas against the sandstone, limestone and dolomite lines of the chartbook (Schlumberger Por-11: CNL and Litho-Density, fresh water; the sandstone and dolomite lines curve). The M-N reference assumes freshwater and a limestone-referenced neutron response with linear mineral endpoints; neither is a calibration chart for another tool:
pp.nd_plot(result, top=2784, bottom=3176)
M-N plot: matrix minerals from density, neutron and sonic together:
pp.mn_plot(result, top=2784, bottom=3176)
MID plot: apparent matrix density against apparent matrix slowness. It removes
the freshwater contribution using PHIT, or an explicit total-porosity curve
selected with porosity_curve="MY_PHIT". Without total porosity it estimates
porosity from linear quartz/calcite/water and calcite/dolomite/water triangles.
Samples outside that clean binary-mineral model warn and are omitted. For gas,
clay or complex mineral mixtures, supply independently determined total porosity:
pp.mid_plot(result, top=2784, bottom=3176)
Pickett plot: log Rt against log porosity. Water-bearing rock falls on a straight
line whose slope is -m and whose intercept at porosity 1 is a * Rw; with a known,
Rw can be recovered. Rw must be at formation temperature: by default the plot takes the
median of the interpretation’s RW curve over the plotted points. Lines of constant Sw lie
above it. Only clean rock is plotted (VCL up to 0.15, vcl_max), as the chart is read on
clean rock. Here with the operator’s Archie constants (a 0.8, m and n 2):
pp.pickett_plot(result, top=3223, bottom=3556, a=0.8)
DataQualityWarning: Pickett input: 29 of 22176 value(s) require porosity in (0,1] and finite positive resistivity (zero-based flat indices [20774, 20776, 20781, 20782, 20783]). Invalid points are omitted from this plot.
Hingle plot: the same Archie water line on linear axes, where it passes through the matrix point at zero porosity, with the same Rw and clean points:
pp.hingle_plot(result, top=3223, bottom=3556, a=0.8)
DataQualityWarning: Hingle input: 29 of 22176 value(s) require porosity in (0,1] and positive resistivity (zero-based flat indices [20774, 20776, 20781, 20782, 20783]). Invalid points are omitted from this plot.
Buckles plot: each hyperbola represents constant bulk-volume water (porosity * Sw).
Clustering along one hyperbola can support an irreducible-water interpretation,
but constant BVW alone does not establish irreducible saturation. Only the
physical segment with Sw <= 1 is drawn. The axis identifies total porosity when
PHIT supplies the fallback. HW-3,
a COSTA carbonate whose header carries Rw, coloured by the file’s core-calibrated
permeability PERM_CC (the run’s own PERM has no core calibration in a carbonate):
pp.buckles_plot(pp.interpret(pp.sample("HW-3")), color="PERM_CC")
Reservoir displays¶
Flow units, net flags and formation tops sum up where the good rock is.
Flow units plot the reservoir quality index (RQI) against normalized porosity (φz) for the core plugs; each hydraulic flow unit lies on its own line:
from petrophys.interpretation.core_analysis import core_data
pp.flow_unit_plot(core_data(result))
Zone flags draw net rock, net reservoir and net pay as depth bars:
pp.zone_flags_plot(result, flag_curves=["NET_ROCK", "NET_RES", "NET_PAY"],
top=2841, bottom=2958);
Formation tops given to pp.read (or to pp.plot as formations=) are drawn on
every log plot, as above. To shade named intervals on a Matplotlib axis of your own,
use add_zone_shading().
Multi-well and sensitivity charts¶
petrophys.visualization also draws charts that are not depth tracks.
bar_chart and line_chart complete the set.
Multi-well overlay: one curve from several wells on a shared depth axis, here the normalized gamma ray of five COSTA wells:
costa = pp.read([pp.sample(name) for name in ["HW-3", "HW-4", "HW-5", "HW-6", "HW-7"]])
pp.multiwell_overlay(costa, "GR", normalize=True, title="Normalized GR, five COSTA wells");
Histogram comparison: distributions on common bins after conversion to a shared unit. Equivalent percent and fraction porosities share a distribution; incompatible declared units raise an error. For example:
pp.histograms(costa, "GR", density=True, histtype="step", xlabel="GR [API]", title="GR by well");
Tornado: how far each assumption moves the answer.
cutoff_sensitivity() re-applies the net-pay cutoffs to
the interpreted curves, which stay fixed; it applies the cutoffs alone, so the samples
pp.interpret leaves out of NET_PAY (bad hole, evaporite, coal, halite) count
here. The standard clastic cutoffs are VCL 0.4, PHIE 0.08 and Sw 0.6. Each case
moves one cutoff to a low and a high value:
from petrophys.evaluation import cutoff_sensitivity
def net_pay(**cutoffs):
grid = cutoff_sensitivity(result.well, top=2841, bottom=2958, **cutoffs)
return grid["net_pay_thickness"].tolist()
low, high = zip(net_pay(vcl_cutoffs=[0.3, 0.5]), net_pay(phie_cutoffs=[0.12, 0.05]),
net_pay(sw_cutoffs=[0.5, 0.7]))
pp.tornado_plot(["VCL cutoff 0.3 / 0.5", "PHIE cutoff 0.12 / 0.05", "Sw cutoff 0.5 / 0.7"],
low, high, base=net_pay()[0], xlabel="Brent Group net pay [m]",
low_label="stricter cutoff", high_label="looser cutoff");
With the standard cutoffs the Brent Group has 23.3 m of net pay. The Sw cutoff moves it most, from 21.0 to 25.6 m; the VCL and PHIE cutoffs move it by less than 1.3 m either way.
Heatmap: any 2-D grid, such as net-to-gross over two cutoffs at once:
grid = cutoff_sensitivity(result.well, top=2841, bottom=2958,
vcl_cutoffs=[0.2, 0.3, 0.4, 0.5], sw_cutoffs=[0.4, 0.5, 0.6, 0.7, 0.8])
ntg = grid.pivot(index="vcl_cutoff", columns="sw_cutoff", values="ntg_pay")
pp.heatmap(ntg, x=ntg.columns, y=ntg.index, cmap="RdYlGn", invert_yaxis=False,
xlabel="Sw cutoff", ylabel="VCL cutoff", colorbar_label="Net-to-gross pay", values="{:.2f}",
title="Brent Group net-to-gross pay", figsize=(7, 4.5));
Specialist displays (NMR panel, borehole images, XRF, saturation-height, core plots) are shown in Specialist data.
The XRF panel converts all elements to one mass-concentration unit (concentration_unit="%"
by default, or "ppm") before drawing shared axes and calculating proxies.
Missing element units warn and assume percent; unknown units raise an error.
Controlling the log viewer¶
pp.plot takes a well, a result or a well file (pp.plot("well.las")) and returns a LogViewer, a matplotlib figure shown inline in a notebook and saved by .save(path) as PNG, PDF, SVG or any other matplotlib format. Choose the window and tracks, then read what it did.
Several wells give a MultiWellPlot (each well’s own plot, one at a time; .save(folder) writes a file per well), or with curves= a WellComparisonPlot (one figure, a track per curve with every well in it).
The auto template of the interpreted 30/6-5 has the tracks DEPTH, LITHOLOGY,
GAMMA / HOLE, RESISTIVITY, DENSITY / NEUTRON, SONIC, POROSITY, SATURATION,
PERMEABILITY, ROCK QUALITY, MINERAL VOLUMES and FLAGS; tracks= keeps a few of them.
Some curves are drawn only when curves= names them: the single clay volumes VCL_GR,
VCL_ND and VCL_SP, the porosities PHID, PHIS and PHIN, and the invasion ratio
INVASION_RATIO and MHI, each of the last two in a track of its own, shaded where its
rule of thumb reads invasion or moved hydrocarbon.
focus = pp.plot(result, top=2841, bottom=2958,
tracks=["GAMMA / HOLE", "POROSITY", "SATURATION", "FLAGS"])
focus
The viewer reports what it did. The Dunlin Group and Drake Formation tops sit at the bottom of this window, so their labels are suppressed:
focus.diagnostics["suppressed_formation_labels"]
[{'name': 'DUNLIN GP.',
'depth': 2958.0,
'reason': 'at the bottom of the window'},
{'name': 'Drake Fm.',
'depth': 2958.0,
'reason': 'at the bottom of the window'}]
Control or attribute |
What it does |
|---|---|
|
Window in the well’s depth unit; each defaults to its end of the logged interval |
|
Track display names to keep, in order; also draws the optional TEMPERATURE and RW / RMF tracks |
|
Only these curves, each in its usual track, by the file’s names or standard names ( |
|
Colour, scale, line, fill or marker of single curves, without an XML template |
|
Your mnemonics to standard names: a dict, or a CSV/Excel table with |
|
Named layout, or an XML file with your own tracks, scales and fills |
|
Formation tops and lithology intervals for this plot only, as for |
|
Formation name shown in the plot title |
|
Codebook of a lithology code curve: a mapping of code to rock name, or a CSV/Excel codebook |
|
Fail when a fixed template needs a missing curve, instead of skipping the track |
|
Tracks left out because their curves are missing |
|
Imports, curve choices, omitted empty tracks, optional tracks left out, and labels suppressed to avoid crowding |
|
Plot-only warnings, such as a curve whose values run off its track scale |
|
Output |
A style or window you give is drawn as given. For example, 100 m from the Brent Group top, the lithology fill at 30 % opacity, and your own lithology codes:
pp.plot(result, top=2841, bottom=2941,
curve_styles={"LITHOLOGY_GEOLINK": {"fill_alpha": 0.3}})
pp.plot(result, lithology_codes={65000: "Sandstone", 30000: "Shale"})
Your curve names, your curves, your styles¶
The Teapot Dome well 44-MDX-10 uses company mnemonics (DT, SPR, LLS, LLD,
MSFL, NPOR, RHOB, CORR, GRD, CALD). Standard names find most of them;
its spontaneous potential SPR is known to no alias table, so a mapping places it.
The mapping can be a dict or a CSV/Excel table (curve, standard), given to
pp.read (stored on the well, used by plotting and interpretation alike) or to one
pp.plot. curve_styles restyles single curves:
pp.plot(pp.sample("teapot_44-mdx-10"), curves=["GR", "SP", "RDEP", "RMED", "NPHI", "RHOB"],
curve_aliases={"SPR": "SP"}, top=2400, bottom=3000,
curve_styles={"GR": {"color": "black"}, "SP": {"color": "#984ea3"}})
Coincident formation tops are grouped, not discarded. Plotting never computes a missing curve: a well without Sw shows no Sw. auto_template() lists the tracks auto would draw before you render.
Exports¶
Write curves for other software, a full trace for review, or a delivery package for a folder of wells. The interpretation writes its own LAS file and trace:
result.to_las("30_6-5_interpreted.las") # curves + settings in ~Params
result.to_json("30_6-5_trace.json") # every step, input and decision
result.to_markdown("30_6-5_trace.md");
Chosen curves go to CSV or Excel, and a delivery LAS standardizes the curve families:
from petrophys.io import export_csv, export_excel
from petrophys.reporting import export_example_format_las
curves = ["GR", "VCL", "PHIE", "SW", "PERM", "NET_PAY"]
export_csv(result.well, "30_6-5.csv", curves=curves)
export_excel(result.well, "30_6-5.xlsx", curves=curves)
export_example_format_las(result.well, "delivery/30_6-5.las", set_name="Petrophys interpretation");
Several wells interpret together and write a LAS file and a plot per well:
results = pp.interpret(costa, lithology="carbonate", carbonate_calibration="costa")
results.to_las("interpreted")
results.save_plots("plots");
from pathlib import Path
sorted(path.as_posix() for path in Path().rglob("*.*"))
['30_6-5.csv',
'30_6-5.xlsx',
'30_6-5_interpreted.las',
'30_6-5_trace.json',
'30_6-5_trace.md',
'delivery/30_6-5.las',
'interpreted/HW-3.las',
'interpreted/HW-4.las',
'interpreted/HW-5.las',
'interpreted/HW-6.las',
'interpreted/HW-7.las',
'plots/HW-3.png',
'plots/HW-4.png',
'plots/HW-5.png',
'plots/HW-6.png',
'plots/HW-7.png']
Export |
Call |
Contents |
|---|---|---|
Interpreted LAS |
|
All curves with units and descriptions; settings as |
Trace |
|
Every step’s method, inputs, outputs, parameters and decisions |
Tables |
|
Chosen curves with depth; missing values left blank |
Delivery LAS |
|
Standardized curve families with calculation provenance |
Several wells |
|
One interpreted LAS and one plot per well |
Work package |
|
Runs the workflow on each LAS in a folder: interpreted LAS plus reference JSON |
Batch plots |
|
One PNG per LAS in a folder and a CSV of what was drawn or skipped |
For LLM-ready JSON grouped by formation and lithology, see Context export.
Next¶
Specialist data: NMR, spectral gamma, core, saturation-height and borehole-image data, with their own displays.
Tutorial 17 shows every plot type with the reasoning behind it, and tutorial 18 adds batch runs, normalization and field charts.