2.16.3.2. pycsamt.geology.lithology#

Lithology — resistivity-to-geology classification for EM methods.

The built-in RockDatabase covers the resistivity ranges encountered in MT, AMT, CSAMT, and CSEM surveys. Its entries live in pycsamt.geology.rock_library (not in this module, so the table can grow independently of the classification logic here), drawing on:

  • Palacky (1988) — resistivity of geological formations

  • Telford, Geldart & Sheriff (1990) — Applied Geophysics

  • Keller & Frischknecht (1966) — Electrical Methods in Geophysical Prospecting

  • Slichter & Telkes (1942) — electrical properties of minerals

  • Updated ranges for fracture zones, aquifers, and economic targets

StratigraphicLog packages a per-station depth profile with lithology assignments and can be exported to CSV, LAS 2.0, or Oasis Montaj XYZ format via pycsamt.interp.export.

Example

>>> db = RockDatabase.default()
>>> db.classify(250.0)
RockEntry(name='Granite (weathered)', rho_min=50, rho_max=2000, ...)
>>> log = StratigraphicLog.from_column(
...     "S17", x=1050.0, z_centers=z, rho_log10=col, db=db
... )

Classes

Layer(top, bottom, rho_log10, lithology[, ...])

One geological unit in a pseudo-stratigraphic log.

RockDatabase(entries, *[, metadata])

Extensible rock physics database for EM resistivity interpretation.

RockEntry(name, rho_min, rho_max[, color, ...])

A single entry in the rock physics database.

StratigraphicLog(station_name, station_x, ...)

Per-station pseudo-stratigraphic depth profile.

class pycsamt.geology.lithology.RockEntry(name, rho_min, rho_max, color='#AAAAAA', description='', code=0, source='')[source]

Bases: PyCSAMTObject

A single entry in the rock physics database.

Parameters:
  • name (str) – Geological unit / lithology name.

  • rho_min (float) – Resistivity range in Ω·m (linear scale).

  • rho_max (float) – Resistivity range in Ω·m (linear scale).

  • color (str) – Hex colour code for plotting (e.g. '#28B463').

  • description (str) – Optional free-text note.

  • code (int) – Integer code used in LAS exports.

  • source (str) – Optional literature citation for this range (e.g. 'Palacky (1988)'). Empty when unspecified, as for entries loaded from a CSV without a source column.

name: str
rho_min: float
rho_max: float
color: str = '#AAAAAA'
description: str = ''
code: int = 0
source: str = ''
property rho_mid: float[source]
property log_rho_mid: float[source]
contains(rho_ohm_m)[source]
Parameters:

rho_ohm_m (float)

Return type:

bool

class pycsamt.geology.lithology.RockDatabase(entries, *, metadata=None)[source]

Bases: PyCSAMTObject, MetadataMixin

Extensible rock physics database for EM resistivity interpretation.

Parameters:
  • entries (list of RockEntry) – The database entries. default() returns the built-in set.

  • metadata (dict)

Example

>>> db = RockDatabase.default()
>>> db.classify(180.0).name
'Granite (weathered)'
metadata: dict
property entries: tuple[RockEntry, ...][source]

Read-only view of the database entries, in insertion order.

classmethod default()[source]

Return a database pre-loaded with the built-in rock entries.

Entries come from pycsamt.geology.rock_library.BUILTIN_ROCKS; see that module for the literature the ranges are drawn from.

Return type:

RockDatabase

classmethod from_csv(path)[source]

Load from a CSV file.

Required columns: name, rho_min, rho_max Optional columns: color, description, code, source

Parameters:

path (str | Path)

Return type:

RockDatabase

classmethod from_provider(provider)[source]

Build a database from any RockPropertyProvider.

This is the generic entry point behind from_url(); call it directly when provider is something other than a plain URL fetch, such as a provider pre-configured with authentication or a provider composing several sources.

Parameters:

provider (RockPropertyProvider)

Return type:

RockDatabase

