In [1]:
from striplog import Decor
A Decor attaches a display style to a Rock.
In [2]:
print(Decor.__doc__)
We are going to need a Component to make a Decor.
In [3]:
from striplog import Component
r = {'colour': 'grey',
'grainsize': 'vf-f',
'lithology': 'sand'}
rock = Component(r)
rock
Out[3]:
Like Rocks, we instantiate Decors with a dict of properties:
In [4]:
d = {'color': '#86F0B6',
'component': rock,
'width': 3}
decor = Decor(d)
decor
Out[4]:
You can access its attributes. It has two ways to understand colour:
In [5]:
decor.colour
Out[5]:
In [6]:
decor.rgb
Out[6]:
In [7]:
%matplotlib inline
decor.plot()
In [8]:
from striplog import Legend
print(Legend.__doc__)
We'll define a legend in a CSV file. I can't think of a better way for now. It would be easy to make a web form to facilitate this with, for example, a colour picker. It may not be worth it, though; I imagine one would create one and then leave it alone most of the time.
In [9]:
l = u"""colour, width, component lithology, component colour, component grainsize
#F7E9A6, 3, Sandstone, Grey, VF-F
#FF99CC, 2, Anhydrite, ,
#DBD6BC, 3, Heterolithic, Grey,
#FF4C4A, 2, Volcanic, ,
#86F0B6, 5, Conglomerate, ,
#FF96F6, 2, Halite, ,
#F2FF42, 4, Sandstone, Grey, F-M
#DBC9BC, 3, Heterolithic, Red,
#A68374, 2, Siltstone, Grey,
#A657FA, 3, Dolomite, ,
#FFD073, 4, Sandstone, Red, C-M
#A6D1FF, 3, Limestone, ,
#FFDBBA, 3, Sandstone, Red, VF-F
#FFE040, 4, Sandstone, Grey, C-M
#A1655A, 2, Siltstone, Red,
#363434, 1, Coal, ,
#664A4A, 1, Mudstone, Red,
#666666, 1, Mudstone, Grey, """
In [10]:
legend = Legend.from_csv(l)
legend[:5]
Out[10]:
In [11]:
legend = Legend.default()
print(legend.to_csv())
In fact, this is the default legend.
In [12]:
Legend.default()
Out[12]:
We can ask the Legend what colour to use for a given Rock object:
In [13]:
legend.get_colour(rock)
Out[13]:
In [14]:
rock3 = Component({'colour': 'red',
'grainsize': 'vf-f',
'lithology': 'sandstone'})
legend.get_colour(rock3)
Out[14]:
Sometimes we also want to use a width for a given lithology:
In [15]:
legend.get_width(rock3)
Out[15]:
We can also ask the legend which Rock is represented by a particular colour. (I doubt you'd ever really need to do this, but I had to implement this to allow you to make a Striplog from an image: it looks up the rocks to use by colour.)
In [16]:
legend.get_component('#f7e9a6')
Out[16]:
The Legend behaves more or less like a list, so we can index into it:
In [17]:
legend[3:5]
Out[17]:
Legends can plot themselves.
In [18]:
legend.plot()
Sometimes you don't want to have to make a legend, so you can use a random one. Just pass a list of Components...
In [20]:
# We'll scrape a quick list of 7 components from the default legend:
c = [d.component for d in legend[:7]]
l = Legend.random(c)
l.plot()
©2015 Agile Geoscience. Licensed CC-BY. striplog.py