agilescientific / striplog

Lithology and stratigraphic logs for wells or outcrop.
https://code.agilescientific.com/striplog
Apache License 2.0
204 stars 69 forks source link

Macrostrat columns #116

Closed mtb-za closed 4 years ago

mtb-za commented 4 years ago

…columns for a given location.

This adds a from_macrostrat method to striplog.striplog. It expects a lng lat point, and will then use the MacroStrat API to get nearby geological units and construct a column based on the ages of the rocks within a buffer zone of the point (by default 0.2 degrees, but easily changed through a parameter). The column is returned as a striplog.Striplog.

While in striplog.py, this is not part of the Striplog class.

It is possible that I should just refactor this so that it does work as part of the class, but there are a handful of additional functions that handle part of the data munging. These could be pulled into the main function which could be moved into the class proper, if so desired. They have relatively little utility outside this specific application.

Example of usage:

import striplog.striplog 
import matplotlib.pyplot as plt

lng = -64.3573186
lat = 44.4454632
buffer_size = 0.3
the_strip = striplog.striplog.from_macrostrat(lng, lat, buffer_size)

fig = plt.figure(figsize=(4,8))
ax = fig.add_axes((0.2, 0.1, 0.3, 0.8))
the_strip[0].plot(the_strip[1], aspect=5, match_only=['lith', 'age'], label='age', ax=ax)
plt.show()

The plotting call should perhaps be overloaded to hide some complexity?

Resolves #109, but in a more roundabout way, since getting data at a point does not give a column, it returns values from all the data sources at the point.

coveralls commented 4 years ago

Coverage Status

Coverage decreased (-0.8%) to 76.204% when pulling b2bd0554ca6dec83b97f6fadc96a031724d70d16 on mtb-za:macrostrat_columns into 02ae02ec4ec7c31990faa06e5156924a9b87254f on agile-geoscience:master.

kwinkunks commented 4 years ago

Thank you Martin! I will add the function into the class I think, and move the service functions into utils, or something like that.