Skip to content

ps.results

ps.results.ResultError(*args: Any, code: str | None = None, address: str | None = None, fix: str | None = None, at: str | None = None) -> None

A run’s output that cannot be read, or a run that stopped short.

except ps.results.ResultError as error: catches a run folder that cannot be read.

ps.results.open(folder) -> Run

Open a finished run’s folder and read it by PetroScript’s names.

ps.results.open("runs/case") reads the run in that folder: run.field("oil_production_rate") is a frame of the field’s oil rate.

The target that wrote the run reads it (the one its <CASE>.run.json names, as deck.run() writes it; opm-flow otherwise): summary quantities as polars frames (run.field("oil_production_rate"), run.wells("bottom_hole_pressure")), cell arrays as read-only (nx, ny, nz) arrays with NaN in the cells the run did not simulate (run.initial["pressure"], run.static["pore_volume"]), and the run’s own log (run.log). It warns when the record says the run stopped short, or the folder holds none, and reads what the run wrote.

folder : str or Path The folder the run wrote its files to.

Run The run, read on demand.

ResultError results.unknown when folder is no folder (a file names the folder that holds it), holds the run records of two targets (a reused folder; each record is named), or, for opm-flow, the folder does not hold exactly one *.SMSPEC file. CompileError target.unknown when the folder’s <CASE>.run.json names a target PetroScript does not hold.

import petroscript as ps run = ps.results.open(“tests/results_fixtures/QUICKSTART”) # Merle’s run, metric run.units, run.phases (‘metric’, (‘water’, ‘gas’)) run.field(“gas_production_total”)[“unit”][0] # sm3 of gas ‘sm3’

PetroScript is licensed under the Apache License 2.0. © 2026 Blauweiss EDV LLC. PetroScript by Blauweiss AI.For AI agents: llms.txt