DynamicWorkflowResult

petrophys.workflow.DynamicWorkflowResult

class DynamicWorkflowResult(
well,
config,
steps_executed=<factory>,
steps_skipped=<factory>,
specific_steps_skipped=<factory>,
errors=<factory>,
warnings=<factory>,
lithology_domain='auto',
rw_computed=None,
rmf_computed=None,
rcl_computed=None,
temperature_gradient=None,
context_profile=None,
preparatory_steps=<factory>,
post_workflow_steps=<factory>,
zone_results=<factory>,
zone_names=<factory>,
zone_intervals=<factory>,
)[source]

Results from dynamic workflow execution.

Attributes

context_profile

The context profile whose context interpretation this is (petrophys.interpret(..., context_profile=...)), else None.

has_usable_interpretation

Return whether a successful interpretive step produced a curve.

lithology_domain

The lithology domain the run interpreted with, e.g. "clastic" or "carbonate".

rcl_computed

Clay resistivity used (ohm.m); None when none was computed.

rmf_computed

Mud filtrate resistivity used (ohm.m), as rw_computed; None when no Rmf was computed.

rw_computed

one value, or a value per depth sample at formation temperature.

status

Return the execution status.

success

Return True when errors is empty and no executed step failed.

temperature_gradient

Temperature gradient of the temperature step (degF per 100 ft); None when the step did not run.

well

the input curves and the calculated ones.

config

The settings the run used.

steps_executed

The record of each step that ran, in run order; a step that failed is included with success False and the reason in message.

steps_skipped

Names of the steps that did not run.

specific_steps_skipped

Why each skipped step did not run, by step name.

errors

an input the workflow cannot use, or a failed step as "<step>: <reason>".

warnings

Assumed values and data-quality findings to check.

preparatory_steps

Trace entries of the context profile's preparatory step.

post_workflow_steps

Trace entries of the context's value-range QC and dependent-curve recomputation, applied to well after the workflow.

zone_results

One run per distinct set of zone settings (config.zones and LAS header zones), each merged into well over its depths; empty when no zone sets anything (a zone that only names an interval adds no run).

zone_names

the names of the zones it computed.

zone_intervals

The zones of config.zones that apply to this well, in depth order: name, top and bottom in the well's depth unit.

Methods

formation_summary

Gross, net and average properties for each formation.

group_records

Each formation and lithology group's record, with its own routing notes, as its context gives it.

plot

Plot the interpretation: petrophys.plot(result, **options), with its options.

print_trace

Print a comprehensive human-readable trace of all steps.

provenance_parameters

Summarize the settings this interpretation used, as LAS parameters.

raise_for_errors

Raise RuntimeError when execution failed; return this result for chaining.

statistics

Statistics of curves of the interpreted well over a depth window.

step

The record of one executed step: its method, decisions, parameters, input_curves and output_curves.

summary

Summarize the interpretation as compact, JSON-serializable data.

to_dataframe

Return the step trace as a DataFrame, one row per executed step.

to_json

Export the workflow route as JSON.

to_las

Write the interpreted well to LAS with the settings used.

to_markdown

Export the workflow route as a human-readable Markdown report.

to_trace_dict

Export the full workflow route as a JSON-safe dictionary.

zone_summary

Gross, net and average properties for each zone.

Parameters:
well: Well

the input curves and the calculated ones.

Type:

The interpreted well

config: DynamicWorkflowConfig

The settings the run used.

steps_executed: List[StepResult]

The record of each step that ran, in run order; a step that failed is included with success False and the reason in message.

steps_skipped: List[str]

Names of the steps that did not run.

specific_steps_skipped: dict[str, str]

Why each skipped step did not run, by step name.

errors: List[str]

an input the workflow cannot use, or a failed step as "<step>: <reason>". Empty for a run that succeeded.

Type:

What made the run fail

warnings: List[str]

Assumed values and data-quality findings to check.

lithology_domain: str = 'auto'

The lithology domain the run interpreted with, e.g. "clastic" or "carbonate".

rw_computed: float | ndarray | None = None

one value, or a value per depth sample at formation temperature. None when no Rw was computed.

Type:

Formation water resistivity used (ohm.m)

rmf_computed: float | ndarray | None = None

Mud filtrate resistivity used (ohm.m), as rw_computed; None when no Rmf was computed.

rcl_computed: float | None = None

Clay resistivity used (ohm.m); None when none was computed.

