XRFData

petrophys.interpretation.geochemistry.XRFData

class XRFData(depth, elements, units=<factory>, errors=<factory>, metadata=<factory>)[source]

XRF geochemistry measurements along a core depth.

Parameters:
  • depth (np.ndarray) – Measured depth of each sample (m or ft).

  • elements (dict) – Mapping of element symbol → concentration array (% or ppm).

  • units (dict) – Mapping of element symbol → unit string (e.g. “%”, “ppm”).

  • errors (dict, optional) – Mapping of element symbol → measurement error array.

  • metadata (dict) – Additional header information from the LAS file.

Examples

>>> xrf = XRFData.from_las("core_xrf.las")
>>> ratios = xrf.elemental_ratios()
>>> proxies = xrf.mineral_proxies()

Attributes

bottom

Deepest depth.

element_names

List of available element names.

n_samples

Number of depth samples.

top

Shallowest depth.

depth

elements

units

errors

metadata

Methods

elemental_ratios

Compute standard geochemical ratios used in mineral discrimination.

filter_by_depth

Return a new XRFData filtered to [top, bottom].

from_dataframe

Create XRFData from a pandas DataFrame.

from_las

Load XRF data from a LAS file.

get

Return concentration array for an element, or None if not present.

mineral_proxies

Derive normalized mineral proxy indices (0–1) from elemental data.

to_dataframe

Export to a pandas DataFrame with depth + all elements.

depth: ndarray
elements: Dict[str, ndarray]
units: Dict[str, str]
errors: Dict[str, ndarray]
metadata: Dict[str, Any]
property element_names: List[str]

List of available element names.

property n_samples: int

Number of depth samples.

property top: float | None

Shallowest depth.

property bottom: float | None

Deepest depth.

classmethod from_las(filepath, error_suffix='_ERR', null_value=-999.25)[source]

Load XRF data from a LAS file.

Depth is read via lasio’s las.index property (always the first column, regardless of mnemonic name). Element curves are any curve whose mnemonic does not end with error_suffix.

Parameters:
  • filepath (str or Path) – Path to the LAS file.

  • error_suffix (str) – Suffix that identifies error/uncertainty curves (default: “_ERR”).

  • null_value (float) – Value to replace with NaN (default: -999.25).

Return type:

XRFData

classmethod from_dataframe(
df,
depth_col='DEPTH',
element_cols=None,
error_cols=None,
unit_map=None,
null_value=-999.25,
)[source]

Create XRFData from a pandas DataFrame.

Parameters:
  • df (pd.DataFrame)

  • depth_col (str)

  • element_cols (list, optional) – Columns to treat as element concentrations. Defaults to all numeric columns except depth_col.

  • error_cols (dict, optional) – Mapping of element name → error column name.

  • unit_map (dict, optional) – Mapping of element name → unit string.

  • null_value (float) – Value to replace with NaN (default: -999.25).

Return type:

XRFData

get(element)[source]

Return concentration array for an element, or None if not present.

Lookup is case-insensitive so both chemical-symbol keys (“Si”) and upper-cased LAS mnemonics (“SI”) resolve to the same element.

Parameters:

element (str)

Return type:

ndarray | None

elemental_ratios()[source]

Compute standard geochemical ratios used in mineral discrimination.

Returns:

Ratio name → array. Every ratio is returned; it is all NaN when either element is absent.

Return type:

dict

Notes

Ratios and their petrophysical meaning:

Ratio

Interpretation

Si_Al

Quartz/clay ratio — high = clean sand

Ca_Al

Carbonate index — high = limestone/dolomite

Fe_Al

Iron enrichment — pyrite, siderite, chlorite

K_Al

Illite/feldspar proxy

Mg_Ca

Dolomite vs calcite — high = dolomite

Mg_Al

Chlorite proxy

S_Fe

Pyrite indicator — FeS₂ has S/Fe ≈ 1.15 by weight

Rb_K

Rb substitutes for K in illite, micas and K-feldspar

Mn_Fe

Mn enrichment relative to Fe (carbonates, redox)

Ca_Ca_Mg

Calcite fraction in carbonate (Ca/(Ca+Mg))

Al_Al_Si

Clay fraction (Al/(Al+Si))

mineral_proxies()[source]

Derive normalized mineral proxy indices (0–1) from elemental data.

These are quick lithology discriminators, not quantitative volumes. Use the multi-mineral solver for quantitative mineral fractions.

Returns:

Proxy name → array (0-1 scale where possible).

Return type:

dict

filter_by_depth(top, bottom)[source]

Return a new XRFData filtered to [top, bottom].

Parameters:
Return type:

XRFData

to_dataframe()[source]

Export to a pandas DataFrame with depth + all elements.

Return type:

DataFrame