parameter_sensitivity¶
petrophys.evaluation.sensitivity.parameter_sensitivity
Also available as petrophys.evaluation.parameter_sensitivity
- parameter_sensitivity(evaluate, cases, *, outputs=None)[source]¶
One-at-a-time sensitivity: the data behind a tornado chart.
evaluate()is called once with no arguments for the base case, then twice per case with that case’s low and high keyword changes; everything else stays at base. The widest swing names the assumption the answer depends on most, which is usually the measurement worth buying first.- Parameters:
evaluate (callable) –
evaluate(**changes)returns the answer for one set of changes: a number, a mapping of named numbers, or an object withto_dict()(for example aPaySummary). With no arguments it must return the base case.cases (mapping) –
{label: (low_changes, high_changes)}, each a mapping of keyword arguments forevaluate, e.g.{"Rw 0.05 / 0.09": ({"rw": 0.05}, {"rw": 0.09})}. “Low” and “high” refer to the settings, not to the result, which may move either way.outputs (sequence of str, optional) – Outputs to keep when
evaluatereturns several. Defaults to every numeric output.
- Returns:
One row per case and output:
case,output,low,base,high,swing(|high - low|),low_settingandhigh_setting. Rows are grouped by output and sorted by decreasing swing.attrs["base"]holds the base outputs.- Return type:
- Raises:
ValueError – If
casesis empty or malformed, or a requested output is missing.TypeError – If
evaluatereturns something that is not numeric.
See also
petrophys.visualization.tornado_plotDraw the result.
Examples
>>> def net_pay(rw=0.07, m=2.0): ... return 100.0 - 300.0 * rw - 10.0 * m >>> table = parameter_sensitivity( ... net_pay, ... {"Rw 0.05 / 0.09": ({"rw": 0.05}, {"rw": 0.09}), ... "m 1.8 / 2.2": ({"m": 1.8}, {"m": 2.2})}) >>> table["case"].tolist() # widest swing first ['Rw 0.05 / 0.09', 'm 1.8 / 2.2'] >>> table[["low", "base", "high", "swing"]].round(2).values.tolist() [[65.0, 59.0, 53.0, 12.0], [61.0, 59.0, 57.0, 4.0]]