temperature_gradient: float | None = None

Temperature gradient of the temperature step (degF per 100 ft); None when the step did not run.

context_profile: str | None = None

The context profile whose context interpretation this is (petrophys.interpret(..., context_profile=...)), else None.

preparatory_steps: List[Dict[str, Any]]

Trace entries of the context profile’s preparatory step.

post_workflow_steps: List[Dict[str, Any]]

Trace entries of the context’s value-range QC and dependent-curve recomputation, applied to well after the workflow.

zone_results: List[DynamicWorkflowResult]

One run per distinct set of zone settings (config.zones and LAS header zones), each merged into well over its depths; empty when no zone sets anything (a zone that only names an interval adds no run).

zone_names: List[str]

the names of the zones it computed.

Type:

For a run in zone_results

zone_intervals: List[Dict[str, Any]]

The zones of config.zones that apply to this well, in depth order: name, top and bottom in the well’s depth unit.

property has_usable_interpretation: bool

Return whether a successful interpretive step produced a curve.

property status: str

Return the execution status.

"failed" when the run has errors or a failed step, "interpreted" when it succeeded and an interpretive step wrote a curve, and "no_interpretation" when it succeeded without one.

property success: bool

Return True when errors is empty and no executed step failed.

raise_for_errors()[source]

Raise RuntimeError when execution failed; return this result for chaining.

Return type:

DynamicWorkflowResult

plot(**options)[source]

Plot the interpretation: petrophys.plot(result, **options), with its options.

print_trace()[source]

Print a comprehensive human-readable trace of all steps.

Return type:

None

to_dataframe()[source]

Return the step trace as a DataFrame, one row per executed step.

The columns are Step, Status (OK or FAIL), Method, Input Curves, Output Curves, Parameters, Decisions and Message. For the interpreted log curves use result.well.to_dataframe().

to_trace_dict(include_curves=None)[source]

Export the full workflow route as a JSON-safe dictionary.

The trace is recorded at the workflow module boundary, so each step shows why that module ran, which method was selected, which curves were consumed, which curves were written, and the parameters used.

Parameters:

include_curves (List[str] | None)

Return type:

Dict[str, Any]

group_records(**options)[source]

Each formation and lithology group’s record, with its own routing notes, as its context gives it.

See petrophys.reporting.context_profiles.interpretation_group_records() for the options (tops_file and lithology_mapping_file for context-profile results, minimum_group_thickness, documents).

Parameters:

options (Any)

Return type:

List[Dict[str, Any]]

to_json(path=None, include_curves=None, indent=2)[source]

Export the workflow route as JSON.

If path is provided, the JSON file is written and the output path is returned. Otherwise the JSON string is returned.

Parameters:
Return type:

str | Path

formation_summary(formations=None, *, rank=None)[source]

Gross, net and average properties for each formation.

Parameters:
  • formations (path, DataFrame, mapping or sequence, optional) – Formation tops or intervals (anything petrophys.read_formations() accepts). Defaults to the formations attached with petrophys.read(path, formations=...).

  • rank (str, optional) – Level to summarize when the tops mix levels, e.g. "group"; tops that mix levels default to "formation". NPD-style names ("Brent Gp.", "Etive Fm.") carry their rank; other tables need a rank column to mix levels. Tops at or below the logged bottom are left out.

Returns:

One row per formation: top, bottom, gross, net rock, net reservoir and net pay thickness (in the well’s depth unit), net reservoir / gross (“N/G (reservoir)”) and net pay / gross (“Pay/Gross”), and PHIE, Sw, VCL and permeability averaged over the net-pay samples only: porosity and clay volume weighted by thickness, Sw by pore volume (porosity x thickness), permeability a geometric mean (NaN where a formation has no pay). DataFrame.attrs["curves"] names the curve each pay average is taken from (PHIE_CC and PERM_CC where the interpretation produced or used them, PHIE and PERM at the samples those do not cover). Avg GR, Avg RHOB, Avg NPHI, Avg RDEP and Avg PHIT are means over the whole formation. HCPV is the hydrocarbon pore thickness, the sum of PHIE x (1 - Sw) x thickness over net pay (depth unit), and BVW the thickness-weighted mean of PHIE x Sw over net pay (v/v). Samples and Pay Samples count the depth samples, and Data Coverage % is the share of samples with RHOB.

Return type:

DataFrame

Raises:

