litholog.sequence package
Submodules
litholog.sequence.io module
IO classes & functions
- class litholog.sequence.io.SequenceIOMixin[source]
Bases:
abc.ABCDefines the IO interface for BedSequence.
- classmethod from_dataframe(df, topcol='tops', basecol=None, thickcol=None, component_map=None, datacols=[], metacols=[], metasafe=True, tol=0.001)[source]
Create an instance from a pd.DataFrame or subclass (e.g., a GroupBy object). Must provide topcol and one of basecol or thickcol.
- Parameters
df (pd.DataFrame or subclass) – Table from which to create list_of_Beds.
topcol (str) – Name of top depth/elevation column. Must be present. Default=’top’.
basecol, thickcol (str) – Either provide a base depth/elevation column, or a thickness column. Must provide at least one.
component_map (tuple(str, func), optional) – Function that maps values of a column to a primary striplog.Component for individual Beds. TODO: if func is a str with ‘wentworth’, maybe just map using grainsize bins?
datacols (list(str), optional) – Columns to use as Bed data. Should reference numeric columns only.
metacols (list(str), optional) – Columns to read into metadata dict attribute.
metasafe (bool, optional) – If True, enforces that df[metacols] have a single unique value per column. If False, just attaches any + all unique values.
- litholog.sequence.io.check_order(df, topcol, basecol, raise_error=True)[source]
Check that all rows are either depth ordered or elevation_ordered. Returns ‘elevation’ or ‘depth’.
- litholog.sequence.io.check_samples(df, depthcol, valuecol)[source]
Check that depth_col and sample_col have equal number of entries per bed,
- Returns
good – True if sizes match in all rows, False otherwise.
- Return type
bool
- litholog.sequence.io.check_thicknesses(df, topcol, thickcol, order, basecol='bases', tol=0.001)[source]
Check that gap between tops and adjacent bases implied by ‘th’ are consistent and small.
- Returns
(df, good) – df has new basecol added with implied base positions good is True if the average gap < tol, else False
- Return type
(DataFrame, bool)
litholog.sequence.sequence module
- Notes:
Just need top depths/elevations.
- class litholog.sequence.sequence.BedSequence(list_of_Beds, metadata={})[source]
Bases:
litholog.sequence.io.SequenceIOMixin,litholog.sequence.viz.SequenceVizMixin,litholog.sequence.stats.SequenceStatsMixin,striplog.striplog.StriplogOrdered collection of
Bedinstances.- flip_convention(depth_key=None)[source]
Changes the depth convention (elevation <-> depth), setting to base or top to 0.0, respectively.
If depth_key is given, that data column in each bed should be shifted the same amount.
- get_field(field, lithology=None, default_value=0.0)[source]
Get ‘vertical’ array of
fieldvalues.If lithology provided, will only use the beds matching that lithology (in primary component).
- get_values(exclude_keys=[])[source]
Getter for
valuesthat allows droppingexclude_keys(e.g., sample depths) from array
- property nfeatures
The number of columns in
values.
- property nsamples
The number of sample rows in
values. NOTE:len(striplog.Striplog)will already give number of beds.
- reduce_fields(field_fn_dict)[source]
Return array, result of applying fn values to field keys.
The funcs can return scalars or arrays, but all of the return values should be numpy-concatable. The concatenation
- resample_data(depth_key, step, kind='linear')[source]
Resample the data at approximate depth intervals of size step. depth_key can be a str (for dict-like bed data) or column index (for array bed data).
I think we probably want to maintain top/base samples, and sample to the nearest step b/t. Maybe this could be the default of multiple options? Implement it as the default first though.
NOTE: We could return a new instance rather than modify inplace, since it’s hard to undo.
- shift(delta=None, start=None, depth_key=None)[source]
Shift all the intervals by delta (negative numbers are ‘up’), or by setting a new start depth. Returns a new copy of the BedSequence.
- property values
Get the instance as a 2D array w/ shape (
nsamples,nfeatures).
litholog.sequence.stats module
Sequence stats + related.
- class litholog.sequence.stats.SequenceStatsMixin[source]
Bases:
abc.ABCDefines the plot/viz interface for BedSequence.
- property amalgamation_ratio
dont count mud on mud contacts
find sand on sand contacts
divide sand-on-sand contacts by total number of contacts
NOTE: ‘gravel’ counts as a ‘sand’
- hurst_D(field, lithology, take_log=True, safe=True, nsamples=1000, return_K=True)[source]
Returns (D, p, K) if
return_K, else (D, p) where:D : Bootstrapped Hurst value from
nsamplesresamples p : p-value ofDK : Hurst K value with original values
- hurst_K(field, lithology, safe=True)[source]
Hurst K value for data from a sequence
field.If
safe, will only accept fields with at least 20 values.
- property interfaces
Get all pairs of adjacent Beds, ignoring any pairs with either Bed ‘missing’
- property net_to_gross
Returns (total thickness of ‘sand’ & ‘gravel’ Beds) / (total thickness of all Beds)
- pseudo_gamma_simple(gs_field='grain_size_mm', depth_field='depth_m', resolution=0.2, gs_cutoff=0.0625, gamma_range=(30, 180), sigma=0.1, noise=10.0)[source]
Compute a ‘pseudo’ gamma ray log by thresholding gs_field + Gaussian convolution.
- Parameters
gs_field (str) – Which field to use for grainsize
depth_field (str) – Which field to use for depth
resolution (float) – Scale at which to resample (in depth_field units)
gs_cutoff (float) – Cutoff for gs_field thresholding. Values above/below get mapped to gamma_range.
gamma_range (tuple or list) – (low, high) sample values for gs_field values (above, below) gs_cuttoff.
sigma (float) – Width of Gaussian, in depth units.
noise (float or None) – Magnitude of uniform noise to add, or None to add no noise.
litholog.sequence.viz module
Visualization funcs and the SequenceVizMixin interface for BedSequence.
- class litholog.sequence.viz.SequenceVizMixin[source]
Bases:
abc.ABCDefines the plot/viz interface for
BedSequence.- plot(legend=None, fig_width=1.5, aspect=10, width_field=None, depth_field=None, wentworth='fine', exxon_style=False, yticks_right=False, set_ylim=True, xlim=None, ax=None, **kwargs)[source]
Plot as a
Striplogof ``Bed``s.- Parameters
legend (striplog.Legend, optional) – If beds have primary component with ‘lithology’ field, will use
defaults.litholegend, otherwise random.fig_width (int, optional) – Width of figure, if creating one.
aspect (int, optional) – Aspect ratio of figure, if creating one.
width_field (str or int) – The
Bed.data`field orBed.valuescolumn used to define polyon widths.depth_field – The
Bed.datafield orBed.valuescolumn defining depths ofwidth_fieldsampleswentworth (one of {‘fine’, ‘coarse’}) – Which Wentworth scale to use for xlabels/ticks.
exxon_style (bool, optional) – Set to true to invert the x-axis (so GS increases to the left).
yticks_right (bool, optional) – If True, will move yticks/labels to right side. Defualt=False.
set_ylim (bool, optional) – Whether to set the y-limits of the ax to [self.start, self.stop]. Default=True.
**kwargs (optional) – ylabelsize, yticksize, xlabelsize, xlabelrotation
- litholog.sequence.viz.make_pair_figure()[source]
Generate a figure with two column axes and no space horizontal between them.
- litholog.sequence.viz.set_wentworth_ticks(ax, min_psi, max_psi, wentworth='fine', **kwargs)[source]
Set the xticks of ax for Wentworth grainsizes.
- Parameters
ax (matplotlib.Axes) – Axes to modify.
min_psi, max_psi (float) – Define the xlim for the axis.
wentworth (one of {‘fine’, ‘medium’, ‘coarse’}) – Which scale to use. Default=’fine’.
**kwargs