litholog package

Subpackages

Submodules

litholog.bed module

class litholog.bed.Bed(top, base, data, keys=None, **kwargs)[source]

Bases: striplog.interval.Interval

Represents an individual bed or layer.

Essentially a striplog.Interval with some additional restrictions and logic.

Beds are required to have a top, base, and data (which can be an array or dict-like).

as_patch(legend, width_field=None, depth_field=None, min_width=0.0, max_width=1.5, **kwargs)[source]

Representation of the Bed as a matplotlib.patches object [Polygon or Rectangle].

Parameters
  • legend (striplog.Legend) – Legend to get a matching striplog.Decor from.

  • width_field (str or int, optional) – data key or values column index to use as width field.

  • depth_field (str or int, optional) – Data key or values column index to use as positions of width_field samples. If not provided and width_field values are iterable, created from np.linspace(top, base). Ignored if width_field is a scalar. Sizes must match if both fields return iterables.

Returns

patch

Return type

instance from matplotlib.patches

compatible_with(other)[source]

Check that self.data and other.data have compatible values shapes and matching data key order.

NOTE: Should both have to be constructed from similar dtypes, or just have concatable values?

get_values(exclude_keys=[])[source]

Getter for values that allows dropping exclude_keys (e.g., sample depths) from array

property lithology

Just shorthand.

max_field(key)[source]

Return the maximum value of data[key], or None if it doesn’t exist.

min_field(key)[source]

Return the minimum value of data[key], or None if it doesn’t exist.

property nfeatures

The number of columns in values.

property nsamples

The number of sample rows in values.

resample_data(depth_key, step, kind='linear')[source]

Resample data to approximately step, but preserving at least top/base samples.

Parameters
  • depth_key (str, int, or None) – Dict key or column index pointing to sample depths

  • step (float) – Depth step at which to (approximately) resample data values

  • kind (one of {‘linear’,’slinear’,’quadratic’,’cubic’,…}, optional) – Kind of interpolation to use, default=’linear’. See scipy.intepolate.interp1d docs.

spans(d, eps=0.001)[source]

Determines if position d is within this Bed. Overridden from striplog.Interval to accomodate small tolerance eps

Parameters

d (float) – Position (depth or elevation) to evaluate.

Returns

in_bed – True if d is within the Bed, False otherwise.

Return type

bool

property values

litholog.defaults module

Define default striplog.Decor`s when using grainsize as the width field. Also specify default csv/DataFrame fields to map to `Bed attributes/data.

litholog.defaults.gs2litho(gs, units='psi')[source]

Map grainsize value gs to striplog.Component.

If gs is None or np.nan, maps to ‘missing’ Component.

If units is ‘mm’ or ‘phi’, will convert to ‘psi’ first.

Psi is log2(gs_mm), so medium sand is -1 to -2. See more at https://en.wikipedia.org/wiki/Grain_size#/media/File:Wentworth_scale.png

litholog.utils module

Utility functions.

litholog.utils.safelen(x)[source]

Return the length of an array or iterable, or 1 for literals.

litholog.utils.saferep(x, n)[source]

Repeat x to array of length n if it’s a literal, or check that len(x) == n if it’s iterable.

litholog.utils.string2array_matlab(s)[source]

Parse matlab-style array string (e.g., “1.0, 2.0, 3.0”) to float array.

litholog.utils.string2array_pandas(s)[source]

Parse pandas-style array string (e.g, “[1.0 2.0 3.0]”) to float array.

litholog.utils.strings2array(elems)[source]

Convert iterable of numeric strings to (float) array.

litholog.wentworth module

Utility functions for Wentworth/Krumbein logarithmic grainsize scale.

See this link for a nice chart:

https://en.wikipedia.org/wiki/Grain_size#/media/File:Wentworth_scale.png

litholog.wentworth.gs2name(gs)[source]
litholog.wentworth.gs2phi(gs)[source]
litholog.wentworth.gs2psi(gs)[source]
litholog.wentworth.phi2gs(phi)[source]
litholog.wentworth.phi2name(phi)[source]
litholog.wentworth.phi2psi(phi)[source]
litholog.wentworth.psi2gs(psi)[source]
litholog.wentworth.psi2name(psi, scale=[('colloid', - 10), ('clay', - 8), ('vf_silt', - 7), ('f_silt', - 6), ('m_silt', - 5), ('c_silt', - 4), ('vf_sand', - 3), ('f_sand', - 2), ('m_sand', - 1), ('c_sand', 0), ('vc_sand', 1), ('vf_gravel', 2), ('f_gravel', 3), ('m_gravel', 4), ('c_gravel', 5), ('vc_gravel', 6), ('cobble', 8), ('boulder', None)])[source]

Map single psi value to Wentworth bin name.

litholog.wentworth.psi2phi(psi)[source]

Module contents