Quickstart¶
Run a first well: read a bundled well, plot it, interpret it and export the result. Every output shown is computed from that well. Run it with Petrophys installed (Installation), or open it in Google Colab with the button above and run it in your browser, with nothing to install (New to Python?).
import pandas as pd
import petrophys as pp
well = pp.read(pp.sample("30_6-5")) # or the path to your own LAS file
well
Well(30/6-5, curves=20, samples=22176)
The well has 20 curves, logged from 177 m to 3556 m.
Plot the raw logs¶
pp.plot plots a well or an interpretation. Here it plots the logs as read,
before any interpretation, and tracks= picks four of the layout’s tracks. The
window, 2800–3000 m, brackets the Brent Group (2841–2958 m).
pp.plot(well, top=2800, bottom=3000,
tracks=["LITHOLOGY", "GAMMA / HOLE", "RESISTIVITY", "DENSITY / NEUTRON"])
UserWarning: SWC: inferred percent core saturation despite unit 'frac'; divided by 100
to v/v. Verify source units.
UserWarning: SOC: inferred percent core saturation despite unit 'frac'; divided by 100
to v/v. Verify source units.
Interpret¶
pp.interpret works on a copy of the well. Settings are keywords: here the
formation-water resistivity rw and the temperature it was measured at.
Interpretation settings lists them all.
result = pp.interpret(well, rw=0.07, rw_meas_temp="230 degF") # Rw 0.07 ohm.m at 230 degF
result.status
'interpreted'
result.warnings holds what the run wants you to check:
result.warnings
['Held readings, one value repeated exactly over ten samples or more: RHOB 1.8 over 180.42-242.752 m (411 samples), RSHA 7.012 over 3537.94-3555.32 m (116 samples), RHOB 1.9602 over 1461.19-1468.66 m (51 samples), GR 187.5 over 3548.77-3556.08 m (50 samples), RHOB 1.899 over 529.416-536.274 m (47 samples) and 28 more. A tool that stopped reading, or a log padded to a depth, holds its last value while the other logs change; check these against the other logs before using them.',
'lithology: PEF set aside: in 94% of 331 clean porous samples the apparent matrix density is quartz-like (< 2.67 g/cm3) but the apparent matrix U calcite-like (> 10 b/cm3), the signature of barite-weighted mud; minerals solved without PEF',
"Bad hole removed 107.25 m of net pay (BAD_HOLE at 12631 of 22176 samples). Check the flag against the caliper and DRHO; bad_hole={'drho': ..., 'cali': ...} sets its thresholds and skip_steps=['bad_hole'] keeps the pay.",
'Net pay where the gamma ray reads shale and neutron-density clean, VCL_GR above VCL_ND by more than 0.5: 2805.05-2805.66 m (VCL_GR 0.78, VCL_ND 0.11), 3272.77-3273.07 m (VCL_GR 0.72, VCL_ND 0.03). VCL takes the lower value, so these beds count as clean rock; check the density and neutron there (a density read too light in bad hole or near a casing shoe, gas, heavy minerals).',
"The LAS header gives rw_meas_temp=(230.0, 'degF'); not used, rw_meas_temp='230 degF' is set"]
The first says the photoelectric log (PEF) reads like barite-weighted mud, so the minerals were solved without it. The second says how much net pay the bad-hole flag removed over the whole well; Implausible inputs and bad hole explains that flag.
Note
The two UserWarning messages above the raw-log plot are real: this LAS labels
its core saturations SWC and SOC as fractions, but they hold percentages.
Petrophys divides them by 100 for plotting and core calibration and says so when
it reads them (Python shows a warning once per place it is raised, so the
interpretation does not repeat them here). They are Python warnings, not entries
of result.warnings. The rest of this page hides only these warnings; see
Core saturation units.
|
Meaning |
|---|---|
|
Steps ran and produced interpretation curves. |
|
Nothing failed, but the inputs supported no interpretation step. |
|
A step failed; |
To see the original exception while debugging, pass raise_on_error=True.
A step that cannot run is skipped with a reason, never filled with invented defaults:
result.specific_steps_skipped
{'spectral_gamma': 'Not run by the interpretation workflow; use petrophys.interpretation.geochemistry.interpret_spectral_gamma directly',
'elemental_spectroscopy': 'Not run by the interpretation workflow; use petrophys.interpretation.geochemistry.interpret_elemental_spectroscopy directly',
'hc_correction': 'apply_hc_correction=False (hydrocarbon correction is opt-in)',
'porosity_refinement': 'Not run by the interpretation workflow; porosity is computed once in the porosity step'}
Where Rw comes from
The workflow takes Rw from the first source it finds, your settings before the file’s header:
the Rw you set,
rw(atrw_meas_temp);the formation-water salinity you set,
salinity_ppm;the
RWvalue in the LAS header (at itsRWT, or atrw_meas_tempwhen you set one, else at the header formation temperatureFMT);a formation-water salinity in the LAS header (
WATSAL,WSAL,SAL, …);the SP or Rxo/Rt response, given a mud-filtrate resistivity (water-based mud only);
the apparent Rw of clean rock, with a warning: each sample’s apparent Rw is corrected from its own temperature to 75 degF, and the P5 of those values is taken as one water for the whole well (values saltier than saturated brine are left out). Use
zones=where the water changes, for example fresher shallow sands;a default of 0.05 ohm.m, with a warning (
allow_default_rw=Falseturns it off).
Give the temperature Rw was measured at with its unit, rw_meas_temp="230 degF"
or rw_meas_temp="110 degC"; without it, Rw is taken at the well’s median
formation temperature, with a warning. The 30/6-5 header gives RW = 0.07 ohm.m
at RWT = 230 degF, which the workflow would read by itself; this page passes
them as settings to show how you give your own.
Read the trace¶
Every executed step records its method, inputs, outputs, parameters and
decisions. result.to_dataframe() gives one row per step, and
result.print_trace() prints every record in full.
result.to_dataframe()[["Step", "Status", "Method", "Output Curves"]]
| Step | Status | Method | Output Curves | |
|---|---|---|---|---|
| 0 | normalization | OK | curve_alias_and_unit_standardization | DRHO, PEF, GR, DTC, SWC, SOC |
| 1 | input_context | OK | validated_geology_selection | |
| 2 | temperature | OK | linear_gradient_from_BHT | TEMP |
| 3 | bad_hole | OK | caliper_drho_flags | BAD_HOLE |
| 4 | vclay | OK | linear | VCL, VCLAY, VCL_GR, VCLGR, VCL_SP, VCLSP, VCL_ND, VCLND |
| 5 | rcl | OK | lithology_shale_median_rt | |
| 6 | rmf | OK | las_metadata_assumed_reference_temperature | RMF |
| 7 | porosity | OK | component_based | PHIN, PHID, PHIS, PHIT, PHIE, PHI_SEC |
| 8 | lithology | OK | multi_mineral_solver | VQUAR, VCALC, VDOLO, VANHY |
| 9 | core_correction | OK | same_well_core_correction | PHIE_CC, PERM_CC |
| 10 | rw | OK | user_provided_temperature_profile_corrected | RW |
| 11 | invasion | OK | rxo_rt_ratio | INVASION_RATIO |
| 12 | saturation | OK | archie+simandoux | SW, SXO |
| 13 | permeability | OK | auto | RESFLAG, PERM, PERM_CC, SWIRR_APP |
| 14 | rock_quality | OK | RQI_FZI_phi_z | RQI, FZI, PHI_Z |
| 15 | bvw | OK | PHIE_x_SW | BVW |
| 16 | mhi | OK | moveable_HC_index | MHI |
| 17 | net_pay | OK | cutoff_flags | NET_ROCK, NET_RES, NET_PAY, RESFLAG, SEALFLAG, NET_EXCLUSION, CROSSOVER_FLAG, PRIME_OIL_TARGET |
The rw row shows which Rw source was used:
user_provided_temperature_profile_corrected, the Rw you gave, corrected from
230 degF to the temperature of each depth.
Summarize the Brent Group¶
The log starts in shallow, poorly consolidated rock that can pass the pay cutoffs (the clay, porosity and saturation limits). One Rw also serves the whole well, while shallow formation waters are usually fresher than the reservoir’s, so shallow sections that no lithology code covers can be flagged as marginal pay; Where the pay sits explains this limitation. Summarize the interval you are evaluating, not the whole well.
result.summary()["net_thickness"]
{'depth_unit': 'm', 'net_rock': 1902.87, 'net_res': 786.69, 'net_pay': 50.9}
brent = result.summary(top=2841, bottom=2958)
brent["net_thickness"]
{'depth_unit': 'm', 'net_rock': 76.5, 'net_res': 65.99, 'net_pay': 25.3}
Of the 51 m of net pay in the whole well, 25 m lies in the Brent Group. The statistics of the interpreted curves over the same window:
result.statistics(top=2841, bottom=2958)
| unit | samples | mean | p10 | median | p90 | |
|---|---|---|---|---|---|---|
| VCL | v/v | 768 | 0.356 | 0.011 | 0.233 | 0.835 |
| PHIT | v/v | 768 | 0.200 | 0.130 | 0.204 | 0.263 |
| PHIE | v/v | 768 | 0.128 | 0.000 | 0.148 | 0.232 |
| SW | v/v | 768 | 0.778 | 0.243 | 1.000 | 1.000 |
| PERM | mD | 636 | 60.451 | 0.000 | 17.136 | 212.236 |
Plot the interpretation¶
Passing the result plots the interpreted well. The petrophysics template adds
porosity, saturation, permeability and pay-flag tracks.
pp.plot(result, top=2841, bottom=2958, template="petrophysics",
formation_name="Brent Group")
Export¶
to_las writes every curve plus the settings used, as PP_* parameters in the
LAS header. to_json writes the complete trace.
result.to_las("30_6-5_interpreted.las")
result.to_json("30_6-5_trace.json");
The PP_* parameters written to the LAS:
pd.DataFrame(result.provenance_parameters())
| mnemonic | value | descr | unit | |
|---|---|---|---|---|
| 0 | PP_VERSION | 3.0.0 | petrophys version | NaN |
| 1 | PP_STATUS | interpreted | Interpretation status | NaN |
| 2 | PP_DOMAIN | clastic | Lithology domain of the run (clastic, carbonate or evaporite) | NaN |
| 3 | PP_MATRIX | sandstone | Matrix of the porosity calculation | NaN |
| 4 | PP_RW | 0.070 | Rw input at 230 degF (user_provided_temperature_profile_corrected) | ohm.m |
| 5 | PP_RWTMIN | 0.062 | Lowest Rw at formation temperature over the well (Rw falls as temperature rises) | ohm.m |
| 6 | PP_RWTMAX | 0.197 | Highest Rw at formation temperature over the well | ohm.m |
| 7 | PP_SWMODEL | archie+simandoux | Water saturation model(s) | NaN |
| 8 | PP_A | per lithology | Archie a by lithology, from the lithology table (see the trace) | NaN |
| 9 | PP_M | 2.000 | Archie m, from the lithology table, the same for every lithology here | NaN |
| 10 | PP_N | 2.000 | Archie n, from the lithology table, the same for every lithology here | NaN |
Several wells¶
pp.read and pp.interpret take a folder, a file pattern ("logs/*.las") or a list of files as well as one file.
A multi-well tops table is read once and each well keeps its own picks; every well is interpreted with the same settings, its own header values filling the rest.
One table covers all the wells, and to_las(folder) and save_plots(folder) write a file per well.
A well that fails is named in results.failed; the others are interpreted.
wells = pp.read([pp.sample(name) for name in ["HW-3", "HW-4", "HW-5"]],
formations=pp.sample("formations_costa"))
results = pp.interpret(wells, lithology_domain="carbonate")
results.summary()
| Well | Status | Depth unit | Net rock | Net reservoir | Net pay | Median VCL | Median PHIE | Median SW | Median PERM | Warnings | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | HW-3 | interpreted | ft | 215.500 | 195.000 | 194.000 | 0.000 | 0.290 | 0.102 | 7.300 | 4 |
| 1 | HW-4 | interpreted | ft | 180.500 | 142.500 | 4.000 | 0.000 | 0.180 | 1.000 | 2.550 | 4 |
| 2 | HW-5 | interpreted | ft | 168.500 | 112.000 | 0.000 | 0.000 | 0.080 | 1.000 | 0.180 | 4 |
results.formation_summary()
| Well | Formation | Top | Bottom | Gross (ft) | Net Rock (ft) | Net Reservoir (ft) | Net Pay (ft) | N/G (reservoir) | Pay/Gross | ... | Avg GR | Avg RHOB | Avg NPHI | Avg RDEP | Avg PHIT | HCPV | BVW | Samples | Pay Samples | Data Coverage % | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | HW-3 | KHARAIB-2 | 7805.000 | 8020.000 | 215.500 | 215.500 | 195.000 | 194.000 | 0.905 | 0.900 | ... | 12.322 | 2.377 | 0.099 | 37.938 | 0.198 | 45.921 | 0.027 | 431 | 388 | 100.000 |
| 1 | HW-4 | KHARAIB-2 | 8150.000 | 8330.000 | 180.500 | 180.500 | 142.500 | 4.000 | 0.789 | 0.022 | ... | 15.429 | 2.435 | 0.131 | 1.297 | 0.153 | 0.236 | 0.108 | 361 | 8 | 100.000 |
| 2 | HW-5 | KHARAIB-2 | 8182.000 | 8350.000 | 168.500 | 168.500 | 112.000 | 0.000 | 0.665 | 0.000 | ... | 20.743 | 2.595 | 0.071 | 15.237 | 0.069 | NaN | NaN | 337 | 0 | 100.000 |
3 rows × 24 columns
pp.plot on several wells draws each well’s own log plot, one after another; .save(folder) writes a file per well.
With curves=, it draws one figure instead: a track per curve, with every well’s curve in it.
pp.plot(results, curves=["GR", "RDEP", "PHIE", "SW"])
Next¶
Your own data: read your own CSV logs, attach formation and lithology tables, and check that their depths agree.
The complete tour runs every capability of the library on bundled data in one notebook, and the 30/6-5 case study evaluates this well step by step.