ValueError – If no formations are given or attached to the well.

Examples

>>> import petrophys as pp
>>> well = pp.read(pp.sample("30_6-5"), formations=pp.sample("formations_30_6-5"))
>>> result = pp.interpret(well, rw=0.07, rw_meas_temp="230 degF")
>>> table = result.formation_summary()
zone_summary(zones=None)[source]

Gross, net and average properties for each zone.

Parameters:

zones (path, DataFrame or sequence of mappings, optional) – Zones as DynamicWorkflowConfig.zones takes them: one row per zone with its name (or zone), top and bottom, in a CSV or Excel file, a table or a list. A well column selects the rows of this well. Defaults to the zones passed to petrophys.interpret(well, zones=...).

Returns:

One row per zone, with the columns of formation_summary(); the first column is Zone.

Return type:

DataFrame

Raises:

ValueError – If no zones are given and the interpretation had none.

Examples

>>> import petrophys as pp
>>> zones = [{"zone": "Upper", "top": 2841, "bottom": 2900},
...          {"zone": "Lower", "top": 2900, "bottom": 2958}]
>>> result = pp.interpret(pp.read(pp.sample("30_6-5")), rw=0.07, rw_meas_temp="230 degF", zones=zones)
>>> list(result.zone_summary()["Zone"])
['Upper', 'Lower']
summary(top=None, bottom=None)[source]

Summarize the interpretation as compact, JSON-serializable data.

Designed for reports and LLM agents: everything needed to judge the result without walking the full trace.

Parameters:
  • top (float, optional) – Depth window (well depth unit) for key_results and net_thickness; defaults to the whole well.

  • bottom (float, optional) – Depth window (well depth unit) for key_results and net_thickness; defaults to the whole well.

Returns:

petrophys_version, well (its name), status, lithology_domain, resolved matrix and lithology, settings_used (non-default settings), summary_interval (top, bottom and depth_unit), key_results (statistics of VCL, PHIT, PHIE, SW and PERM, and of PHIE_CC and PERM_CC where the pay averages use them), net_thickness (net_rock, net_res and net_pay in depth_unit), executed_steps, skipped_steps with reasons, warnings and errors. Use to_trace_dict() for every step’s full record.

Return type:

dict

Examples

>>> import petrophys as pp
>>> result = pp.interpret(pp.read(pp.sample("30_6-5")), rw=0.07, rw_meas_temp="230 degF")
>>> result.summary(top=2841, bottom=2958)["status"]
'interpreted'
step(name)[source]

The record of one executed step: its method, decisions, parameters, input_curves and output_curves.

A step that did not run raises KeyError, with the reason it was skipped and the names of the steps that ran.

>>> result.step("rw").decisions
Parameters:

name (str)

Return type:

StepResult

statistics(curves=None, top=None, bottom=None)[source]

Statistics of curves of the interpreted well over a depth window.

Parameters:
  • curves (str or sequence of str, optional) – Curves to describe (the well’s names); default VCL, PHIT, PHIE, SW and PERM where present.

  • top (float, optional) – Depth window in the well’s depth unit; default the whole well.

  • bottom (float, optional) – Depth window in the well’s depth unit; default the whole well.

Returns:

A row per curve: unit, samples (finite), mean, p10, median and p90.

Return type:

DataFrame

Raises:

KeyError – If a named curve is not in the well.

provenance_parameters()[source]

Summarize the settings this interpretation used, as LAS parameters.

Returns:

PP_* entries (mnemonic, value, unit, descr): package version, status, resolved matrix and lithology domain, Rw input and its temperature-corrected range, Sw model and Archie exponents.

Return type:

list of dict

to_las(path, **options)[source]

Write the interpreted well to LAS with the settings used.

The ~Params section keeps the source file’s header values and adds provenance_parameters() (PP_*); ~Other lists executed and skipped steps and, under the "current" calculation profile, the run’s warnings. Use to_json() for the complete trace.

The clay-volume aliases the workflow keeps for other readers (VCLAY, VCLGR, VCLSP, VCLND, copies of VCL, VCL_GR, VCL_SP, VCL_ND) are left out unless curves names them.

Parameters:
Returns:

The written file.

Return type:

Path

to_markdown(path=None, include_curves=None)[source]

Export the workflow route as a human-readable Markdown report.

This mirrors to_json but is easier to scan when checking per-module routing decisions for a single well.

Parameters:
Return type:

str | Path