striplog.component module#

Defines components for holding properties of rocks or samples or whatevers.

copyright

2015 Agile Geoscience

license

Apache 2.0

class striplog.component.Component(properties=None)#

Bases: object

Initialize with a dictionary of properties. You can use any properties you want e.g.:

  • lithology: a simple one-word rock type

  • colour, e.g. ‘grey’

  • grainsize or range, e.g. ‘vf-f’

  • modifier, e.g. ‘rippled’

  • quantity, e.g. ‘35%’, or ‘stringers’

  • description, e.g. from cuttings

classmethod from_macrostrat(feature, columns=None)#

Make a Component from a Macrostrat feature dictionary.

classmethod from_text(text, lexicon=None, required=None, first_only=True)#

Generate a Component from a text string, using a Lexicon.

Parameters
  • text (str) – The text string to parse.

  • lexicon (Lexicon) – The dictionary to use for the categories and lexemes.

  • required (str) – An attribute that we must have. If a required attribute is missing from the component, then None is returned.

  • first_only (bool) – Whether to only take the first match of a lexeme against the text string.

Returns

A Component object, or None if there was no

must-have field.

Return type

Component

json()#

Returns a JSON dump of the dictionary representation of the instance.

keys()#

Needed for double-star behaviour, along with __getitem__().

summary(fmt=None, initial=True, default='')#

Given a format string, return a summary description of a component.

Parameters
  • component (dict) – A component dictionary.

  • fmt (str) – Describes the format with a string. If no format is given, you will just get a list of attributes. If you give the empty string (‘’), you’ll get default back. By default this gives you the empty string, effectively suppressing the summary.

  • initial (bool) – Whether to capitialize the first letter. Default is True.

  • default (str) – What to give if there’s no component defined.

Returns

A summary string.

Return type

str

Example

r = Component({‘colour’: ‘Red’,

‘grainsize’: ‘VF-F’, ‘lithology’: ‘Sandstone’})

r.summary() –> ‘Red, vf-f, sandstone’

exception striplog.component.ComponentError#

Bases: Exception

Generic error class.