Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src2015_04/article4_microresistivity_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@

def histogram_scale(image, ref_min, ref_max):
"""Linear min-max histogram scaling of an image array onto [ref_min, ref_max]."""
img = np.asarray(image, float)
lo, hi = np.min(img), np.max(img)
return ref_min + (img - lo) * (ref_max - ref_min) / (hi - lo)
return petrolib.data_qc_io.scale.normalize_to_reference(image, ref_min, ref_max, pct=None)


def median_curve(image_array):
Expand Down
2 changes: 1 addition & 1 deletion src2016_02/article3_low_permeability_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def deviation_indicator(x1, x2):
the fractional discrepancy used to compare permeability/porosity from
different techniques.
"""
return 2.0 * abs(x1 - x2) / (x1 + x2)
return float(petrolib.data_qc_io.clean.relative_discrepancy(x1, x2))


# ---------------------------------------------- tests --------------
Expand Down
14 changes: 10 additions & 4 deletions src2016_12/article6_gr_normalization_haynesville.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,20 @@

import numpy as np

try:
import petrolib
except ImportError: # bare clone, not installed
import sys, pathlib
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
import petrolib


# ---------------------------------------------- normalization --------------

def histogram_normalize(gr, gr_min, gr_max, ref_min, ref_max):
"""Linear histogram normalization of a GR log onto a reference [ref_min, ref_max]."""
gr = np.asarray(gr, float)
return ref_min + (gr - gr_min) * (ref_max - ref_min) / (gr_max - gr_min)
return petrolib.data_qc_io.scale.normalize_to_reference(
gr, ref_min, ref_max, in_lo=gr_min, in_hi=gr_max)


def tst_projection(gr_vertical, tst_vertical, tst_query):
Expand All @@ -47,8 +54,7 @@ def affine_normalize(gr_raw, target_mean, target_std):

GR_norm = (GR_raw - mean)/std * target_std + target_mean.
"""
gr = np.asarray(gr_raw, float)
return (gr - gr.mean()) / gr.std() * target_std + target_mean
return petrolib.data_qc_io.scale.match_moments(gr_raw, target_mean, target_std)


def max_percent_shift(gr_raw, gr_norm):
Expand Down
2 changes: 1 addition & 1 deletion src2017_10/article5_permian_core_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def hydrocarbon_pore_volume(phi, sw):

def relative_discrepancy(value_a, value_b):
"""Relative discrepancy between two method results |a - b|/mean(a, b)."""
return abs(value_a - value_b) / (0.5 * (value_a + value_b))
return float(petrolib.data_qc_io.clean.relative_discrepancy(value_a, value_b))


# ---------------------------------------------- tests --------------
Expand Down
9 changes: 2 additions & 7 deletions src2018_12/article11_data_preconditioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,12 @@ def zscore_outliers(x, thresh=3.0):

def iqr_outliers(x, k=1.5):
"""Boolean mask of IQR outliers (outside Q1 - k*IQR, Q3 + k*IQR)."""
x = np.asarray(x, float)
q1, q3 = np.percentile(x, [25, 75]); iqr = q3 - q1
return (x < q1 - k * iqr) | (x > q3 + k * iqr)
return petrolib.data_qc_io.clean.outlier_mask(x, "iqr", k=k)


def impute_gaps(x):
"""Fill NaN gaps by linear interpolation over the index."""
x = np.asarray(x, float).copy()
idx = np.arange(len(x)); good = ~np.isnan(x)
x[~good] = np.interp(idx[~good], idx[good], x[good])
return x
return petrolib.data_qc_io.clean.impute_gaps(x)


# ---------------------------------------------- tests --------------
Expand Down
2 changes: 1 addition & 1 deletion src2019_02/article4_insitu_saturation_core_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def reconstruct_insitu(so_measured, sg_measured, retention):

def closure(sw, so, sg):
"""Saturation closure residual Sw + So + Sg - 1 (should be ~0)."""
return sw + so + sg - 1.0
return float(petrolib.data_qc_io.clean.closure_residual(sw, so, sg))


# ---------------------------------------------- tests --------------
Expand Down
Loading