impute

petrophys.preprocessing.imputation.impute

Also available as petrophys.impute

impute(well, curve, *, train_wells=None, output=None)[source]

Reconstruct the missing samples of a curve.

A gradient-boosted tree model learns curve from the other logs (gamma ray, density, neutron, sonic, resistivity and so on) wherever it was measured, in this well and in train_wells, and predicts it where it is missing. The result is added as <CURVE>_IMPUTED, named after the well’s own mnemonic for the curve (ZDEN_IMPUTED for a ZDEN density asked for as "RHOB"): the measured values where the curve has them and the predictions in its gaps. The original curve is left as it is.

To show how far the predictions can be trusted, <CURVE>_PREDICTED holds a prediction at every depth. Where the curve was measured, each prediction comes from a model that did not learn from that sample’s part of the well (the measured samples split into five contiguous depth blocks, each predicted by a model trained on the other four and the training wells), so its difference from the measured curve is the error to expect in a gap. The curve’s description gives that error (mean absolute error, bias and R2) in the unit the curve is stored in; for the curves modelled as log10 (resistivity, permeability) it is the error of log10 of the curve, so a mean absolute error of 0.3 is a factor of 2. pp.plot(well, curves=["RHOB", "RHOB_PREDICTED"]) overlays the two. In the gaps it holds the imputed values.

Parameters:
  • well (Well, DynamicWorkflowResult or path) – The well, an interpretation result (its interpreted well), or a LAS, DLIS, CSV or TSV file.

  • curve (str) – The curve to reconstruct, by its mnemonic or standard name ("RHOB", "DT", "NPHI" …).

  • train_wells (Well, DynamicWorkflowResult or path, or a sequence of them, optional) – Other wells to learn from, typically from the same field. Needed when the well lacks the curve altogether, and useful when its measured part is short. Where the well has measured samples of the curve, the well itself among them (the same name, or the same depths and curve values) is left out, with a warning: its samples are learned from once, and the check of <CURVE>_PREDICTED must not see the samples it holds back.

  • output (path, optional) – Write the well, with the new curve, to this LAS file.

Returns:

What was passed, with <CURVE>_IMPUTED and <CURVE>_PREDICTED added to its well: the result for a result, else the well.

Return type:

Well or DynamicWorkflowResult

Raises:

ValueError – If fewer than 200 samples with the curve measured are available to learn from, or no log the model can use is present where the curve is missing.

Notes

The model does not learn from held readings of the curve (runs of 10 or more identical samples, such as a zero-filled or padded curve), and a training well without one of the input logs still teaches the others. Tree models reproduce the relations seen in training and do not extrapolate: where the input logs fall outside the range they had in the training data (the 1st to 99th percentile, widened by a tenth of that span on each side), a warning gives the number of such samples. Depth is not used as an input. Imputation needs scikit-learn (pip install "petrophys[ml]").

Examples

>>> well = pp.impute("16_7-1.las", "RHOB", output="16_7-1_imputed.las")
>>> well = pp.impute(target, "DT", train_wells=["HW-3.las", "HW-4.las"])