find_core_depth_shift

petrophys.interpretation.core_analysis.find_core_depth_shift

find_core_depth_shift(
well,
core,
log_curve='PHIE',
*,
core_property='porosity',
shifts=None,
max_shift=None,
step=None,
log_scale=False,
run_gap=None,
min_run_plugs=30,
min_points=10,
)[source]

Find the depth shift that best ties core plugs to a log curve.

Each candidate shift is added to the plug depths, the log is interpolated at the shifted depths, and the Pearson correlation between the core property and the log is computed. The shift with the highest (signed) correlation wins; a negative correlation is never treated as a good tie.

Parameters:
  • well (Well) – Well carrying log_curve. The log must be computed independently of the core (comparing core porosity with a core-corrected curve gives a meaningless tie).

  • core (CoreData) – Core plugs, for example from core_data().

  • log_curve (str, default "PHIE") – Log curve to match.

  • core_property (str, default "porosity") – CoreData attribute to match: "porosity", "permeability", "grain_density", "sw" or "so". Zero or negative porosity and permeability are treated as unmeasured.

  • shifts (sequence of float, optional) – Explicit shifts to scan, in well depth units. Overrides max_shift and step.

  • max_shift (float, optional) – Largest shift to scan in either direction, in well depth units. Defaults to 30 log samples (about 4.6 m, or 15 ft, at the standard 0.1524 m / 0.5 ft sampling).

  • step (float, optional) – Shift increment in well depth units. Defaults to the median log sample step.

  • log_scale (bool, default False) – Compare log10 values; use it for permeability.

  • run_gap (float, optional) – When given, also scan each core run on its own. Runs are separated where consecutive plugs are more than run_gap apart (depth units).

  • min_run_plugs (int, default 30) – Runs with fewer valid plugs are not scanned on their own.

  • min_points (int, default 10) – Minimum valid plug/log pairs for a correlation to be computed.

Returns:

Best shift, the correlation before and after, the full scan and, with run_gap, the per-run shifts.

Return type:

CoreDepthShift

Raises:

ValueError – If the curve or core property is missing, the scan settings are invalid, or no shift has min_points valid pairs.

Warns:

UserWarning – If the best shift lies at the edge of the scanned window, or its correlation is below 0.5.

See also

shift_core_depths

Apply the shift to a CoreData.

petrophys.interpretation.core_analysis.calibrate_porosity

Calibration statistics at the stored (or shifted) plug depths.

Examples

>>> import numpy as np
>>> from petrophys import Well
>>> from petrophys.interpretation.core_analysis import CoreData
>>> well = Well("DEMO")
>>> well.depth = np.arange(1000.0, 1100.0, 0.5)
>>> _ = well.add_curve("PHID", 0.2 + 0.05 * np.sin(well.depth / 3.0), "v/v")
>>> plugs = np.arange(1020.0, 1080.0, 1.0)
>>> core = CoreData(depth=plugs - 2.0,                  # stored 2 m too shallow
...                 porosity=0.2 + 0.05 * np.sin(plugs / 3.0))
>>> scan = find_core_depth_shift(well, core, "PHID", max_shift=5.0)
>>> float(scan.shift)
2.0
>>> tied = shift_core_depths(core, scan)