This notebooks looks at the main striplog object. For the basic objects it depends on, see Basic objects.
First, import anything we might need.
In [1]:
%matplotlib inline
import striplog
striplog.__version__
Out[1]:
In [2]:
from striplog import Legend, Lexicon, Interval, Component
In [3]:
legend = Legend.default()
lexicon = Lexicon.default()
In [4]:
from striplog import Striplog
print(Striplog.__doc__)
Here is one of the images we will convert into striplogs:
In [5]:
imgfile = "M-MG-70_14.3_135.9.png"
In [6]:
striplog = Striplog.from_img(imgfile, 14.3, 135.9, legend=legend)
striplog
Out[6]:
In [7]:
striplog.thinnest(n=7)
Out[7]:
In [8]:
striplog.thickest(n=5).plot(legend=legend)
This striplog doesn't have any gaps...
In [9]:
if striplog.find_gaps():
print('Gaps')
else:
print("No gaps!")
But we can make some by deleting indices:
In [10]:
del striplog[[2, 7, 20]]
striplog.find_gaps()
Out[10]:
We can also get a list of the indices of intervals that are followed by gaps (i.e. are directly above gaps in 'depth' order, or directly below gaps in 'elevation' order).
In [11]:
striplog.find_gaps(index=True)
Out[11]:
In [12]:
striplog.thinnest(1)
Out[12]:
In [13]:
striplog.prune(limit=1)
print(len(striplog))
striplog.plot(legend=legend)
In [14]:
striplog.anneal()
striplog.plot(legend=legend)
In [15]:
striplog.find_gaps()
There are several ways to inspect a striplog:
print prints the contents of the striplogtop shows us a list of the primary lithologies in the striplog, in order of cumulative thicknessplot makes a plot of the striplog with coloured bars
In [16]:
print(striplog[:5])
In [17]:
striplog.top
Out[17]:
It's easy enough to visualize this. Perhaps this should be a method...
In [18]:
depth = 0
list_of_int = []
for i in striplog.top:
list_of_int.append(Interval(depth, depth+i[1], components=[i[0]]))
depth += i[1]
t = Striplog(list_of_int)
t.plot(legend)
If you call plot() on a Striplog you'll get random colours (one per rock type in the striplog), and preset aspect ratio of 10.
In [19]:
striplog.plot()
For more control, you can pass some parameters. You'll probably always want to pass a legend.
In [69]:
striplog.plot(legend, ladder=True, aspect=5, interval=5)
Again, the object is indexable and iterable.
In [21]:
print(striplog[:3])
In [22]:
print(striplog[-1].primary.summary())
In [23]:
for i in striplog[:5]:
print(i.summary())
In [24]:
len(striplog)
Out[24]:
In [25]:
import numpy as np
np.array([d.top for d in striplog[5:13]])
Out[25]:
You can even index into it with an iterable, like a list of indices.
In [26]:
indices = [2,4,6]
print(striplog[indices])
This results in a new Striplog, contianing only the intervals requested.
In [27]:
striplog.find('sandstone')
Out[27]:
In [28]:
striplog.find('sandstone').top
Out[28]:
In [29]:
striplog.find('sandstone').cum
Out[29]:
In [30]:
print(striplog.find('sandstone'))
In [31]:
striplog.find('sandstone').plot()
Let's ask for the rock we just found by seaching.
In [32]:
rock = striplog.find('sandstone')[1].components[0]
rock
Out[32]:
We can also search for a rock...
In [33]:
striplog.find(rock).plot(legend)
In [34]:
rock in striplog
Out[34]:
And we can ask what is at a particular depth.
In [36]:
striplog.depth(90).primary
Out[36]:
In [37]:
for r in reversed(striplog[:5]):
print(r)
Slicing returns a new striplog:
In [38]:
striplog[1:3]
Out[38]:
In [39]:
rock2 = Component({'lithology':'shale', 'colour':'grey'})
iv = Interval(top=300, base=350, description='', components=[rock, rock2])
In [40]:
striplog[-3:-1] + Striplog([iv])
Out[40]:
In [41]:
print(striplog.to_las3())
In [42]:
striplog.source
Out[42]:
In [43]:
csv_string = """ 200.000, 230.329, Anhydrite
230.329, 233.269, Grey vf-f sandstone
233.269, 234.700, Anhydrite
234.700, 236.596, Dolomite
236.596, 237.911, Red siltstone
237.911, 238.723, Anhydrite
238.723, 239.807, Grey vf-f sandstone
239.807, 240.774, Red siltstone
240.774, 241.122, Dolomite
241.122, 241.702, Grey siltstone
241.702, 243.095, Dolomite
243.095, 246.654, Grey vf-f sandstone
246.654, 247.234, Dolomite
247.234, 255.435, Grey vf-f sandstone
255.435, 258.723, Grey siltstone
258.723, 259.729, Dolomite
259.729, 260.967, Grey siltstone
260.967, 261.354, Dolomite
261.354, 267.041, Grey siltstone
267.041, 267.350, Dolomite
267.350, 274.004, Grey siltstone
274.004, 274.313, Dolomite
274.313, 294.816, Grey siltstone
294.816, 295.397, Dolomite
295.397, 296.286, Limestone
296.286, 300.000, Volcanic
"""
In [44]:
strip2 = Striplog.from_csv(csv_string, lexicon=lexicon)
Notice the warning about a missing term in the lexicon.
In [45]:
Component.from_text('Volcanic', lexicon)
Out[45]:
In [46]:
Component.from_text('Grey vf-f sandstone', lexicon)
Out[46]:
In [47]:
las3 = """~Lithology_Parameter
LITH . : Lithology source {S}
LITHD. MD : Lithology depth reference {S}
~Lithology_Definition
LITHT.M : Lithology top depth {F}
LITHB.M : Lithology base depth {F}
LITHN. : Lithology name {S}
~Lithology_Data | Lithology_Definition
200.000, 230.329, Anhydrite
230.329, 233.269, Grey vf-f sandstone
233.269, 234.700, Anhydrite
234.700, 236.596, Dolomite
236.596, 237.911, Red siltstone
237.911, 238.723, Anhydrite
238.723, 239.807, Grey vf-f sandstone
239.807, 240.774, Red siltstone
240.774, 241.122, Dolomite
241.122, 241.702, Grey siltstone
241.702, 243.095, Dolomite
243.095, 246.654, Grey vf-f sandstone
246.654, 247.234, Dolomite
247.234, 255.435, Grey vf-f sandstone
255.435, 258.723, Grey siltstone
258.723, 259.729, Dolomite
259.729, 260.967, Grey siltstone
260.967, 261.354, Dolomite
261.354, 267.041, Grey siltstone
267.041, 267.350, Dolomite
267.350, 274.004, Grey siltstone
274.004, 274.313, Dolomite
274.313, 294.816, Grey siltstone
294.816, 295.397, Dolomite
295.397, 296.286, Limestone
296.286, 300.000, Volcanic
"""
In [48]:
strip3 = Striplog.from_las3(las3, lexicon)
strip3
Out[48]:
In [49]:
strip3.top
Out[49]:
I recommend treating tops as intervals, not as point data.
In [50]:
tops_csv = """100, Escanilla Fm.
200, Sobrarbe Fm.
350, San Vicente Fm.
500, Cretaceous
"""
In [51]:
tops = Striplog.from_csv(tops_csv)
In [52]:
print(tops)
In [53]:
tops.depth(254.0)
Out[53]:
Some things really are point data.
In [54]:
data_csv = """1200, 6.4
1205, 7.3
1210, 8.2
1250, 9.2
1275, 4.3
1300, 2.2
"""
In [55]:
data = Striplog.from_csv(data_csv, points=True)
In [56]:
print(data)
One day, when we have a use case, we can do something nice with this, like treat it as numerical data, and make a plot for it. We need an elegant way to get that number into a 'rock', like {'x': 6.4}, etc.
In [21]:
import numpy as np
from matplotlib import pyplot as plt
import seaborn; seaborn.set()
In [22]:
fmt = '{colour}\n{lithology}\n{grainsize}'
labels = [c.summary(fmt=fmt) for c in comps]
colours = [legend.get_colour(c) for c in comps]
fig, ax = plt.subplots()
ind = np.arange(len(comps))
bars = ax.bar(ind, counts, align='center')
ax.set_xticks(ind)
ax.set_xticklabels(labels)
for b, c in zip(bars, colours):
b.set_color(c)
plt.show()
©2015 Agile Geoscience. Licensed CC-BY. striplog.py