classmethod from_url(url, *, cache_dir=None, ttl_seconds=86400.0, timeout=10.0, force=False, fallback=True)[source]

Fetch a database from url, with local caching and fallback.

url must serve a JSON array of objects using the same fields as RockEntry (name, rho_min, rho_max, and optionally color, description, code, source). No public rock-resistivity service is bundled or assumed by default – point this at a project- or organisation-controlled endpoint (an internal API, a shared JSON file on a file server, and so on).

Parameters:
  • url (str) – Location to fetch the JSON entry list from.

  • cache_dir (path-like, optional) – Override the local cache location. Defaults to $PYCSAMT_ROCKDB_CACHE or ~/.pycsamt/rock_db.

  • ttl_seconds (float) – Reuse a cached response younger than this many seconds instead of re-fetching. Default one day.

  • timeout (float) – Network timeout in seconds for the fetch itself.

  • force (bool) – Re-fetch even if a fresh cache entry exists.

  • fallback (bool) – If the fetch fails (network, timeout, malformed response) and no usable cache entry exists, fall back to default() instead of raising. Set to False to surface the failure instead.

Return type:

RockDatabase

See also

pycsamt.geology.rock_providers.RemoteRockPropertyProvider

The provider implementing the fetch/cache/fallback policy used here.

classify(rho_ohm_m, method='nearest')[source]

Return the best-matching rock entry for rho_ohm_m.

Parameters:
  • rho_ohm_m (float) – Resistivity in Ω·m (linear).

  • method ({'nearest', 'overlap'}) – 'nearest': log-distance to midpoint. 'overlap': first entry whose range brackets rho_ohm_m.

Return type:

RockEntry

classify_column(rho_log10)[source]

Classify every cell in a log10-rho depth column.

Parameters:

rho_log10 (ndarray)

Return type:

list[RockEntry]

class pycsamt.geology.lithology.Layer(top, bottom, rho_log10, lithology, color='#AAAAAA', confidence=1.0)[source]

Bases: PyCSAMTObject

One geological unit in a pseudo-stratigraphic log.

Parameters:
  • top (float) – Depth in metres (positive downward).

  • bottom (float) – Depth in metres (positive downward).

  • rho_log10 (float) – Representative \(\log_{10}(\rho)\) of the layer.

  • lithology (str) – Rock name from RockDatabase.

  • color (str) – Hex colour for plotting.

  • confidence (float) – Fraction of depth cells whose DB classification matches the reported lithology (0 – 1).

top: float
bottom: float
rho_log10: float
lithology: str
color: str = '#AAAAAA'
confidence: float = 1.0
property thickness: float[source]
property rho_ohm_m: float[source]
class pycsamt.geology.lithology.StratigraphicLog(station_name, station_x, z_centers, rho_log10, layers)[source]

Bases: PyCSAMTObject

Per-station pseudo-stratigraphic depth profile.

Constructed from a 1-D log10-rho column and a RockDatabase, it merges adjacent cells that share the same lithology into discrete Layer objects.

Parameters:
  • station_name (str)

  • station_x (float)

  • z_centers (ndarray (n_z,)) – Depth cell centres, metres.

  • rho_log10 (ndarray (n_z,)) – \(\log_{10}(\rho)\) for each depth cell.

  • layers (list of Layer) – Merged geological units (assembled by from_column()).

classmethod from_column(station_name, x, z_centers, rho_log10, db=None, *, merge_tolerance=0.2)[source]

Build a log from a 1-D resistivity column.

Parameters:
  • station_name (str)

  • x (float) – Station position, metres.

  • z_centers (ndarray (n_z,))

  • rho_log10 (ndarray (n_z,))

  • db (RockDatabase, optional) – Defaults to RockDatabase.default().

  • merge_tolerance (float) – Log10-rho difference threshold for merging adjacent cells into one layer (default 0.2 decade).

Return type:

StratigraphicLog

to_dataframe()[source]

Return layers as a pandas.DataFrame.

to_dict()[source]

Return a shallow dictionary representation.

Return type:

dict