Welcome to APSG’s documentation!
APSG defines several new python classes to easily manage, analyze and visualize orientational structural geology data. It is under active developement, so until documenation will be finished, you can go trough tutorial to see what APSG can do for you.
Usage
To use APSG in a project:
import apsg
To use APSG interactively it is easier to import into current namespace:
from apsg import *
Changes in classnames and API
Note
APSG has been significantly refactored from version 1.0 and several changes are breaking backward compatibility. The main APSG namespace provides often-used classes in lowercase names as aliases to PascalCase convention used in modules to provide a simplified interface for users. The PascalCase names of classes use longer and plain English names instead acronyms for better readability.
If you already used older versions of APSG, check following table for new names and aliases of most commonly used classes.
alias |
class name |
Description |
---|---|---|
vec2 |
Vector2 |
A class to represent a 2D vector |
vec |
Vector3 |
A class to represent a 3D vector |
lin |
Lineation |
A class to represent non-oriented (axial) linear feature |
fol |
Foliation |
A class to represent non-oriented planar feature |
pair |
Pair |
The class to store pair of planar and linear features |
fault |
Fault |
The class to store pair of planar and linear features together with sense of movement |
cone |
Cone |
The class to store cone with given axis, secant line and revolution angle in degrees |
vec2set |
Vector2Set |
Class to store set of |
vecset |
Vector3Set |
Class to store set of |
linset |
LineationSet |
Class to store set of |
folset |
FoliationSet |
Class to store set of |
pairset |
PairSet |
Class to store set of |
faultset |
FaultSet |
Class to store set of |
coneset |
ConeSet |
Class to store set of |
defgrad2 |
DeformationGradient2 |
The class to represent 2D deformation gradient tensor |
defgrad |
DeformationGradient3 |
The class to represent 3D deformation gradient tensor |
velgrad2 |
VelocityGradient2 |
The class to represent 2D velocity gradient tensor |
velgrad |
VelocityGradient3 |
The class to represent 3D velocity gradient tensor |
stress2 |
Stress2 |
The class to represent 2D stress tensor |
stress |
Stress3 |
The class to represent 3D stress tensor |
ellipse |
Ellipse |
The class to represent 2D ellipse |
ellipsoid |
Ellipsoid |
The class to represent 3D ellipsoid |
ortensor2 |
OrientationTensor2 |
Represents an 2D orientation tensor |
ortensor |
OrientationTensor3 |
Represents an 3D orientation tensor |
ellipseset |
EllipseSet |
Class to store set of |
ortensor2set |
OrientationTensor2Set |
Class to store set of |
ellipsoidset |
EllipsoidSet |
Class to store set of |
ortensorset |
OrientationTensor3Set |
Class to store set of |
Check tutorials and module API for more details.
Contents
Installation
Using pip
To install APSG from PyPI, just execute:
pip install apsg
To upgrade an existing version of APSG from PyPI, execute
pip install apsg –upgrade –no-deps
Please note that the dependencies (Matplotlib, NumPy and SciPy) will also be upgraded if you omit the --no-deps
flag;
use the --no-deps
(“no dependencies”) flag if you don’t want this.
Master version
The APSG version on PyPI may always one step behind; you can install the latest development version from the GitHub repository by executing:
pip install git+https://github.com/ondrolexa/apsg.git
Using Conda
The APSG package is also available through conda-forge
. To install APSG using conda, use the following command:
conda install apsg --channel conda-forge
or simply
conda install apsg
if you added conda-forge
to your channels (conda config --add channels conda-forge
).
Tutorials
APSG tutorial - Part 1
APSG defines several new python classes to easily manage, analyze and visualize orientation structural geology data. There are several classes to work with orientation data, namely Vector3
for vectorial data and Lineation
, Foliation
for axial data
Basic usage
APSG module could be imported either into own name space or into active one for easier interactive work.
[1]:
from apsg import *
Basic operations with vectors in 2D and 3D
Instance of vector object Vector3
could be created by passing 3 arguments correspondig to 3 components to function vec
:
[2]:
u = vec(1, -2, 3)
v = vec(-2, 1, 1)
Alternative ways to create vector is to pass single iterable object as list, tuple or array, or to provide geological orientation according to APSG notation (default is direction of dip and dip angle for planar and trend and plunge for linear features)
[3]:
coords = (-2, 2, 3)
a = vec(coords)
b = vec(120, 60)
print(a, b)
Vector3(-2, 2, 3) Vector3(-0.25, 0.433, 0.866)
The instance of 2D vector Vector2
could be created passing 2 arguments correspondig to 2 components or single iterable with components to function vec2
:
[4]:
k = vec2(1, 1)
coords = (-1, 2)
l = vec2(coords)
print(k, l)
Vector2(1, 1) Vector2(-1, 2)
Alternatively, single argument is interpreted as direction in degrees (0-top, 90-right, 180-down, 270-left)
[5]:
m = 5 * vec2(120)
m
[5]:
Vector2(-2.5, 4.33)
For common vector operation we can use standard mathematical operators or special methods using dot notation
[6]:
u + v
[6]:
Vector3(-1, -1, 4)
[7]:
u - v
[7]:
Vector3(3, -3, 2)
[8]:
3*u - 2*v
[8]:
Vector3(7, -8, 7)
Its magnitude or length is most commonly defined as its Euclidean norm and could be calculated using abs
[9]:
abs(v)
[9]:
2.449489742783178
[10]:
abs(u + v)
[10]:
4.242640687119285
For dot product we can use dot
method or operator @
[11]:
u.dot(v)
[11]:
-1
[12]:
u @ v
[12]:
-1.0
For cross product we can method cross
[13]:
u.cross(v)
[13]:
Vector3(-5, -7, -3)
To project vector u
onto vector v
we can use method proj
[14]:
u.proj(v)
[14]:
Vector3(0.333, -0.167, -0.167)
To find angle (in degrees) between to vectors we use method angle
[15]:
u.angle(v)
[15]:
96.26395271992722
Method rotate
provide possibility to rotate vector around another vector. For example, to rotate vector u
around vector v
for 45°
[16]:
u.rotate(v, 45)
[16]:
Vector3(2.248, 0.558, 2.939)
Classes Lineation and Foliation
To work with orientation data in structural geology, APSG provide two classes, Foliation
class to represent planar features and Lineation
class to represent linear features. Both classes support all Vector3
methods and operators, but it should be noted, that dot
and angle
respect their axial nature, i.e. angle between two lineations cant’t be bigger than 90 degrees.
To create instance of Lineation
or Foliation
, we can use functions lin
and fol
. Arguments have similar syntax to vec3
.
[17]:
lin(120, 60), fol(216, 62)
[17]:
(L:120/60, S:216/62)
We can also cast Vector3
instance to Foliation
or Lineation
[18]:
lin(u), fol(u)
[18]:
(L:297/53, S:117/37)
Vector methods for Lineation and Foliation
To find angle between two linear or planar features we can use method angle
[19]:
l1 = lin(110, 40)
l2 = lin(160, 30)
l1.angle(l2)
[19]:
41.59741268003547
[20]:
p1 = fol(330, 50)
p2 = fol(250, 40)
p1.angle(p2)
[20]:
54.69639932197533
We can use cross product to construct planar feature defined by two linear features
[21]:
l1.cross(l2)
[21]:
S:113/40
or to construct linear feature defined by intersection of two planar features
[22]:
p1.cross(p2)
[22]:
L:278/36
Cross product of planar and linear features could be used to construct plane defined by linear feature and normal of planar feature
[23]:
l2.cross(p2)
[23]:
S:96/53
or to find perpendicular linear feature on given plane
[24]:
p2.cross(l2)
[24]:
L:276/37
To rotate structural features we can use method rotate
[25]:
p2.rotate(l2, 45)
[25]:
S:269/78
Classes Pair and Fault
To work with paired orientation data like foliations and lineations or fault data in structural geology, APSG provide two base Pair
class and derived Fault
class. Both classes are instantiated providing dip direction and dip of planar and linear measurements, which are automatically orthogonalized. If misfit is too high, warning is raised. The Fault
class expects one more argument providing sense of movement information, either 1 or -1 for normal/reverse movement.
To create instance of Pair
, we have to pass two arguments for planar and two argumets for linear features following geological notation to function pair
:
[26]:
p = pair(120, 40, 162, 28)
p
[26]:
P:118/39-163/30
[27]:
p.misfit
[27]:
3.5623168411508175
Planar and linear features are accessible using fol
and lin
properties
[28]:
p.fol, p.lin
[28]:
(S:118/39, L:163/30)
To rotate Pair
instance we can use rotate
method
[29]:
p.rotate(lin(45, 10), 60)
[29]:
P:314/83-237/61
Instantiation of Fault
class is similar, we just have to provide argument to define sense of movement
[30]:
f = fault(120, 60, 110, 58, 1) # 1 for normal fault
f
[30]:
F:120/59-110/59 +
Note the change in sense of movement after Fault
rotation
[31]:
f.rotate(lin(45, 10), 60)
[31]:
F:312/62-340/59 -
For simple fault analyses Fault
class also provide p
, t
, m
and d
properties to get PT-axes, kinematic plane and dihedra separation plane
[32]:
f.p, f.t, f.m, f.d
[32]:
(L:315/75, L:116/14, S:27/85, S:290/31)
Class Cone
General feature type to store small or great circles as cone. It could be defined by axis
, secant
and revolving angle
or by axis
and apical angle
The revolving angle is by default 360° defining full cone. For segments of small circles, the revolving angle
could be different.
[33]:
c = cone(lin(140, 50), lin(140, 75))
c
[33]:
C:140/50 [25]
To create small circle segment, you can provide revolving angle
[34]:
c = cone(lin(90, 70), lin(45,30), 115)
The tips of small circle segments could be obtained from cone property secant
and rotated_secant
[35]:
lin(c.secant), lin(c.rotated_secant)
[35]:
(L:45/30, L:137/30)
To define cone using apical angle
, use axis
amd number arguments. Note, that revolving angle
is 360 by default
[36]:
c = cone(lin(140, 50), 25)
c
[36]:
C:140/50 [25]
[37]:
c.revangle
[37]:
360.0
Feature sets
APSG provide several classes to process, analyze and visualize the sets of data. There are e.g. vecset
, linset
and folset
classes to store group of vec
, lin
and fol
objects. All these feature sets are created from homogeneous list of data with optional name
atribute.
[38]:
v = vecset([vec(120,60), vec(116,50), vec(132,45), vec(90,60), vec(84,52)], name='Vectors')
v
[38]:
V3(5) Vectors
[39]:
l = linset([lin(120,60), lin(116,50), lin(132,45), lin(90,60), lin(84,52)], name='Lineations')
l
[39]:
L(5) Lineations
[40]:
f = folset([fol(120,60), fol(116,50), fol(132,45), fol(90,60), fol(84,52)], name='Foliations')
f
[40]:
S(5) Foliations
To simplify interactive group creation, you can use function G
[41]:
g = G([lin(120,60), lin(116,50), lin(132,45), lin(90,60), lin(84,52)], name='L1')
g
[41]:
L(5) L1
Method len
returns number of features in group
[42]:
len(v)
[42]:
5
Most of the vec
, lin
and fol
methods could be used for feature sets as well. For example, to measure angles between all features in group and another feature, we can use method angle
:
[43]:
l.angle(lin(110,50))
[43]:
array([11.49989817, 3.85569115, 15.61367789, 15.11039885, 16.3947936 ])
To rotate all features in group around another feature, we can use method rotate
[44]:
lr = l.rotate(lin(150, 30), 45)
To show data in list you can use data
property
[45]:
l.data
[45]:
(L:120/60, L:116/50, L:132/45, L:90/60, L:84/52)
[46]:
lr.data
[46]:
(L:107/35, L:113/26, L:126/30, L:93/26, L:94/18)
Function R
returns resultant of all features in set. Note that Lineation
and Foliation
are axial in nature, so resultant vector is not reliable. Check the orientation tensor anlysis below.
[47]:
v.R()
[47]:
Vector3(-0.941, 2.649, 3.993)
[48]:
lin(v.R())
[48]:
L:110/55
There is several methods to infer spherical statistics as spherical variance, Fisher’s statistics, confidence cones on data etc.
[49]:
l.var()
[49]:
0.02337168447438498
[50]:
v.fisher_statistics()
[50]:
{'k': 34.22945405911087, 'a95': 13.26402990511733, 'csd': 13.844747281750971}
[51]:
v.fisher_cone_a95()
[51]:
C:110/55 [13.264]
[52]:
v.fisher_cone_csd()
[52]:
C:110/55 [13.8447]
[53]:
v.delta()
[53]:
12.411724720740516
[54]:
v.rdegree()
[54]:
95.32566310512297
To calculate orientation tensor of all features in group, we can use ortensor
method.
[55]:
v.ortensor()
[55]:
OrientationTensor3
[[ 0.074 -0.096 -0.143]
[-0.096 0.284 0.421]
[-0.143 0.421 0.642]]
(S1:0.977, S2:0.201, S3:0.0758)
[ ]:
APSG tutorial - Part 2
[1]:
from apsg import *
Matrix like classes and tensors
APSG provides matrix-like classes to work with tensor quantities used commonly in structural geology analysis. It includes DefGrad3
and VelGrad3
for deformation and velocity gradient, Stress3
for stress tensor, Ellipsoid
for quadratic forms and Ortensor3
for orientation tensor. All these classes support common matrix mathematical operations and provide basic methods and properties.
All matrix-like objects could be created either by passing nested list or tuple or providing individual components to class method from_comp
[2]:
F = defgrad([[2, 0, 1], [0, 1, 0], [0, 0, 0.5]])
F
[2]:
DeformationGradient3
[[2. 0. 1. ]
[0. 1. 0. ]
[0. 0. 0.5]]
[3]:
F = defgrad.from_comp(xx=2, zz=0.5, xz=1)
F
[3]:
DeformationGradient3
[[2. 0. 1. ]
[0. 1. 0. ]
[0. 0. 0.5]]
For multiplifications of matrix or vectors we have to use matmul @
operator
[4]:
v = vec('z') # unit-length vector in direction af axis z
u = F @ v
u
[4]:
Vector3(1, 0, 0.5)
I
property returns inverse matrix
[5]:
F.I @ u
[5]:
Vector3(0, 0, 1)
To transpose matrix, we can use T
property and for multiplification we have to use @
operator
[6]:
F.T @ F
[6]:
DeformationGradient3
[[4. 0. 2. ]
[0. 1. 0. ]
[2. 0. 1.25]]
[7]:
v @ F.T @ F @ v
[7]:
1.25
Eigenvalues and eigenvectors could be obtained by methods eigenvalues
and eigenvectors
. Individual eigenvalues and eigen vectors could be accessed by properties E1
, E2
, E3
and V1
, V2
, V3
Deformation gradient and rotations
Deformation gradient DeformationGradient3
could describe distorsion, dilation and rigid-body rotation. All APSG features provides transform
method which transform then using provided deformation gradient.
The rigid-body rotation could be either extracted from deformation gradient using R
method:
[8]:
R = F.R
R
[8]:
DeformationGradient3
[[ 0.928 0. 0.371]
[ 0. 1. 0. ]
[-0.371 0. 0.928]]
or could be created of one of the class methods like from_axisangle
, defining axis of rotation and angle
[9]:
R = defgrad.from_axisangle(lin(120, 50), 60)
R
[9]:
DeformationGradient3
[[ 0.552 -0.753 0.359]
[ 0.574 0.655 0.492]
[-0.605 -0.065 0.793]]
from_two_vectors
, where axis of rotation is perpendicular to both vectors and angle is angle of vectors
[10]:
R = defgrad.from_two_vectors(lin(120, 50), lin(270, 80))
R
[10]:
DeformationGradient3
[[ 0.938 0.074 0.339]
[ 0.186 0.718 -0.671]
[-0.294 0.692 0.66 ]]
[11]:
lin(120, 50).transform(R)
[11]:
L:270/80
or by from_vectors_axis
, where axis
do not need to by perpendicular to vectors. Note that rotation axis needs to be adjusted to provide correct rotation of vector.
[12]:
R = defgrad.from_vectors_axis(lin(45,30), lin(135, 30), lin(90, 70))
R
[12]:
DeformationGradient3
[[-0.393 -0.864 0.315]
[ 0.864 -0.23 0.448]
[-0.315 0.448 0.837]]
[13]:
lin(45,30).transform(R)
[13]:
L:135/30
[14]:
a, ang = R.axisangle()
print(lin(a), ang)
L:90/70 113.1157146919613
from_two_pairs
method, to describe rotation between two coordinate systems. Note that pair define X axis as lineation vector and Z axis as foliation vector.
[15]:
p1 = pair(150, 60, 90, 40)
p2 = pair(45, 30, 10, 25)
R = defgrad.from_two_pairs(p1, p2)
R
[15]:
DeformationGradient3
[[-0.071 0.97 0.234]
[-0.874 -0.174 0.453]
[ 0.48 -0.173 0.86 ]]
[16]:
p1.transform(R)
[16]:
P:45/30-10/25
In deformation analysis, the quadratic forms are represented by Ellipsoid
class. It could be used to represents either ellipsoid objects or finite strain ellipsoid.
It provides additional methods and properties including lambda1
, lambda2
and lambda3
for square-root of eigenvalues, Woodcock’s shape
and strength
, k
, K
, d
and D
for Flinn’s and Ramsay symmetries and intensities, lode
for Lode’s parameter etc. For more check documentation. Eigenvectors could be also represented by linear or planar features using properties eigenlins
and eigenfols
.
We can create Ellipsoid
object similarly to Matrix3
(note that only components of upper triangular part are available in from_comp
method due to matrix symmetry), or you can use aditional class methods from_defgrad
and from_stretch
.
[17]:
B = ellipsoid.from_defgrad(F) # Finger deformation tensor
B
[17]:
Ellipsoid
[[5. 0. 0.5 ]
[0. 1. 0. ]
[0.5 0. 0.25]]
(S1:2.25, S2:1, S3:0.445)
In above example, the Finger deformation tensor B
represents finite strain ellipsoid reulting from deformation described by deformation gradient F
. We can explore several parameters:
[18]:
print(f'Principal stretches: Sx={B.S1}, Sy={B.S2}, Sz={B.S3}')
print(f'Principal strain ratios: Rxy={B.Rxy}, Ryz={B.Ryz}')
print(f"Flinn's finite strain parameters: d={B.d}, k={B.k}")
print(f"Ramsay's finite strain parameters: d={B.D}, k={B.K}")
print(f"Woodcock's parameters: strength={B.strength}, shape={B.shape}")
print(f"Watterson's strain intesity: s{B.r}")
print(f"Nadai's natural octahedral unit shear: {B.goct}")
print(f"Nadai's natural octahedral unit strain: {B.eoct}")
print(f"Lode's parameter: {B.lode}")
Principal stretches: Sx=2.2476790206496235, Sy=1.0, Sz=0.44490338291762865
Principal strain ratios: Rxy=2.2476790206496235, Ryz=2.2476790206496235
Flinn's finite strain parameters: d=1.7644845924910786, k=1.0
Ramsay's finite strain parameters: d=1.3118699860194973, k=1.0
Woodcock's parameters: strength=1.6197962748565002, shape=1.0
Watterson's strain intesity: s3.495358041299247
Nadai's natural octahedral unit shear: 1.3225581202197996
Nadai's natural octahedral unit strain: 1.14536893009174
Lode's parameter: 0.0
[19]:
C = ellipsoid.from_defgrad(F, 'right') # Green's deformation tensor
C
[19]:
Ellipsoid
[[4. 0. 2. ]
[0. 1. 0. ]
[2. 0. 1.25]]
(S1:2.25, S2:1, S3:0.445)
[20]:
v @ C @ v
[20]:
1.25
OrientationTensor3
class represents orientation tensor of set of vectors, linear or planar features. In adition to Ellipsoid
methods and properties, it provides properties to describe orientation distribution, e.g. Vollmer’s P
, G
, R
and B
indexes, Intensity
for Lisle intensity index and MAD
for approximate angular deviation.
[21]:
l = linset.random_fisher(position=lin(120,40))
ot = l.ortensor()
# or
ot = ortensor.from_features(l)
ot
[21]:
OrientationTensor3
[[ 0.169 -0.226 -0.218]
[-0.226 0.423 0.37 ]
[-0.218 0.37 0.407]]
(S1:0.958, S2:0.214, S3:0.193)
[22]:
ot.eigenvalues()
[22]:
array([0.91691349, 0.04592418, 0.03716233])
[23]:
ot.eigenvectors()
[23]:
(Vector3(-0.387, 0.66, 0.644),
Vector3(0.194, -0.625, 0.756),
Vector3(0.901, 0.418, 0.114))
[24]:
ot.kind
[24]:
'L'
The instances of Stress3
, Ellipsoid
and OrientationTensor3
also provides eigenlins
and eigenfols
properties to represent principal axes and planes
[25]:
ot.eigenlins
[25]:
(L:120/40, L:287/49, L:25/7)
[26]:
ot.eigenfols
[26]:
(S:300/50, S:107/41, S:205/83)
[27]:
ot.strength, ot.shape
[27]:
(1.6028587004277868, 14.14302389342446)
[28]:
ot.k, ot.d
[28]:
(31.063343962312064, 3.4701087058410436)
[29]:
ot.K, ot.D
[29]:
(14.14302389342446, 2.252244853321263)
[30]:
ot.P, ot.G, ot.R
[30]:
(0.8709893116100177, 0.017523685957085658, 0.11148700243289719)
[31]:
ot.MAD
[31]:
16.75305404050666
[ ]:
APSG tutorial - Part 3
[1]:
from apsg import *
StereoNet class
StereoNet
allows to visualize fetaures on stereographic projection. Both equal-area Schmidt (default) and equal-angle Wulff projections are supported.
[2]:
s = StereoNet()
s.great_circle(fol(150, 40))
s.pole(fol(150, 40))
s.line(lin(112, 30))
s.show()

A small circles (or cones) could be plotted as well
[3]:
s = StereoNet()
l = linset.random_fisher(position=lin(40, 15), kappa=15)
s.line(l, color='k')
s.cone(l.fisher_cone_a95(), color='r') # confidence cone on resultant
s.cone(l.fisher_cone_csd(), color='g') # confidence cone on 63% of data
s.show()

For density contouring a contour
method is available
[4]:
s = StereoNet()
s.contour(l, levels=8, colorbar=True)
s.line(l, color='g', marker='.')
s.show()

APSG also provides pairset
and faultset
classes to store pair
or fault
datasets. It can be inicialized by passing list of pair
or fault
objects as argument or use class methods from_array
or from_csv
[5]:
p = pairset([pair(120, 30, 165, 20),
pair(215, 60, 280,35),
pair(324, 70, 35, 40)])
p.misfit
[5]:
array([0.00000000e+00, 1.42108547e-14, 0.00000000e+00])
StereoNet
has two special methods to visualize fault data. Method fault
produce classical Angelier plot
[6]:
f = faultset([fault(170, 60, 182, 59, -1),
fault(210, 55, 195, 53, -1),
fault(10, 60, 15, 59, -1),
fault(355, 48, 22, 45, -1)])
s = StereoNet()
s.fault(f)
s.line(f.p, label='P-axes')
s.line(f.t, label='T-axes')
s.great_circle(f.m, label='M-planes')
s.show()

hoeppner
method produce Hoeppner diagram and must be invoked from StereoNet
instance
[7]:
s = StereoNet()
s.hoeppner(f, label=repr(f))
s.show()

StereoGrid class
StereoGrid
class allows to visualize any scalar field on StereoNet. It is used for plotting contour diagrams, but it exposes apply_func
method to calculate scalar field by any user-defined function. Function must accept three element numpy.array
as first argument passed from grid points of StereoGrid
.
Following example defines function to calculate resolved shear stress on plane from given stress tensor. StereoGrid
accesses via .grid
property is used to calculate this value over all directions and finally values are plotted by StereoNet
[8]:
S = stress([[-10, 2, -3],[2, -5, 1], [-3, 1, 2]])
s = StereoNet()
s.grid.apply_func(S.shear_stress)
s.contour(levels=10)
s.show()

The StereoGrid
provide also amgmech
(Angelier dihedra) method for paleostress analysis. Results are stored in StereoGrid
. Default behavior is to calculate counts (positive in extension, negative in compression)
[9]:
f = faultset.from_csv('mele.csv')
s = StereoNet()
s.grid.angmech(f)
s.contour()
s.show()

Setting method
to probability
, maximum likelihood estimate is calculated.
[10]:
f = faultset.from_csv('mele.csv')
s = StereoNet()
s.grid.angmech(f, method='probability')
s.contour()
s.show()

[11]:
s.grid
[11]:
StereoGrid EqualAreaProj 3000 points.
Maximum: 48.3587 at L:250/11
Minimum: -36.1316 at L:158/14
Multiple stereonets in figure
[12]:
import matplotlib.pyplot as plt
fig = plt.figure(constrained_layout=True, figsize=(10, 4))
subfigs = fig.subfigures(1, 3)
f = folset.random_fisher(position=fol(130, 60))
l = linset.random_fisher(position=fol(230, 30))
# panel 1
s1 = StereoNet()
s1.great_circle(f)
# panel 2
s2 = StereoNet()
s2.contour(l)
s2.line(l, ms=4, color='green')
# panel 3
s3 = StereoNet()
s3.pole(f, color='orange')
# render2fig
s1.render2fig(subfigs[0])
s2.render2fig(subfigs[1])
s3.render2fig(subfigs[2])
plt.show()

[ ]:
APSG tutorial - Part 4
[1]:
from apsg import *
Fabric plots
Tensor-type objects (ortensor
, ellipsoid
) could be visualized in several specialized plots. FlinnPlot
class provide classical Flinn’s deformation diagram, RamsayPlot
class provide Ramsay modification of Flinn’s deformation diagram, VollmerPlot
class provide triangular fabric plot (Vollmer, 1989) and HsuPlot
class provide Hsu fabric diagram using natural strains.
[2]:
F = defgrad.from_comp(xx=1/1.1, zz=1.1)
g1 = linset.uniform_sfs(name='Uniform').transform(F)
Fp = defgrad.from_comp(xx=0.5, yy=0.5, zz=4)
g2 = linset.uniform_sfs(name='Cluster').transform(Fp @ F)
Fo = defgrad.from_comp(xx=2, yy=0.25, zz=2)
g3 = linset.uniform_sfs(name='Girdle').transform(Fo @ F)
[3]:
s = StereoNet()
s.line(g1, label=True)
s.line(g2, label=True)
s.line(g3, label=True)
s.show()

[4]:
s = FlinnPlot()
s.point(g1.ortensor(), label=g1.name)
s.point(g2.ortensor(), label=g2.name)
s.point(g3.ortensor(), label=g3.name)
s.show()

[5]:
s = RamsayPlot()
s.point(g1.ortensor(), label=g1.name)
s.point(g2.ortensor(), label=g2.name)
s.point(g3.ortensor(), label=g3.name)
s.show()

[6]:
s = VollmerPlot()
s.point(g1.ortensor(), label=g1.name)
s.point(g2.ortensor(), label=g2.name)
s.point(g3.ortensor(), label=g3.name)
s.show()

[7]:
s = HsuPlot()
s.point(g1.ortensor(), label=g1.name)
s.point(g2.ortensor(), label=g2.name)
s.point(g3.ortensor(), label=g3.name)
s.show()

All fabric plots has path
method which accepts ellipsoidset
or ortensorset
objects plotted as line.
[8]:
F = defgrad.from_comp(xx=2, xy=2, yz=2, zz=0.5)
E = ellipsoid.from_defgrad(F)
L = velgrad.from_comp(xx=-2, zz=2)
Eevol = ellipsoidset([E.transform(L.defgrad(t/50)) for t in range(50)])
[9]:
r = FlinnPlot()
r.path(Eevol, marker='.')
r.point(E, color='r', marker='o')
r.show()

[10]:
r = RamsayPlot()
r.path(Eevol, marker='.')
r.point(E, color='r', marker='o')
r.show()

[11]:
ot = g1.ortensor()
otevol = ortensorset([g1.transform(L.defgrad(t/50)).ortensor() for t in range(50)])
f = VollmerPlot()
f.path(otevol, marker='.')
f.point(ot, color='r', marker='o')
f.show()

[12]:
r = HsuPlot()
r.path(Eevol, marker='.')
r.point(E, color='r', marker='o')
r.show()

[ ]:
APSG tutorial - Part 5
[1]:
from apsg import *
Pandas interface
To activate APSG interface for pandas you need to import it.
[2]:
import pandas as pd
from apsg.pandas import *
We can use pandas to read and manage data. See pandas documentation for more information.
[3]:
df = pd.read_csv('structures.csv')
df.head()
[3]:
site | structure | azi | inc | |
---|---|---|---|---|
0 | PB3 | L3 | 113 | 47 |
1 | PB3 | L3 | 118 | 42 |
2 | PB3 | S1 | 42 | 79 |
3 | PB3 | S1 | 42 | 73 |
4 | PB4 | S0 | 195 | 10 |
We can split out dataset by type of the structure…
[4]:
g = df.groupby('structure')
and select only one type…
[5]:
l = g.get_group('L3')
l.head()
[5]:
site | structure | azi | inc | |
---|---|---|---|---|
0 | PB3 | L3 | 113 | 47 |
1 | PB3 | L3 | 118 | 42 |
5 | PB8 | L3 | 167 | 17 |
6 | PB9 | L3 | 137 | 9 |
7 | PB9 | L3 | 147 | 14 |
Before we can use APSG interface, we need to create column with APSG features. For that we can use apsg
accessor and it’s methods create_vecs
, create_fols
, create_lins
or create_faults
. Each of this method accepts keyword argument name
to provide name of the new column.
[6]:
l = l.apsg.create_lins(name='L3')
l.head()
[6]:
site | structure | azi | inc | L3 | |
---|---|---|---|---|---|
0 | PB3 | L3 | 113 | 47 | L:113/47 |
1 | PB3 | L3 | 118 | 42 | L:118/42 |
5 | PB8 | L3 | 167 | 17 | L:167/17 |
6 | PB9 | L3 | 137 | 9 | L:137/9 |
7 | PB9 | L3 | 147 | 14 | L:147/14 |
Once we create column with APSG features, we can use accessors vec
, fol
, lin
or fault
providing methods for individual feature types, e.g. to calculate resultant vector
[7]:
l.lin.R()
[7]:
L:122/8
or to calculate orientation tensor…
[8]:
l.lin.ortensor()
[8]:
OrientationTensor3
[[ 0.29 -0.344 -0.067]
[-0.344 0.644 0.088]
[-0.067 0.088 0.065]]
(S1:0.932, S2:0.29, S3:0.216)
or to plot data on stereonet…
[9]:
l.lin.plot(label=True)

You can also extract APSG column as featureset using accessor property getset
[10]:
l.lin.getset
[10]:
L(97) L3
To construct stereonets with more data, you can pass stereonet object using keyword argument snet
[11]:
s = StereoNet()
l.lin.contour(snet=s)
l.lin.plot(snet=s, label=True)
pp = l.lin.ortensor().eigenfols
s.great_circle(*pp, label='principal\nplanes')
s.show()

[12]:
f = g.get_group('S2').apsg.create_fols(name='S2')
f.fol.plot()

The fault features could be created from columns containing orientation of fault plane, fault striation and sense of shear (+/-1)
[13]:
df = pd.read_csv('mele.csv')
df.head()
[13]:
fazi | finc | lazi | linc | sense | |
---|---|---|---|---|---|
0 | 94.997 | 79.966 | 119.073 | 79.032 | -1 |
1 | 65.923 | 84.972 | 154.087 | 20.008 | -1 |
2 | 42.354 | 46.152 | 109.786 | 21.778 | -1 |
3 | 14.093 | 61.963 | 295.917 | 21.045 | 1 |
4 | 126.138 | 77.947 | 40.848 | 21.033 | -1 |
[14]:
t = df.apsg.create_faults()
t.head()
[14]:
fazi | finc | lazi | linc | sense | faults | |
---|---|---|---|---|---|---|
0 | 94.997 | 79.966 | 119.073 | 79.032 | -1 | F:95/80-119/79 - |
1 | 65.923 | 84.972 | 154.087 | 20.008 | -1 | F:66/85-154/20 - |
2 | 42.354 | 46.152 | 109.786 | 21.778 | -1 | F:42/46-110/22 - |
3 | 14.093 | 61.963 | 295.917 | 21.045 | 1 | F:14/62-296/21 + |
4 | 126.138 | 77.947 | 40.848 | 21.033 | -1 | F:126/78-41/21 - |
[15]:
t[:5].fault.plot()

APSG tutorial - Part 6
Various tricks
The apsg_conf
dictionary allows to modify APSG settings.
[1]:
import numpy as np
from apsg import *
apsg_conf['figsize'] = (9, 7)
Some fun with cones…
[2]:
l1 = lin(110, 40)
l2 = lin(250, 40)
m = l1.slerp(l2, 0.5)
p = lin(l1.cross(l2))
[3]:
s = StereoNet()
[4]:
for t in np.linspace(0, 1, 8):
D = defgrad.from_vectors_axis(l1, l2, m.slerp(p, t))
a, ang = D.axisangle()
s.cone(cone(a, l1, ang))
[5]:
for a in np.linspace(10,25,4):
s.cone(cone(lin(315, 30), a), cone(lin(45, 30), a))
[6]:
s.show()

Some tricks
Double cross products are allowed but not easy to understand.
For example p**l**p
is interpreted as p**(l**p)
: a) l**p
is plane defined by l
and p
normal b) intersection of this plane and p
is calculated
[7]:
p = fol(250,40)
l = lin(160,25)
s = StereoNet()
s.great_circle(p, label='p')
s.pole(p, label='p')
s.line(l, label='l')
s.great_circle(l**p, label='l**p')
s.line(p**l, label='p**l')
s.great_circle(l**p**l, label='l**p**l')
s.line(p**l**p, label='p**l**p')
s.show()

Pair
class could be used to correct measurements of planar linear features which should spatialy overlap
[8]:
pl = pair(250, 40, 160, 25)
pl.misfit
[8]:
18.889520432245405
[9]:
s = StereoNet()
s.great_circle(fol(250, 40), color='b', label='Original')
s.line(lin(160, 25), color='b', label='Original')
s.great_circle(pl.fol, color='g', label='Corrected')
s.line(pl.lin, color='g', label='Corrected')
s.show()

StereoNet
has method arrow
to draw arrow. Here is example of Hoeppner plot for variable fault orientation within given stress field
[10]:
R = defgrad.from_pair(pair(180, 45, 240, 27))
S = stress([[-8, 0, 0],[0, -5, 0],[0, 0, -1]]).transform(R)
d = vecset.uniform_gss(n=600)
d = d[~d.is_upper()]
s = StereoNet()
s.great_circle(*S.eigenfols, lw=2)
s.line(S.sigma1dir, ms=10, color='red', label='Sig1')
s.line(S.sigma2dir, ms=10, color='k', label='Sig2')
s.line(S.sigma3dir, ms=10, color='green', label='Sig3')
for n in d:
f = S.fault(n)
if f.sense == 1:
s.arrow(f.fvec, f.lvec, sense=f.sense, color='coral')
else:
s.arrow(f.fvec, f.lvec, sense=f.sense, color='skyblue')
s.show()

ClusterSet class
ClusterSet
class provide access to scipy hierarchical clustering. Distance matrix is calculated as mutual angles of features within FeatureSet keeping axial and/or vectorial nature in mind. ClusterSet.elbow()
method allows to explore explained variance versus number of clusters relation. Actual cluster is done by ClusterSet.cluster()
method, using distance or maxclust criterion. Using of ClusterSet
is explained in following example. We generate some data and plot dendrogram:
[11]:
g1 = linset.random_fisher(position=lin(45,30))
g2 = linset.random_fisher(position=lin(320,56))
g3 = linset.random_fisher(position=lin(150,40))
g = g1 + g2 + g3
cl = cluster(g)
cl.dendrogram(no_labels=True)

Now we can explore evolution of within-groups variance versus number of clusters on Elbow plot (Note change in slope for three clusters)
[12]:
cl.elbow()

Finally we can do clustering with chosen number of clusters and plot them
[13]:
cl.cluster(maxclust=3)
cl.R.data # Restored centres of clusters
[13]:
(L:151/38, L:324/60, L:48/31)
[14]:
s = StereoNet()
for gid, color in zip(range(3), ['orange', 'red', 'green']):
s.line(cl.groups[gid], color=color, alpha=0.4, mec='none')
s.line(cl.R[gid], ms=16, color=color, marker='*', label=True)
s.show()

[ ]:
Package modules
APSG provides following modules:
feature module
This module provide basic classes to store and analyze various type of structural data.
Classes:
|
A class to represent axial (non-oriented) linear feature (lineation). |
|
A class to represent non-oriented planar feature (foliation). |
|
The class to store pair of planar and linear feature. |
|
The class to store |
|
The class to store cone with given axis, secant line and revolution angle in degrees. |
|
The class to represent 3D deformation gradient tensor. |
|
The class to represent 3D velocity gradient tensor. |
|
The class to represent 3D stress tensor. |
|
The class to represent 3D ellipsoid. |
|
Represents an 3D orientation tensor, which characterize data distribution using eigenvalue method. |
|
The class to represent 2D deformation gradient tensor. |
|
The class to represent 2D velocity gradient tensor. |
|
The class to represent 2D stress tensor. |
|
The class to represent 2D ellipse |
|
Represents an 2D orientation tensor, which characterize data distribution using eigenvalue method. |
|
Class to store set of |
|
Base class for containers |
|
Class to store set of |
|
Class to store set of |
|
Class to store set of |
|
Class to store set of |
|
Class to store set of |
|
Class to store set of |
|
Class to store set of |
|
Class to store set of |
|
Class to store set of |
|
Class to store set of |
|
Provides a hierarchical clustering using scipy.cluster routines. |
|
|
Functions:
|
Function to create appropriate container (FeatueSet) from list of features. |
- class apsg.feature.Lineation(*args)
Bases:
Axial3
A class to represent axial (non-oriented) linear feature (lineation).
There are different way to create
Lineation
object:without arguments create default
Lineation
L:0/0with single argument l, where:
l could be Vector3-like object
l could be string ‘x’, ‘y’ or ‘z’ - principal axes of coordinate system
l could be tuple of (x, y, z) - vector components
with 2 arguments plunge direction and plunge
with 3 numerical arguments defining vector components
- Parameters
azi (float) – plunge direction of linear feature in degrees
inc (float) – plunge of linear feature in degrees
Example
>>> lin() >>> lin('y') >>> lin(1,2,-1) >>> l = lin(110, 26)
- cross(other)
Return Foliation defined by two linear features
- property geo
Return tuple of plunge direction and plunge
- to_json()
Return as JSON dict
- class apsg.feature.Foliation(*args)
Bases:
Axial3
A class to represent non-oriented planar feature (foliation).
There are different way to create
Foliation
object:without arguments create default
Foliation
S:180/0with single argument f, where:
f could be Vector3-like object
f could be string ‘x’, ‘y’ or ‘z’ - principal planes of coordinate system
f could be tuple of (x, y, z) - vector components
with 2 arguments follows active notation. See apsg_conf[“notation”]
with 3 numerical arguments defining vector components of plane normal
- Parameters
azi (float) – dip direction (or strike) of planar feature in degrees.
inc (float) – dip of planar feature in degrees
Example
>>> fol() >>> fol('y') >>> fol(1,2,-1) >>> f = fol(250, 30)
- cross(other)
Return Lineation defined by intersection of planar features
- property geo
Return tuple of dip direction and dip
- to_json()
Return as JSON dict
- dipvec()
Return dip vector
- pole()
Return plane normal as vector
- rake(rake)
Return rake vector
- transform(F, **kwargs)
Return affine transformation by matrix F.
- Parameters
F – transformation matrix
- Keyword Arguments
norm – normalize transformed
Foliation
. [True or False] Default False- Returns
vector representation of affine transformation (dot product) of self by F
Example
>>> # Reflexion of `y` axis. >>> F = [[1, 0, 0], [0, -1, 0], [0, 0, 1]] >>> f = fol(45, 20) >>> f.transform(F) S:315/20
- class apsg.feature.Pair(*args)
Bases:
object
The class to store pair of planar and linear feature.
When
Pair
object is created, both planar and linear feature are adjusted, so linear feature perfectly fit onto planar one. Warning is issued, when misfit angle is bigger than 20 degrees.There are different way to create
Pair
object:without arguments create default Pair with fol(0,0) and lin(0,0)
with single argument p, where:
p could be Pair
p could be tuple of (fazi, finc, lazi, linc)
p could be tuple of (fx, fy ,fz, lx, ly, lz)
with 2 arguments f and l could be Vector3 like objects, e.g. Foliation and Lineation
with four numerical arguments defining fol(fazi, finc) and lin(lazi, linc)
- Parameters
fazi (float) – dip azimuth of planar feature in degrees
finc (float) – dip of planar feature in degrees
lazi (float) – plunge direction of linear feature in degrees
linc (float) – plunge of linear feature in degrees
Example
>>> pair() >>> pair(p) >>> pair(f, l) >>> pair(fazi, finc, lazi, linc) >>> p = pair(140, 30, 110, 26)
- label()
Return label
- to_json()
Return as JSON dict
- classmethod random()
Random Pair
- property fol
Return a planar feature of
Pair
asFoliation
.
- property lin
Return a linear feature of
Pair
asLineation
.
- transform(F, **kwargs)
Return an affine transformation of
Pair
by matrix F.- Parameters
F – transformation matrix
- Keyword Arguments
norm – normalize transformed vectors. True or False. Default False
- Returns
representation of affine transformation (dot product) of self by F
Example
>>> F = defgrad.from_axisangle(lin(0,0), 60) >>> p = pair(90, 90, 0, 50) >>> p.transform(F) P:270/30-314/23
- class apsg.feature.Fault(*args)
Bases:
Pair
The class to store
Pair
with associated sense of movement.When
Fault
object is created, both planar and linear feature are adjusted, so linear feature perfectly fit onto planar one. Warning is issued, when misfit angle is bigger than 20 degrees.There are different way to create
Fault
object:without arguments create default
Fault
with fol(0,0) and lin(0,0)with single argument p:
p could be Fault
p could be tuple of (fazi, finc, lazi, linc, sense)
p could be tuple of (fx, fy ,fz, lx, ly, lz)
with 2 arguments f and l could be Vector3 like objects, e.g.
Foliation
andLineation
with 5 numerical arguments defining fol(fazi, finc), lin(lazi, linc) and sense
- Parameters
fazi (float) – dip azimuth of planar feature in degrees
finc (float) – dip of planar feature in degrees
lazi (float) – plunge direction of linear feature in degrees
linc (float) – plunge of linear feature in degrees
sense (float) – sense of movement -/+1 hanging-wall up/down reverse/normal
- sense
sense of movement (+/-1)
- Type
int
Example
>>> fault() >>> fault(p) >>> fault(f, l) >>> fault(fazi, finc, lazi, linc, sense) >>> f = fault(140, 30, 110, 26, -1)
- to_json()
Return as JSON dict
- classmethod random()
Random Fault
- p_vector(ptangle=90)
Return P axis as
Vector3
- t_vector(ptangle=90)
Return T-axis as
Vector3
.
- property p
Return P-axis as
Lineation
- property t
Return T-axis as
Lineation
- property m
Return kinematic M-plane as
Foliation
- property d
Return dihedra plane as
Fol
- class apsg.feature.Cone(*args)
Bases:
object
The class to store cone with given axis, secant line and revolution angle in degrees.
There are different way to create
Cone
object according to number of arguments:without args, you can create default``Cone`` with axis
lin(0, 90)
, secantlin(0, 0)
angle 360°with single argument c, where c could be
Cone
, 5-tuple of (aazi, ainc, sazi, sinc, revangle) or 7-tuple of (ax, ay ,az, sx, sy, sz, revangle)with 3 arguments, where axis and secant line could be Vector3 like objects, e.g. Lineation and third argument is revolution angle
with 5 arguments defining axis lin(aazi, ainc), secant line lin(sazi, sinc) and angle of revolution
- revangle
revolution angle
- Type
float
Example
>>> cone() >>> cone(c) >>> cone(a, s, revangle) >>> cone(aazi, ainc, sazi, sinc, revangle) >>> c = cone(140, 30, 110, 26, 360)
- label()
Return label
- to_json()
Return as JSON dict
- classmethod random()
Random Cone
- apical_angle()
Return apical angle
- property rotated_secant
Return revangle rotated secant vector
- class apsg.feature.DeformationGradient3(*args)
Bases:
Matrix3
The class to represent 3D deformation gradient tensor.
- Parameters
a (3x3 array_like) – Input data, that can be converted to 3x3 2D array. This includes lists, tuples and ndarrays.
- Returns
DeformationGradient3
object
Example
>>> F = defgrad(np.diag([2, 1, 0.5]))
- classmethod from_ratios(Rxy=1, Ryz=1)
Return isochoric
DeformationGradient3
tensor with axial stretches defined by strain ratios. Default is identity tensor.- Keyword Arguments
Rxy (float) – XY strain ratio
Ryz (float) – YZ strain ratio
Example
>>> F = defgrad.from_ratios(Rxy=2, Ryz=3) >>> F DeformationGradient3 [[2.289 0. 0. ] [0. 1.145 0. ] [0. 0. 0.382]]
- classmethod from_two_pairs(p1, p2, symmetry=False)
Return
DeformationGradient3
representing rotation of coordinates from system defined byPair
p1 to system defined byPair
p2.Lineation in pair define x axis and normal to foliation in pair define z axis
- Parameters
p1 (
Pair
) – fromp2 (
Pair
) – to
- Keyword Arguments
symmetry (bool) – If True, returns minimum angle rotation of axial pairs
- Returns
Defgrad3
rotational matrix
Example
>>> p1 = pair(58, 36, 81, 34) >>> p2 = pair(217,42, 162, 27) >>> R = defgrad.from_two_pairs(p1, p2) >>> p1.transform(R) == p2 True
- property R
Return rotation part of
DeformationGradient3
from polar decomposition.
- property U
Return stretching part of
DeformationGradient3
from right polar decomposition.
- property V
Return stretching part of
DeformationGradient3
from left polar decomposition.
- axisangle()
Return rotation part of
DeformationGradient3
as axis, angle tuple.
- velgrad(time=1)
Return
VelocityGradient3
calculated as matrix logarithm divided by given time.- Keyword Arguments
time (float) – total time. Default 1
Example
>>> F = defgrad.from_comp(xx=2, xy=1, zz=0.5) >>> L = F.velgrad(time=10) >>> L VelocityGradient3 [[ 0.069 0.069 0. ] [ 0. 0. 0. ] [ 0. 0. -0.069]] >>> L.defgrad(time=10) DeformationGradient3 [[2. 1. 0. ] [0. 1. 0. ] [0. 0. 0.5]]
- class apsg.feature.VelocityGradient3(*args)
Bases:
Matrix3
The class to represent 3D velocity gradient tensor.
- Parameters
a (3x3 array_like) – Input data, that can be converted to 3x3 2D array. This includes lists, tuples and ndarrays.
- Returns
VelocityGradient3
matrix
Example
>>> L = velgrad(np.diag([0.1, 0, -0.1]))
- defgrad(time=1, steps=1)
Return
DeformationGradient3
tensor accumulated after given time.- Keyword Arguments
time (float) – time of deformation. Default 1
steps (int) – when bigger than 1, will return a list of
DeformationGradient3
tensors for each timestep.
- rate()
Return rate of deformation tensor
- spin()
Return spin tensor
- class apsg.feature.Stress3(*args)
Bases:
Tensor3
The class to represent 3D stress tensor.
The real eigenvalues of the stress tensor are what we call the principal stresses. There are 3 of these in 3D, available as properties E1, E2, and E3 in descending order of magnitude (max, intermediate, and minimum principal stresses) with orientations available as properties V1, V2 and V3. The minimum principal stress is simply the eigenvalue that has the lowest magnitude. Therefore, the maximum principal stress is the most tensile (least compressive) and the minimum principal stress is the least tensile (most compressive). Tensile normal stresses have positive values, and compressive normal stresses have negative values. If the maximum principal stress is <=0 and the minimum principal stress is negative then the stresses are completely compressive.
Note: Stress tensor has a special properties sigma1, sigma2 and sigma3 to follow common geological terminology. sigma1 is most compressive (least tensile) while sigma3 is most tensile (least compressive). Their orientation could be accessed with properties sigma1dir, sigma2dir and sigma3dir.
- Parameters
a (3x3 array_like) – Input data, that can be converted to 3x3 2D array. This includes lists, tuples and ndarrays.
- Returns
Stress3
object
Example
>>> S = stress([[-8, 0, 0],[0, -5, 0],[0, 0, -1]])
- classmethod from_comp(xx=0, xy=0, xz=0, yy=0, yz=0, zz=0)
Return
Stress
tensor. Default is zero tensor.Note that stress tensor must be symmetrical.
Example
>>> S = stress.from_comp(xx=-5, yy=-2, zz=10, xy=1) >>> S Stress3 [[-5. 1. 0.] [ 1. -2. 0.] [ 0. 0. 10.]]
- property mean_stress
Mean stress
- property hydrostatic
Mean hydrostatic stress tensor component
- property deviatoric
A stress deviator tensor component
- effective(fp)
A effective stress tensor reduced by fluid pressure
- Parameters
fp (flot) – fluid pressure
- property sigma1
A maximum principal stress (max compressive)
- property sigma2
A intermediate principal stress
- property sigma3
A minimum principal stress (max tensile)
- property sigma1dir
Return unit length vector in direction of maximum principal stress (max compressive)
- property sigma2dir
Return unit length vector in direction of intermediate principal stress
- property sigma3dir
Return unit length vector in direction of minimum principal stress (max tensile)
- property sigma1vec
Return maximum principal stress vector (max compressive)
- property sigma2vec
Return intermediate principal stress vector
- property sigma3vec
Return minimum principal stress vector (max tensile)
- property I1
First invariant
- property I2
Second invariant
- property I3
Third invariant
- property diagonalized
Returns diagonalized Stress tensor and orthogonal matrix R, which transforms actual coordinate system to the principal one.
- cauchy(n)
Return stress vector associated with plane given by normal vector.
- Parameters
n – normal given as
Vector3
orFoliation
object
Example
>>> S = stress.from_comp(xx=-5, yy=-2, zz=10, xy=1) >>> S.cauchy(fol(160, 30)) Vector3(-2.52, 0.812, 8.66)
- fault(n)
Return
Fault
object derived from given by normal vector.- Parameters
n – normal given as
Vector3
orFoliation
object
Example
>>> S = stress.from_comp(xx=-5, yy=-2, zz=10, xy=8) >>> S.fault(fol(160, 30)) F:160/30-141/29 +
- stress_comp(n)
Return normal and shear stress
Vector3
components on plane given by normal vector.
- normal_stress(n)
Return normal stress magnitude on plane given by normal vector.
- shear_stress(n)
Return shear stress magnitude on plane given by normal vector.
- slip_tendency(n, fp=0, log=False)
Return slip tendency calculated as the ratio of shear stress to normal stress acting on the plane.
Note: Providing fluid pressure effective normal stress is calculated
- Keyword Arguments
fp (float) – fluid pressure. Default 0
log (bool) – when True, returns logarithm of slip tendency
- dilation_tendency(n, fp=0)
Return dilation tendency of the plane.
Note: Providing fluid pressure effective stress is used
- Keyword Arguments
fp (float) – fluid pressure. Default 0
- property shape_ratio
Return shape ratio R (Gephart & Forsyth 1984)
- class apsg.feature.Ellipsoid(*args)
Bases:
Tensor3
The class to represent 3D ellipsoid.
See following methods and properties for additional operations.
- Parameters
matrix (3x3 array_like) – Input data, that can be converted to 3x3 2D matrix. This includes lists, tuples and ndarrays.
- Returns
Ellipsoid
object
Example
>>> E = ellipsoid([[8, 0, 0], [0, 2, 0], [0, 0, 1]]) >>> E Ellipsoid [[8 0 0] [0 2 0] [0 0 1]] (S1:2.83, S2:1.41, S3:1)
- classmethod from_defgrad(F, form='left', **kwargs) Ellipsoid
Return deformation tensor from
Defgrad3
.- Kwargs:
- form: ‘left’ or ‘B’ for left Cauchy–Green deformation tensor or
Finger deformation tensor ‘right’ or ‘C’ for right Cauchy–Green deformation tensor or Green’s deformation tensor. Default is ‘left’.
- classmethod from_stretch(x=1, y=1, z=1, **kwargs) Ellipsoid
Return diagonal tensor defined by magnitudes of principal stretches.
- property kind: str
Return descriptive type of ellipsoid
- property strength: float
Return the Woodcock strength.
- property shape: float
return the Woodcock shape.
- property S1: float
Return the maximum principal stretch.
- property S2: float
Return the middle principal stretch.
- property S3: float
Return the minimum principal stretch.
- property e1: float
Return the maximum natural principal strain.
- property e2: float
Return the middle natural principal strain.
- property e3: float
Return the minimum natural principal strain.
- property Rxy: float
Return the Rxy ratio.
- property Ryz: float
Return the Ryz ratio.
- property e12: float
Return the e1 - e2.
- property e13: float
Return the e1 - e3.
- property e23: float
Return the e2 - e3.
- property k: float
Return the strain symmetry.
- property d: float
Return the strain intensity.
- property K: float
Return the strain symmetry (Ramsay, 1983).
- property D: float
Return the strain intensity.
- property r: float
Return the strain intensity (Watterson, 1968).
- property goct: float
Return the natural octahedral unit shear (Nadai, 1963).
- property eoct: float
Return the natural octahedral unit strain (Nadai, 1963).
- property lode: float
Return Lode parameter (Lode, 1926).
- property P: float
Point index (Vollmer, 1990).
- property G: float
Girdle index (Vollmer, 1990).
- property R: float
Random index (Vollmer, 1990).
- property B: float
Cylindricity index (Vollmer, 1990).
- property Intensity: float
Intensity index (Lisle, 1985).
- property aMAD_l: float
Return approximate angular deviation from the major axis along E1.
- property aMAD_p: float
Return approximate deviation from the plane normal to E3.
- property aMAD: float
Return approximate deviation according to shape
- property MAD_l: float
Return maximum angular deviation (MAD) of linearly distributed vectors.
Kirschvink 1980
- property MAD_p: float
Return maximum angular deviation (MAD) of planarly distributed vectors.
Kirschvink 1980
- property MAD: float
Return maximum angular deviation (MAD)
- class apsg.feature.OrientationTensor3(*args)
Bases:
Ellipsoid
Represents an 3D orientation tensor, which characterize data distribution using eigenvalue method. See (Watson 1966, Scheidegger 1965).
See following methods and properties for additional operations.
- Parameters
matrix (3x3 array_like) – Input data, that can be converted to 3x3 2D matrix. This includes lists, tuples and ndarrays. Array could be also
Group
(for backward compatibility)- Returns
OrientationTensor3
object
Example
>>> ot = ortensor([[8, 0, 0], [0, 2, 0], [0, 0, 1]]) >>> ot OrientationTensor3 [[8 0 0] [0 2 0] [0 0 1]] (S1:2.83, S2:1.41, S3:1)
- classmethod from_features(g) OrientationTensor3
Return
Ortensor
of data in Vector3Set of features- Parameters
g (Vector3Set) – Set of features
Example
>>> g = linset.random_fisher(position=lin(120,50)) >>> ot = ortensor.from_features(g) >>> ot OrientationTensor3 [[ 0.126 -0.149 -0.202] [-0.149 0.308 0.373] [-0.202 0.373 0.566]] (S1:0.955, S2:0.219, S3:0.2) >>> ot.eigenlins (L:119/51, L:341/31, L:237/21)
- classmethod from_pairs(p, shift=True) OrientationTensor3
Return Lisle (1989)
Ortensor
of orthogonal data inPairSet
- Lisle, R. (1989). The Statistical Analysis of Orthogonal Orientation Data.
The Journal of Geology, 97(3), 360-364.
- Note: Tensor is by default shifted towards positive eigenvalues, so it
could be used as Scheidegger orientation tensor for plotting. When original Lisle tensor is needed, set shift to False.
- Parameters
p –
PairSet
- Keyword Arguments
shift (bool) – When True the tensor is shifted. Default True
Example
>>> p = pairset([pair(109, 82, 21, 10), pair(118, 76, 30, 11), pair(97, 86, 7, 3), pair(109, 75, 23, 14)]) >>> ot = ortensor.from_pairs(p) >>> ot OrientationTensor3 [[0.577 0.192 0.029] [0.192 0.092 0.075] [0.029 0.075 0.332]] (S1:0.807, S2:0.579, S3:0.114)
- class apsg.feature.DeformationGradient2(*args)
Bases:
Matrix2
The class to represent 2D deformation gradient tensor.
- Parameters
a (2x2 array_like) – Input data, that can be converted to 2x2 2D array. This includes lists, tuples and ndarrays.
- Returns
DeformationGradient2
object
Example
>>> F = defgrad2(np.diag([2, 0.5]))
- classmethod from_ratio(R=1)
Return isochoric
DeformationGradient2
tensor with axial stretches defined by strain ratio. Default is identity tensor.- Keyword Arguments
R (float) – strain ratio
Example
>>> F = defgrad2.from_ratio(R=4) >> F DeformationGradient2 [[2. 0. ] [0. 0.5]]
- classmethod from_angle(theta)
Return
DeformationGradient2
representing rotation by angle theta.- Parameters
theta – Angle of rotation in degrees
Example
>>> F = defgrad2.from_angle(45) >>> F DeformationGradient2 [[ 0.707 -0.707] [ 0.707 0.707]]
- property R
Return rotation part of
DeformationGradient2
from polar decomposition.
- property U
Return stretching part of
DeformationGradient2
from right polar decomposition.
- property V
Return stretching part of
DeformationGradient2
from left polar decomposition.
- angle()
Return rotation part of
DeformationGradient2
as angle.
- velgrad(time=1)
Return
VelocityGradient2
for given time
- class apsg.feature.VelocityGradient2(*args)
Bases:
Matrix2
The class to represent 2D velocity gradient tensor.
- Parameters
a (2x2 array_like) – Input data, that can be converted to 2x2 2D array. This includes lists, tuples and ndarrays.
- Returns
VelocityGradient2
object
Example
>>> L = velgrad2(np.diag([0.1, -0.1]))
- defgrad(time=1, steps=1)
Return
DeformationGradient2
tensor accumulated after given time.- Keyword Arguments
time (float) – time of deformation. Default 1
steps (int) – when bigger than 1, will return a list of
DeformationGradient2
tensors for each timestep.
- rate()
Return rate of deformation tensor
- spin()
Return spin tensor
- class apsg.feature.Stress2(*args)
Bases:
Tensor2
The class to represent 2D stress tensor.
- Parameters
a (2x2 array_like) – Input data, that can be converted to 2x2 2D array. This includes lists, tuples and ndarrays.
- Returns
Stress2
object
Example
>>> S = Stress2([[-8, 0, 0],[0, -5, 0],[0, 0, -1]])
- classmethod from_comp(xx=0, xy=0, yy=0)
Return
Stress2
tensor. Default is zero tensor.Note that stress tensor must be symmetrical.
- Keyword Arguments
yy (xx, xy,) – tensor components
Example
>>> S = stress2.from_comp(xx=-5, yy=-2, xy=1) >>> S Stress2 [[-5. 1.] [ 1. -2.]]
- property mean_stress
Mean stress
- property hydrostatic
Mean hydrostatic stress tensor component
- property deviatoric
A stress deviator tensor component
- property sigma1
A maximum principal stress (max compressive)
- property sigma2
A minimum principal stress
- property sigma1dir
Return unit length vector in direction of maximum principal stress (max compressive)
- property sigma2dir
Return unit length vector in direction of minimum principal stress
- property sigma1vec
Return maximum principal stress vector (max compressive)
- property sigma2vec
Return minimum principal stress vector
- property I1
First invariant
- property I2
Second invariant
- property I3
Third invariant
- property diagonalized
Returns diagonalized Stress tensor and orthogonal matrix R, which transforms actual coordinate system to the principal one.
- cauchy(n)
Return stress vector associated with plane given by normal vector.
- Parameters
n – normal given as
Vector2
object
Example
>>> S = Stress.from_comp(xx=-5, yy=-2, xy=1) >>> S.cauchy(vec2(1,1)) V(-2.520, 0.812, 8.660)
- stress_comp(n)
Return normal and shear stress
Vector2
components on plane given by normal vector.
- normal_stress(n)
Return normal stress magnitude on plane given by normal vector.
- shear_stress(n)
Return shear stress magnitude on plane given by normal vector.
- signed_shear_stress(n)
Return signed shear stress magnitude on plane given by normal vector.
- class apsg.feature.Ellipse(*args)
Bases:
Tensor2
The class to represent 2D ellipse
See following methods and properties for additional operations.
- Parameters
matrix (2x2 array_like) – Input data, that can be converted to 2x2 2D matrix. This includes lists, tuples and ndarrays.
- Returns
Ellipse
object
Example
>>> E = ellipse([[8, 0], [0, 2]]) >>> E Ellipse [[8. 0.] [0. 2.]] (ar:2, ori:0)
- classmethod from_defgrad(F, form='left', **kwargs) Ellipse
Return deformation tensor from
Defgrad2
.- Kwargs:
- form: ‘left’ or ‘B’ for left Cauchy–Green deformation tensor or
Finger deformation tensor ‘right’ or ‘C’ for right Cauchy–Green deformation tensor or Green’s deformation tensor. Default is ‘left’.
- classmethod from_stretch(x=1, y=1, **kwargs) Ellipse
Return diagonal tensor defined by magnitudes of principal stretches.
- property S1: float
Return the maximum principal stretch.
- property S2: float
Return the minimum principal stretch.
- property e1: float
Return the maximum natural principal strain.
- property e2: float
Return the minimum natural principal strain.
- property ar: float
Return the ellipse axial ratio.
- property orientation
Return the orientation of the maximum eigenvector.
- property e12: float
Return the difference between natural principal strains.
- class apsg.feature.OrientationTensor2(*args)
Bases:
Ellipse
Represents an 2D orientation tensor, which characterize data distribution using eigenvalue method. See (Watson 1966, Scheidegger 1965).
See following methods and properties for additional operations.
- Parameters
matrix (2x2 array_like) – Input data, that can be converted to 2x2 2D matrix. This includes lists, tuples and ndarrays. Array could be also
Group
(for backward compatibility)- Returns
OrientationTensor2
object
Example
>>> v = vec2set.random(n=1000) >>> ot = v.ortensor() >>> ot OrientationTensor2 [[ 0.502 -0.011] [-0.011 0.498]] (ar:1.02, ori:140)
- classmethod from_features(g) OrientationTensor2
Return
Ortensor
of data in Vector2Set features- Parameters
g (Vector2Set) – Set of features
Example
>>> v = vec2set.random_vonmises(position=120) >>> ot = v.ortensor() >>> ot OrientationTensor2 [[ 0.377 -0.282] [-0.282 0.623]] (ar:2.05, ori:123)
- class apsg.feature.Vector2Set(data, name='Default')
Bases:
FeatureSet
Class to store set of
Vector2
features- property x
Return numpy array of x-components
- property y
Return numpy array of y-components
- property direction
Return array of direction angles
- proj(vec)
Return projections of all features in
Vector2Set
onto vector.
- dot(vec)
Return array of dot products of all features in
Vector2Set
with vector.
- cross(other=None)
Return cross products of all features in
Vector2Set
Without arguments it returns cross product of all pairs in dataset. If argument is
Vector2Set
of same length or single data object element-wise cross-products are calculated.
- angle(other=None)
Return angles of all data in
Vector2Set
objectWithout arguments it returns angles of all pairs in dataset. If argument is
Vector2Set
of same length or single data object element-wise angles are calculated.
- normalized()
Return
Vector2Set
object with normalized (unit length) elements.
- uv()
Return
Vector2Set
object with normalized (unit length) elements.
- transform(F, **kwargs)
Return affine transformation of all features
Vector2Set
by matrix ‘F’.- Parameters
F – Transformation matrix. Array-like value e.g.
DeformationGradient3
- Keyword Arguments
norm – normalize transformed features. True or False. Default False
- R(mean=False)
Return resultant of data in
Vector2Set
object.Resultant is of same type as features in
Vector2Set
. Note thatAxial2
is axial in nature so resultant can give other result than expected. Anyway for axial data orientation tensor analysis will give you right answer.- Parameters
mean – if True returns mean resultant. Default False
- fisher_statistics()
Fisher’s statistics
- fisher_statistics returns dictionary with keys:
k estimated precision parameter, csd estimated angular standard deviation a95 confidence limit
- var()
Spherical variance based on resultant length (Mardia 1972).
var = 1 - abs(R) / n
- delta()
Cone angle containing ~63% of the data in degrees.
For enough large sample it approach angular standard deviation (csd) of Fisher statistics
- rdegree()
Degree of preffered orientation of vectors in
Vector2Set
.D = 100 * (2 * abs(R) - n) / n
- ortensor()
Return orientation tensor
Ortensor
ofGroup
.
- halfspace()
Change orientation of vectors in
Vector2Set
, so all have angle<=90 with resultant.
- classmethod from_direction(angles, name='Default')
Create
Vector2Set
object from arrays of direction angles- Parameters
angles – list or angles
- Keyword Arguments
name – name of
Vector2Set
object. Default is ‘Default’
Example
>>> f = vec2set.from_angles([120,130,140,125, 132. 131])
- classmethod from_xy(x, y, name='Default')
Create
Vector2Set
object from arrays of x and y components- Parameters
x – list or array of x components
y – list or array of y components
- Keyword Arguments
name – name of
Vector2Set
object. Default is ‘Default’
Example
>>> v = vec2set.from_xy([-0.4330127, -0.4330127, -0.66793414], [0.75, 0.25, 0.60141061])
- classmethod random(n=100, name='Default')
Method to create
Vector2Set
of features with uniformly distributed random orientation.- Keyword Arguments
n – number of objects to be generated
name – name of dataset. Default is ‘Default’
Example
>>> np.random.seed(58463123) >>> l = vec2set.random(100)
- classmethod random_vonmises(n=100, position=0, kappa=5, name='Default')
Return
Vector2Set
of random vectors sampled from von Mises distribution around center position with concentration kappa.- Parameters
n – number of objects to be generated
position – mean orientation given as angle. Default 0
kappa – precision parameter of the distribution. Default 20
name – name of dataset. Default is ‘Default’
Example
>>> l = linset.random_fisher(position=lin(120,50))
- class apsg.feature.FeatureSet(data, name='Default')
Bases:
object
Base class for containers
- to_json()
Return as JSON dict
- label()
Return label
- rotate(axis, phi)
Rotate
FeatureSet
object phi degress about axis.
- bootstrap(n=100, size=None)
Return generator of bootstraped samples from
FeatureSet
.- Parameters
n – number of samples to be generated. Default 100.
size – number of data in sample. Default is same as
FeatureSet
.
Example
>>> np.random.seed(6034782) >>> l = Vector3Set.random_fisher(n=100, position=lin(120,40)) >>> sm = [lb.R() for lb in l.bootstrap()] >>> l.fisher_statistics() {'k': 19.91236110604979, 'a95': 3.249027370399397, 'csd': 18.15196473425630} >>> Vector3Set(sm).fisher_statistics() {'k': 1735.360206701859, 'a95': 0.3393224356447341, 'csd': 1.944420546779801}
- class apsg.feature.Vector3Set(data, name='Default')
Bases:
FeatureSet
Class to store set of
Vector3
features- property x
Return numpy array of x-components
- property y
Return numpy array of y-components
- property z
Return numpy array of z-components
- property geo
Return arrays of azi and inc according to apsg_conf[‘notation’]
- to_lin()
Return
LineationSet
object with all data converted toLineation
.
- to_fol()
Return
FoliationSet
object with all data converted toFoliation
.
- to_vec()
Return
Vector3Set
object with all data converted toVector3
.
- project(vec)
Return projections of all features in
FeatureSet
onto vector.
- proj(vec)
Return projections of all features in
FeatureSet
onto vector.
- reject(vec)
Return rejections of all features in
FeatureSet
onto vector.
- dot(vec)
Return array of dot products of all features in
FeatureSet
with vector.
- cross(other=None)
Return cross products of all features in
FeatureSet
Without arguments it returns cross product of all pairs in dataset. If argument is
FeatureSet
of same length or single data object element-wise cross-products are calculated.
- angle(other=None)
Return angles of all data in
FeatureSet
objectWithout arguments it returns angles of all pairs in dataset. If argument is
FeatureSet
of same length or single data object element-wise angles are calculated.
- normalized()
Return
FeatureSet
object with normalized (unit length) elements.
- uv()
Return
FeatureSet
object with normalized (unit length) elements.
- transform(F, **kwargs)
Return affine transformation of all features
FeatureSet
by matrix ‘F’.- Parameters
F – Transformation matrix. Array-like value e.g.
DeformationGradient3
- Keyword Arguments
norm – normalize transformed features. True or False. Default False
- is_upper()
Return boolean array of z-coordinate negative test
- R(mean=False)
Return resultant of data in
FeatureSet
object.Resultant is of same type as features in
FeatureSet
. Note thatFoliation
andLineation
are axial in nature so resultant can give other result than expected. Anyway for axial data orientation tensor analysis will give you right answer.- Parameters
mean – if True returns mean resultant. Default False
- fisher_statistics()
Fisher’s statistics
- fisher_statistics returns dictionary with keys:
k estimated precision parameter, csd estimated angular standard deviation a95 confidence limit
- fisher_cone_a95()
Confidence limit cone based on Fisher’s statistics
Cone axis is resultant and apical angle is a95 confidence limit
- fisher_cone_csd()
Angular standard deviation cone based on Fisher’s statistics
Cone axis is resultant and apical angle is angular standard deviation
- var()
Spherical variance based on resultant length (Mardia 1972).
var = 1 - abs(R) / n
- delta()
Cone angle containing ~63% of the data in degrees.
For enough large sample it approach angular standard deviation (csd) of Fisher statistics
- rdegree()
Degree of preffered orientation of vectors in
FeatureSet
.D = 100 * (2 * abs(R) - n) / n
- ortensor()
Return orientation tensor
Ortensor
ofGroup
.
- centered(max_vertical=False)
Rotate
FeatureSet
object to position that eigenvectors are parallel to axes of coordinate system: E1||X (north-south), E2||X(east-west), E3||X(vertical)- Parameters
max_vertical – If True E1 is rotated to vertical. Default False
- halfspace()
Change orientation of vectors in
FeatureSet
, so all have angle<=90 with resultant.
- classmethod from_csv(filename, acol=0, icol=1)
Create
FeatureSet
object from csv file of azimuths and inclinations- Parameters
filename (str) – name of CSV file to load
- Keyword Arguments
acol (int or str) – azimuth column (starts from 0). Default 0
icol (int or str) – inclination column (starts from 0). Default 1 When acol and icol are strings they are used as column headers.
Example
>>> gf = folset.from_csv('file1.csv') >>> gl = linset.from_csv('file2.csv', acol=1, icol=2)
- to_csv(filename, delimiter=',')
Save
FeatureSet
object to csv file of azimuths and inclinations- Parameters
filename (str) – name of CSV file to save.
- Keyword Arguments
delimiter (str) – values delimiter. Default ‘,’
Note: Written values are rounded according to ndigits settings in apsg_conf
- classmethod from_array(azis, incs, name='Default')
Create
FeatureSet
object from arrays of azimuths and inclinations- Parameters
azis – list or array of azimuths
incs – list or array of inclinations
- Keyword Arguments
name – name of
FeatureSet
object. Default is ‘Default’
Example
>>> f = folset.from_array([120,130,140], [10,20,30]) >>> l = linset.from_array([120,130,140], [10,20,30])
- classmethod from_xyz(x, y, z, name='Default')
Create
FeatureSet
object from arrays of x, y and z components- Parameters
x – list or array of x components
y – list or array of y components
z – list or array of z components
- Keyword Arguments
name – name of
FeatureSet
object. Default is ‘Default’
Example
>>> v = vecset.from_xyz([-0.4330127, -0.4330127, -0.66793414], [0.75, 0.25, 0.60141061], [0.5, 0.8660254, 0.43837115])
- classmethod random_normal(n=100, position=Vector3(0, 0, 1), sigma=20, name='Default')
Method to create
FeatureSet
of normaly distributed features.- Keyword Arguments
n – number of objects to be generated
position – mean orientation given as
Vector3
. Default Vector3(0, 0, 1)sigma – sigma of normal distribution. Default 20
name – name of dataset. Default is ‘Default’
Example
>>> np.random.seed(58463123) >>> l = linset.random_normal(100, lin(120, 40)) >>> l.R L:120/39
- classmethod random_fisher(n=100, position=Vector3(0, 0, 1), kappa=20, name='Default')
Return
FeatureSet
of random vectors sampled from von Mises Fisher distribution around center position with concentration kappa.- Parameters
n – number of objects to be generated
position – mean orientation given as
Vector3
. Default Vector3(0, 0, 1)kappa – precision parameter of the distribution. Default 20
name – name of dataset. Default is ‘Default’
Example
>>> l = linset.random_fisher(position=lin(120,50))
- classmethod random_fisher2(n=100, position=Vector3(0, 0, 1), kappa=20, name='Default')
Method to create
FeatureSet
of vectors distributed according to Fisher distribution.Note: For proper von Mises Fisher distrinbution implementation use
random.fisher
method.- Parameters
n – number of objects to be generated
position – mean orientation given as
Vector3
. Default Vector3(0, 0, 1)kappa – precision parameter of the distribution. Default 20
name – name of dataset. Default is ‘Default’
Example
>>> l = linset.random_fisher2(position=lin(120,50))
- classmethod random_kent(p, n=100, kappa=20, beta=None, name='Default')
Return
FeatureSet
of random vectors sampled from Kent distribution (Kent, 1982) - The 5-parameter Fisher–Bingham distribution.- Parameters
p – Pair object defining orientation of data
N – number of objects to be generated
kappa – concentration parameter. Default 20
beta – ellipticity 0 <= beta < kappa
name – name of dataset. Default is ‘Default’
Example
>>> p = pair(150, 40, 150, 40) >>> l = linset.random_kent(p, n=300, kappa=30)
- classmethod uniform_sfs(n=100, name='Default')
Method to create
FeatureSet
of uniformly distributed vectors. Spherical Fibonacci Spiral points on a sphere algorithm adopted from John Burkardt.http://people.sc.fsu.edu/~jburkardt/
- Keyword Arguments
n – number of objects to be generated. Default 1000
name – name of dataset. Default is ‘Default’
Example
>>> v = vecset.uniform_sfs(300) >>> v.ortensor().eigenvalues() (0.3334645347163635, 0.33333474915201167, 0.33320071613162483)
- classmethod uniform_gss(n=100, name='Default')
Method to create
FeatureSet
of uniformly distributed vectors. Golden Section Spiral points on a sphere algorithm.http://www.softimageblog.com/archives/115
- Parameters
n – number of objects to be generated. Default 1000
name – name of dataset. Default is ‘Default’
Example
>>> v = vecset.uniform_gss(300) >>> v.ortensor().eigenvalues() (0.33335688569571587, 0.33332315115436933, 0.33331996314991513)
- class apsg.feature.LineationSet(data, name='Default')
Bases:
Vector3Set
Class to store set of
Lineation
features
- class apsg.feature.FoliationSet(data, name='Default')
Bases:
Vector3Set
Class to store set of
Foliation
features- dipvec()
Return
FeatureSet
object with plane dip vector.
- class apsg.feature.PairSet(data, name='Default')
Bases:
FeatureSet
Class to store set of
Pair
features- property fol
Return Foliations of pairs as FoliationSet
- property fvec
Return planar normal vectors of pairs as Vector3Set
- property lin
Return Lineation of pairs as LineationSet
- property lvec
Return lineation vectors of pairs as Vector3Set
- property misfit
Return array of misfits
- property rax
Return vectors perpendicular to both planar and linear parts of pairs as Vector3Set
- property ortensor
Return Lisle (1989) orientation tensor
OrientationTensor3
of orientations defined by pairs
- label()
Return label
- classmethod random(n=25)
Create PairSet of random pairs
- classmethod from_csv(filename, delimiter=',', facol=0, ficol=1, lacol=2, licol=3)
Read
PairSet
from csv file
- to_csv(filename, delimiter=',')
Save
PairSet
object to csv file- Parameters
filename (str) – name of CSV file to save.
- Keyword Arguments
delimiter (str) – values delimiter. Default ‘,’
Note: Written values are rounded according to ndigits settings in apsg_conf
- classmethod from_array(fazis, fincs, lazis, lincs, name='Default')
Create
PairSet
from arrays of azimuths and inclinations- Parameters
azis – list or array of azimuths
incs – list or array of inclinations
- Keyword Arguments
name – name of
PairSet
object. Default is ‘Default’
- class apsg.feature.FaultSet(data, name='Default')
Bases:
PairSet
Class to store set of
Fault
features- property sense
Return array of sense values
- property p_vector
Return p-axes of FaultSet as Vector3Set
- property t_vector
Return t-axes of FaultSet as Vector3Set
- property p
Return p-axes of FaultSet as LineationSet
- property t
Return t-axes of FaultSet as LineationSet
- property m
Return m-planes of FaultSet as FoliationSet
- property d
Return dihedra planes of FaultSet as FoliationSet
- classmethod random(n=25)
Create PairSet of random pairs
- classmethod from_csv(filename, delimiter=',', facol=0, ficol=1, lacol=2, licol=3, scol=4)
Read
FaultSet
from csv file
- to_csv(filename, delimiter=',')
Save
FaultSet
object to csv file- Parameters
filename (str) – name of CSV file to save.
- Keyword Arguments
delimiter (str) – values delimiter. Default ‘,’
Note: Written values are rounded according to ndigits settings in apsg_conf
- classmethod from_array(fazis, fincs, lazis, lincs, senses, name='Default')
Create
PairSet
from arrays of azimuths and inclinations- Parameters
azis – list or array of azimuths
incs – list or array of inclinations
- Keyword Arguments
name – name of
PairSet
object. Default is ‘Default’
- class apsg.feature.ConeSet(data, name='Default')
Bases:
FeatureSet
Class to store set of
Cone
features
- class apsg.feature.EllipseSet(data, name='Default')
Bases:
FeatureSet
Class to store set of
Ellipse
features- property S1: ndarray
Return the array of maximum principal stretches.
- property S2: ndarray
Return the array of minimum principal stretches.
- property e1: ndarray
Return the maximum natural principal strains.
- property e2: ndarray
Return the array of minimum natural principal strains.
- property ar: ndarray
Return the array of axial ratios.
- property orientation: ndarray
Return the array of orientations of the maximum eigenvector.
- property e12: ndarray
Return the array of differences between natural principal strains.
- class apsg.feature.EllipsoidSet(data, name='Default')
Bases:
FeatureSet
Class to store set of
Ellipsoid
features- property strength: ndarray
Return the array of the Woodcock strength.
- property shape: ndarray
Return the array of the Woodcock shape.
- property S1: ndarray
Return the array of maximum principal stretches.
- property S2: ndarray
Return the array of middle principal stretches.
- property S3: ndarray
Return the array of minimum principal stretches.
- property e1: ndarray
Return the array of the maximum natural principal strain.
- property e2: ndarray
Return the array of the middle natural principal strain.
- property e3: ndarray
Return the array of the minimum natural principal strain.
- property Rxy: ndarray
Return the array of the Rxy ratios.
- property Ryz: ndarray
Return the array of the Ryz ratios.
- property e12: ndarray
Return the array of the e1 - e2 values.
- property e13: ndarray
Return the array of the e1 - e3 values.
- property e23: ndarray
Return the array of the e2 - e3 values.
- property k: ndarray
Return the array of the strain symmetries.
- property d: ndarray
Return the array of the strain intensities.
- property K: ndarray
Return the array of the strain symmetries K (Ramsay, 1983).
- property D: ndarray
Return the array of the strain intensities D (Ramsay, 1983)..
- property r: ndarray
Return the array of the strain intensities (Watterson, 1968).
- property goct: ndarray
Return the array of the natural octahedral unit shears (Nadai, 1963).
- property eoct: ndarray
Return the array of the natural octahedral unit strains (Nadai, 1963).
- property lode: ndarray
Return the array of Lode parameters (Lode, 1926).
- property P: ndarray
Return the array of Point indexes (Vollmer, 1990).
- property G: ndarray
Return the array of Girdle indexes (Vollmer, 1990).
- property R: ndarray
Return the array of Random indexes (Vollmer, 1990).
- property B: ndarray
Return the array of Cylindricity indexes (Vollmer, 1990).
- property Intensity: ndarray
Return the array of Intensity indexes (Lisle, 1985).
- property aMAD_l: ndarray
Return approximate angular deviation from the major axis along E1.
- property aMAD_p: ndarray
Return approximate deviation from the plane normal to E3.
- property aMAD: ndarray
Return approximate deviation according to the shape
- property MAD_l: ndarray
Return maximum angular deviation (MAD) of linearly distributed vectors. Kirschvink 1980
- property MAD_p: ndarray
Return maximum angular deviation (MAD) of planarly distributed vectors. Kirschvink 1980
- property MAD: ndarray
Return approximate deviation according to shape
- class apsg.feature.OrientationTensor2Set(data, name='Default')
Bases:
EllipseSet
Class to store set of
OrientationTensor2
features
- class apsg.feature.OrientationTensor3Set(data, name='Default')
Bases:
EllipsoidSet
Class to store set of
OrientationTensor3
features
- apsg.feature.G(lst, name='Default')
Function to create appropriate container (FeatueSet) from list of features.
- Parameters
lst (list) – Homogeneous list of objects of
Vector2
,Vector3
,Lineation
,Foliation
,Pair
,Cone
,Ellipse
orOrientationTensor3
.- Keyword Arguments
name (str) – name of feature set. Default Default
Example
>>> fols = [fol(120,30), fol(130, 40), fol(126, 37)] >>> f = G(fols)
- class apsg.feature.ClusterSet(d, **kwargs)
Bases:
object
Provides a hierarchical clustering using scipy.cluster routines. The distance matrix is calculated as an angle between features, where
Foliation
andLineation
use axial angles whileVector3
uses direction angles.- cluster(**kwargs)
Do clustering on data
Result is stored as tuple of Groups in
groups
property.- Keyword Arguments
maxclust – number of clusters
distance – maximum cophenetic distance in clusters
- linkage(**kwargs)
Do linkage of distance matrix
- Keyword Arguments
method – The linkage algorithm to use
- dendrogram(**kwargs)
Show dendrogram
See
scipy.cluster.hierarchy.dendrogram
for possible kwargs.
- elbow(no_plot=False, n=None)
Plot within groups variance vs. number of clusters. Elbow criterion could be used to determine number of clusters.
- property R
Return group of clusters resultants.
- class apsg.feature.Core(**kwargs)
Bases:
object
Core
class to store palemomagnetic analysis data- Keyword Arguments
info –
specimen –
filename –
alpha –
beta –
strike –
dip –
volume –
date –
steps –
a95 –
comments –
vectors –
- Returns
Core
object instance
- classmethod from_pmd(filename)
Return
Core
instance generated from PMD file.- Parameters
filename – PMD file
- write_pmd(filename=None)
Save
Core
instance to PMD file.- Parameters
filename – PMD file
- classmethod from_rs3(filename, exclude=['C', 'G'])
Return
Core
instance generated from PMD file.- Parameters
filename – Remasoft rs3 file
- Kwargs:
exclude: Labels to be excluded. Default [‘C’, ‘G’]
- write_rs3(filename=None)
Save
Core
instance to RS3 file.- Parameters
filename – RS3 file
- property datatable
Return data list of strings
- show()
Show data
- property MAG
Returns numpy array of MAG values
- property nsteps
Returns steps as numpy array of numbers
- property V
Returns
Vector3Set
of vectors in sample (or core) coordinates system
- property geo
Returns
Vector3Set
of vectors in in-situ coordinates system
- property tilt
Returns
Vector3Set
of vectors in tilt‐corrected coordinates system
- pca(kind='geo', origin=False)
PCA analysis to calculate principal component and MAD
- Keyword Arguments
kind (str) – “V”, “geo” or “tilt”. Default “geo”
origin (bool) – Whether to include origin. Default False
plotting module
Classes:
|
Plot features on stereographic projection |
|
The class to store values with associated uniformly positions. |
|
|
|
Represents the triangular fabric plot (Vollmer, 1989). |
|
Represents the Ramsay deformation plot. |
|
Represents the Ramsay deformation plot. |
|
Represents the Hsu fabric plot. |
Functions:
|
Function to quickly show or save |
- class apsg.plotting.StereoNet(**kwargs)
Bases:
object
Plot features on stereographic projection
- Keyword Arguments
title (str) – figure title. Default None.
title_kws (dict) – dictionary of keyword arguments passed to matplotlib suptitle method.
tight_layout (bool) – Matplotlib figure tight_layout. Default False
kind (str) – Equal area (“equal-area”, “schmidt” or “earea”) or equal angle (“equal-angle”, “wulff” or “eangle”) projection. Default is “equal-area”
hemisphere (str) – “lower” or “upper”. Default is “lower”
overlay_position (tuple or Pair) – Position of overlay X, Y, Z given by Pair. X is direction of linear element, Z is normal to planar. Default is (0, 0, 0, 0)
rotate_data (bool) – Whether data should be rotated together with overlay. Default False
minor_ticks (None or float) – Default None
major_ticks (None or float) – Default None
overlay (bool) – Whether to show overlay. Default is True
overlay_step (float) – Grid step of overlay. Default 15
overlay_resolution (float) – Resolution of overlay. Default 181
clip_pole (float) – Clipped cone around poles. Default 15
grid_type (str) – Type of contouring grid “gss” or “sfs”. Default “gss”
grid_n (int) – Number of counting points in grid. Default 3000
Examples
>>> l = linset.random_fisher(position=lin(120, 40)) >>> s = StereoNet(title="Random linear features") >>> s.contour(l) >>> s.line(l) >>> s.show()
- clear()
Clear plot
- to_json()
Return stereonet as JSON dict
- classmethod from_json(json_dict)
Create stereonet from JSON dict
- save(filename)
Save stereonet to pickle file
- Parameters
filename (str) – name of picke file
- classmethod load(filename)
Load stereonet from pickle file
- Parameters
filename (str) – name of picke file
- render2fig(fig)
Plot stereonet to already existing figure or subfigure
- Parameters
fig (Figure) – A mtplotlib Figure artist
- format_coord(x, y)
Format stereonet coordinates
- show()
Show stereonet
- savefig(filename='stereonet.png', **kwargs)
Save stereonet figure to graphics file
- Keyword Arguments
filename (str) – filename
All others kwargs are passed to matplotlib Figure.savefig
- line(*args, **kwargs)
Plot linear feature(s) as point(s)
- Parameters
feature (Vector3 or Vector3Set like) –
- Keyword Arguments
alpha (scalar) – Set the alpha value. Default None
color (color) – Set the color of the point. Default None
mec (color) – Set the edge color. Default None
mfc (color) – Set the face color. Default None
mew (float) – Set the marker edge width. Default 1
ms (float) – Set the marker size. Default 6
marker (str) – Marker style string. Default “o”
ls (str) – Line style string (only for multiple features). Default None
- pole(*args, **kwargs)
Plot pole of planar feature(s) as point(s)
- Parameters
feature (Foliation or FoliationSet) –
- Keyword Arguments
alpha (scalar) – Set the alpha value. Default None
color (color) – Set the color of the point. Default None
mec (color) – Set the edge color. Default None
mfc (color) – Set the face color. Default None
mew (float) – Set the marker edge width. Default 1
ms (float) – Set the marker size. Default 6
marker (str) – Marker style string. Default “o”
ls (str) – Line style string (only for multiple features). Default None
- vector(*args, **kwargs)
Plot vector feature(s) as point(s)
Note: Markers are filled on lower and open on upper hemisphere.
- Parameters
feature (Vector3 or Vector3Set like) –
- Keyword Arguments
alpha (scalar) – Set the alpha value. Default None
color (color) – Set the color of the point. Default None
mec (color) – Set the edge color. Default None
mfc (color) – Set the face color. Default None
mew (float) – Set the marker edge width. Default 1
ms (float) – Set the marker size. Default 6
marker (str) – Marker style string. Default “o”
ls (str) – Line style string (only for multiple features). Default None
- scatter(*args, **kwargs)
Plot vector-like feature(s) as point(s)
- Note: This method is using scatter plot to allow variable colors
or sizes of points
- Parameters
feature (Vector3 or Vector3Set like) –
- Keyword Arguments
s (list or array) –
c (list or array) –
alpha (scalar) – Set the alpha value. Default None
linewidths (float) – The linewidth of the marker edges. Default 1.5
marker (str) – Marker style string. Default “o”
cmap (str) – Mtplotlib colormap. Default None
legend (bool) – Whether to show legend. Default False
num (int) – NUmber of legend items. Default “auto”
- great_circle(*args, **kwargs)
Plot planar feature(s) as great circle(s)
Note:
great_circle
has also aliasgc
- Parameters
feature (Foliation or FoliationSet) –
- Keyword Arguments
alpha (scalar) – Set the alpha value. Default None
color (color) – Set the color of the point. Default None
ls (str) – Line style string (only for multiple features). Default “-”
lw (float) – Set line width. Default 1.5
- gc(*args, **kwargs)
Plot planar feature(s) as great circle(s)
Note:
great_circle
has also aliasgc
- Parameters
feature (Foliation or FoliationSet) –
- Keyword Arguments
alpha (scalar) – Set the alpha value. Default None
color (color) – Set the color of the point. Default None
ls (str) – Line style string (only for multiple features). Default “-”
lw (float) – Set line width. Default 1.5
- arc(*args, **kwargs)
Plot arc bewtween vectors along great circle(s)
Note: You should pass several features in connection order
- Parameters
feature (Vector3 or Vector3Set like) –
- Keyword Arguments
alpha (scalar) – Set the alpha value. Default None
color (color) – Set the color of the point. Default None
ls (str) – Line style string (only for multiple features). Default “-”
lw (float) – Set line width. Default 1.5
- pair(*args, **kwargs)
Plot pair feature(s) as great circle and point
- Parameters
- Keyword Arguments
alpha (scalar) – Set the alpha value. Default None
color (color) – Set the color of the point. Default None
ls (str) – Line style string (only for multiple features). Default “-”
lw (float) – Set line width. Default 1.5
line_marker (str) – Marker style string for point. Default “o”
- fault(*args, **kwargs)
Plot fault feature(s) as great circle and arrow
Note: Arrow is styled according to default arrow config
- hoeppner(*args, **kwargs)
Plot fault feature(s) on Hoeppner (tangent lineation) plot
Note: Arrow is styled according to default arrow config
- arrow(*args, **kwargs)
Plot arrow at position of first argument and oriented in direction of second
Note: You should pass two features
- Parameters
feature (Vector3 or Vector3Set like) –
- Keyword Arguments
color (color) – Set the color of the arrow. Default None
width (int) – Width of arrow. Default 2
headwidth (int) – Width of arrow head. Default 5
pivot (str) – Arrow pivot. Default “mid”
units (str) – Arrow size units. Default “dots”
- tensor(*args, **kwargs)
Plot principal planes or principal directions of tensor
- Parameters
feature (OrientationTensor3 like) –
- Keyword Arguments
planes (bool) – When True, plot principal planes, otherwise principal directions. Default True
alpha (scalar) – Set the alpha value. Default None
color (color) – Set the color. Default is red, green, blue for s1, s2, s3
ls (str) – Line style string (only for multiple features). Default “-”
lw (float) – Set line width. Default 1.5
mew (float) – Set the marker edge width. Default 1
ms (float) – Set the marker size. Default 9
marker (str) – Marker style string. Default “o”
- contour(*args, **kwargs)
Plot filled contours using modified Kamb contouring technique with exponential smoothing.
- Parameters
feature (Vector3Set like) –
- Keyword Arguments
levels (int or list) – number or values of contours. Default 6
cmap – matplotlib colormap used for filled contours. Default “Greys”
colorbar (bool) – Show colorbar. Default False
alpha (float) – transparency. Default None
antialiased (bool) – Default True
sigma (float) – If None it is automatically calculated
sigmanorm (bool) – If True scaled counts are normalized by sigma. Default True
trimzero (bool) – Remove values equal to 0. Default True
clines (bool) – Show contour lines instead filled contours. Default False
linewidths (float) – contour lines width
linestyles (str) – contour lines style
show_data (bool) – Show data as points. Default False
data_kws (dict) – arguments passed to point factory when show_data True
- class apsg.plotting.StereoGrid(**kwargs)
Bases:
object
The class to store values with associated uniformly positions.
StereoGrid
is used to calculate continous functions on sphere e.g. density distribution.- Keyword Arguments
kind (str) – Equal area (“equal-area”, “schmidt” or “earea”) or equal angle (“equal-angle”, “wulff” or “eangle”) projection. Default is “equal-area”
hemisphere (str) – “lower” or “upper”. Default is “lower”
overlay_position (tuple or Pair) – Position of overlay X, Y, Z given by Pair. X is direction of linear element, Z is normal to planar. Default is (0, 0, 0, 0)
rotate_data (bool) – Whether data should be rotated together with overlay. Default False
minor_ticks (None or float) – Default None
major_ticks (None or float) – Default None
overlay (bool) – Whether to show overlay. Default is True
overlay_step (float) – Grid step of overlay. Default 15
overlay_resolution (float) – Resolution of overlay. Default 181
clip_pole (float) – Clipped cone around poles. Default 15
grid_type (str) – Type of contouring grid “gss” or “sfs”. Default “gss”
grid_n (int) – Number of counting points in grid. Default 3000
Note: Euclidean norms are used as weights. Normalize data if you dont want to use weigths.
- min()
Returns minimum value of the grid
- max()
Returns maximum value of the grid
- min_at()
Returns position of minimum value of the grid as
Lineation
- max_at()
Returns position of maximum value of the grid as
Lineation
- calculate_density(features, **kwargs)
Calculate density distribution of vectors from
FeatureSet
object.The modified Kamb contouring technique with exponential smoothing is used.
- Parameters
sigma (float) – if none sigma is calculated automatically. Default None
sigmanorm (bool) – If True counting is normalized to sigma multiples. Default True
trimzero – if True, zero contour is not drawn. Default True
- density_lookup(v)
Calculate density distribution value at position given by vector
Note: you need to calculate density before using this method
- Parameters
v – Vector3 like object
- Keyword Arguments
p (int) – power. Default 2
- apply_func(func, *args, **kwargs)
Calculate values of user-defined function on sphere.
Function must accept Vector3 like (or 3 elements array) as first argument and return scalar value.
- Parameters
func (function) – function used to calculate values
*args – passed to function func as args
**kwargs – passed to function func as kwargs
- contourf(*args, **kwargs)
Draw filled contours of values using tricontourf.
- Keyword Arguments
levels (int or list) – number or values of contours. Default 6
cmap – matplotlib colormap used for filled contours. Default “Greys”
colorbar (bool) – Show colorbar. Default False
alpha (float) – transparency. Default None
antialiased (bool) – Default True
- contour(*args, **kwargs)
Draw contour lines of values using tricontour.
- Keyword Arguments
levels (int or list) – number or values of contours. Default 6
cmap – matplotlib colormap used for filled contours. Default “Greys”
colorbar (bool) – Show colorbar. Default False
alpha (float) – transparency. Default None
antialiased (bool) – Default True
linewidths (float) – contour lines width
linestyles (str) – contour lines style
- plotcountgrid(**kwargs)
Show counting grid.
- angmech(faults, **kwargs)
Implementation of Angelier-Mechler dihedra method
- Parameters
faults –
FaultSet
of data
- Kwargs:
method: ‘probability’ or ‘classic’. Classic method assigns +/-1 to individual positions, while ‘probability’ returns maximum likelihood estimate. Other kwargs are passed to contourf
- class apsg.plotting.RosePlot(**kwargs)
Bases:
object
RosePlot
class for rose histogram plotting.- Keyword Arguments
title (str) – figure title. Default None
title_kws (dict) – dictionary of keyword arguments passed to matplotlib suptitle method.
bins (int) – Number of bins. Default 36
axial (bool) – Directional data are axial. Defaut True
density (bool) – Use density instead of counts. Default False
pdf (bool) – Plot Von Mises density function instead histogram. Default False
pdf_res (int) – Resolution of pdf. Default 901
kappa (float) – Shape parameter of Von Mises pdf. Default 250
scaled (bool) – Bins scaled by area instead value. Default False
ticks (bool) – show ticks. Default True
grid (bool) – show grid lines. Default False
grid_kws (dict) – Dict passed to Axes.grid. Default {}
plot. (Other keyword arguments are passed to matplotlib) –
Examples
>>> v = vec2set.random_vonmises(position=120) >>> p = RosePlot(grid=False) >>> p.pdf(v) >>> p.bar(v, fc='none', ec='k', lw=1) >>> p.muci(v) >>> p.show()
- clear()
Clear plot
- to_json()
Return rose plot as JSON dict
- classmethod from_json(json_dict)
Create rose plot from JSON dict
- save(filename)
Save stereonet to pickle file
- Parameters
filename (str) – name of picke file
- classmethod load(filename)
Load stereonet from pickle file
- Parameters
filename (str) – name of picke file
- render2fig(fig)
Plot stereonet to already existing figure or subfigure
- Parameters
fig (Figure) – A mtplotlib Figure artist
- show()
Show rose plot
- savefig(filename='roseplot.png', **kwargs)
Save rose plot figure to graphics file
- Keyword Arguments
filename (str) – filename
All others kwargs are passed to matplotlib Figure.savefig
- bar(*args, **kwargs)
Plot rose histogram of angles
- Parameters
feature (Vector2Set) –
- Keyword Arguments
alpha (scalar) – Set the alpha value. Default None
color (color) – Set the color of the point. Default None
ec (color) – Patch edge color. Default None
fc (color) – Patch face color. Default None
ls (str) – Line style string (only for multiple features). Default “-”
lw (float) – Set line width. Default 1.5
legend (bool) – Whether to show legend. Default False
- pdf(*args, **kwargs)
Plot Von Mises probability density function from angles
- Parameters
feature (Vector2Set) –
- Keyword Arguments
alpha (scalar) – Set the alpha value. Default None
color (color) – Set the color of the point. Default None
ec (color) – Patch edge color. Default None
fc (color) – Patch face color. Default None
ls (str) – Line style string (only for multiple features). Default “-”
lw (float) – Set line width. Default 1.5
legend (bool) – Whether to show legend. Default False
weight (float) – Factor to scale probability density function Default 1
- muci(*args, **kwargs)
Plot circular mean with bootstrapped confidence interval
- Parameters
feature (Vector2Set) –
- Keyword Arguments
alpha (scalar) – Set the alpha value. Default None
color (color) – Set the color of the point. Default None
ls (str) – Line style string (only for multiple features). Default “-”
lw (float) – Set line width. Default 1.5
confidence_level (float) – Confidence interval. Default 95
n_resamples (int) – Number of bootstrapped samples. Default 9999
- class apsg.plotting.VollmerPlot(*args, **kwargs)
Bases:
FabricPlot
Represents the triangular fabric plot (Vollmer, 1989).
- Keyword Arguments
title (str) – figure title. Default None.
title_kws (dict) – dictionary of keyword arguments passed to matplotlib suptitle method.
ticks (bool) – Show ticks. Default True
n_ticks (int) – Number of ticks. Default 10
tick_size (float) – Size of ticks. Default 0.2
margin (float) – Size of margin. Default 0.05
grid (bool) – Show grid. Default is True
grid_color (str) – Matplotlib color of the grid. Default “k”
grid_style (str) – Matplotlib style of the grid. Default “:”
Examples
>>> l = linset.random_fisher(position=lin(120, 40)) >>> ot = l.ortensor() >>> s = VollmerPlot(title="Point distribution") >>> s.point(ot) >>> s.show()
- point(*args, **kwargs)
Plot ellipsoid as point
- path(*args, **kwargs)
Plot EllipsoidSet as path
- class apsg.plotting.RamsayPlot(*args, **kwargs)
Bases:
FabricPlot
Represents the Ramsay deformation plot.
- Keyword Arguments
title (str) – figure title. Default None.
title_kws (dict) – dictionary of keyword arguments passed to matplotlib suptitle method.
ticks (bool) – Show ticks. Default True
n_ticks (int) – Number of ticks. Default 10
tick_size (float) – Size of ticks. Default 0.2
margin (float) – Size of margin. Default 0.05
grid (bool) – Show grid. Default is True
grid_color (str) – Matplotlib color of the grid. Default “k”
grid_style (str) – Matplotlib style of the grid. Default “:”
Examples
>>> l = linset.random_fisher(position=lin(120, 40)) >>> ot = l.ortensor() >>> s = RamsayPlot(title="Point distribution") >>> s.point(ot) >>> s.show()
- point(*args, **kwargs)
Plot ellipsoid as point
- path(*args, **kwargs)
Plot EllipsoidSet as path
- class apsg.plotting.FlinnPlot(*args, **kwargs)
Bases:
FabricPlot
Represents the Ramsay deformation plot.
- Keyword Arguments
title (str) – figure title. Default None.
title_kws (dict) – dictionary of keyword arguments passed to matplotlib suptitle method.
ticks (bool) – Show ticks. Default True
n_ticks (int) – Number of ticks. Default 10
tick_size (float) – Size of ticks. Default 0.2
margin (float) – Size of margin. Default 0.05
grid (bool) – Show grid. Default is True
grid_color (str) – Matplotlib color of the grid. Default “k”
grid_style (str) – Matplotlib style of the grid. Default “:”
Examples
>>> l = linset.random_fisher(position=lin(120, 40)) >>> ot = l.ortensor() >>> s = FlinnPlot(title="Point distribution") >>> s.point(ot) >>> s.show()
- point(*args, **kwargs)
Plot Ellipsoid as point
- path(*args, **kwargs)
Plot EllipsoidSet as path
- class apsg.plotting.HsuPlot(*args, **kwargs)
Bases:
FabricPlot
Represents the Hsu fabric plot.
- Keyword Arguments
title (str) – figure title. Default None.
title_kws (dict) – dictionary of keyword arguments passed to matplotlib suptitle method.
ticks (bool) – Show ticks. Default True
n_ticks (int) – Number of ticks. Default 10
tick_size (float) – Size of ticks. Default 0.2
margin (float) – Size of margin. Default 0.05
grid (bool) – Show grid. Default is True
grid_color (str) – Matplotlib color of the grid. Default “k”
grid_style (str) – Matplotlib style of the grid. Default “:”
Examples
>>> l = linset.random_fisher(position=lin(120, 40)) >>> ot = l.ortensor() >>> s = HsuPlot(title="Point distribution") >>> s.point(ot) >>> s.show()
- point(*args, **kwargs)
Plot Ellipsoid as point
- path(*args, **kwargs)
Plot EllipsoidSet as path
- apsg.plotting.quicknet(*args, **kwargs)
Function to quickly show or save
StereoNet
from args- Parameters
args – object(s) to be plotted. Instaces of
Vector3
,Foliation
,Lineation
,Pair
,Fault
,Cone
,Vector3Set
,FoliationSet
,LineationSet
,PairSet
orFaultSet
.- Keyword Arguments
savefig (bool) – True to save figure. Default False
filename (str) – filename for figure. Default stereonet.png
savefig_kwargs (dict) – dict passed to
plt.savefig
fol_as_pole (bool) – True to plot planar features as poles, False for plotting as great circle. Default True
Example
>>> l = linset.random_fisher(position=lin(120, 50)) >>> f = folset.random_fisher(position=lin(300, 40)) >>> quicknet(f, l, fol_as_pole=False)
pandas module
This module provide basic integration with pandas.
Classes:
|
Base class of DataFrame accessors provides methods for FeatureSet |
|
apsg DataFrame accessor to create aspg columns from data |
|
vec DataFrame accessor provides methods for Vector3Set |
|
fol DataFrame accessor provides methods for FoliationSet |
|
lin DataFrame accessor provides methods for LineationSet |
|
fault DataFrame accessor provides methods for FaultSet |
|
Custom Extension Array type for an array of Vector3 |
|
Custom Extension Array type for an array of fols |
|
Custom Extension Array type for an array of lins |
|
Custom Extension Array type for an array of faults |
- class apsg.pandas.VectorSetBaseAccessor(pandas_obj)
Bases:
object
Base class of DataFrame accessors provides methods for FeatureSet
- property getset
Get
FeatureSet
- R()
Return resultant of data in
FeatureSet
.
- fisher_k()
Precision parameter based on Fisher’s statistics
- fisher_csd()
Angular standard deviation based on Fisher’s statistics
- fisher_a95()
95% confidence limit based on Fisher’s statistics
- var()
Spherical variance based on resultant length (Mardia 1972).
var = 1 - abs(R) / n
- delta()
Cone angle containing ~63% of the data in degrees.
For enough large sample it approach angular standard deviation (csd) of Fisher statistics
- rdegree()
Degree of preffered orientation of vectors in
FeatureSet
.D = 100 * (2 * abs(R) - n) / n
- ortensor()
Return orientation tensor
Ortensor
of vectors inFeatureSet
.
- contour(snet=None, **kwargs)
Plot data contours on StereoNet
- class apsg.pandas.APSGAccessor(pandas_obj)
Bases:
object
apsg DataFrame accessor to create aspg columns from data
- create_vecs(columns=['x', 'y', 'z'], name='vecs')
Create column with Vector3 features
- Keyword Arguments
columns (list) – Columns containing either x, y and z components or azi and inc. Default [“x”, “y”, “z”]
name (str) – Name of created column. Default ‘vecs’
- create_fols(columns=['azi', 'inc'], name='fols')
Create column with Foliation features
- Keyword Arguments
columns (list) – Columns containing azi and inc. Default [“azi”, “inc”]
name (str) – Name of created column. Default ‘fols’
- create_lins(columns=['azi', 'inc'], name='lins')
Create column with Lineation features
- Keyword Arguments
columns (list) – Columns containing azi and inc. Default [“azi”, “inc”]
name (str) – Name of created column. Default ‘lins’
- create_faults(columns=['fazi', 'finc', 'lazi', 'linc', 'sense'], name='faults')
Create column with Fault features
- Keyword Arguments
columns (list) – Columns containing azi and inc. Default [‘fazi’, ‘finc’, ‘lazi’, ‘linc’, ‘sense’]
name (str) – Name of created column. Default ‘lins’
- class apsg.pandas.Vec3Accessor(pandas_obj)
Bases:
VectorSetBaseAccessor
vec DataFrame accessor provides methods for Vector3Set
- plot(snet=None, **kwargs)
Plot vecs as vectors on StereoNet
- class apsg.pandas.FolAccessor(pandas_obj)
Bases:
VectorSetBaseAccessor
fol DataFrame accessor provides methods for FoliationSet
- plot(snet=None, aspole=False, **kwargs)
Plot fols as great circles on StereoNet
- class apsg.pandas.LinAccessor(pandas_obj)
Bases:
VectorSetBaseAccessor
lin DataFrame accessor provides methods for LineationSet
- plot(snet=None, **kwargs)
Plot lins as line on StereoNet
- class apsg.pandas.FaultAccessor(pandas_obj)
Bases:
object
fault DataFrame accessor provides methods for FaultSet
- property getset
Get
FeatureSet
- plot(snet=None, **kwargs)
Plot vecs as vectors on StereoNet
- class apsg.pandas.Vector3Array(vecs)
Bases:
ExtensionArray
Custom Extension Array type for an array of Vector3
- property dtype
Return Dtype instance (not class) associated with this Array
- property nbytes
The number of bytes needed to store this object in memory.
- isna()
Returns a 1-D array indicating if each value is missing
- take(indices, *, allow_fill=False, fill_value=None)
Take element from array using positional indexing
- copy()
Return copy of array
- class apsg.pandas.FolArray(fols)
Bases:
Vector3Array
Custom Extension Array type for an array of fols
- property dtype
Return Dtype instance (not class) associated with this Array
- class apsg.pandas.LinArray(lins)
Bases:
Vector3Array
Custom Extension Array type for an array of lins
- property dtype
Return Dtype instance (not class) associated with this Array
- class apsg.pandas.FaultArray(faults)
Bases:
Vector3Array
Custom Extension Array type for an array of faults
- property dtype
Return Dtype instance (not class) associated with this Array
database module
sqlalchemy interface to PySDB database
PySDB database is a simple sqlite3-based relational database to store structural data from the field. You can use apsg to manipulate the data or you can use the GUI application pysdb. There is also the QGIS plugin readsdb to plot data on a map or use map-based select to plot stereonets.
The following snippet demonstrate how to create database programmatically
>>> # Create database
>>> from apsg.database import SDBSession
>>> db = SDBSession('database.sdb', create=True)
>>> # Create unit
>>> unit = db.unit(name='DMU', description='Deamonic Magmatic Unit')
>>> # Create site
>>> site = db.site(unit=unit, name='LX001', x_coord=25934.36, y_coord=564122.5, description='diorite dyke')
>>> # Create structural types
>>> S2 = db.structype(structure='S2', description='Solid-state foliation', planar=1)
>>> L2 = db.structype(structure='L2', description='Solid-state lineation', planar=0)
>>> # Add measurement
>>> fol = db.add_structdata(site=site, structype=S2, azimuth=150, inclination=36)
>>> # Close database
>>> db.close()
You can tag individual data
>>> db = SDBSession('database.sdb')
>>> site = db.site(name='LX001')
>>> struct = db.structype(structure='S2')
>>> tag_plot = db.tag(name='plot')
>>> tag_ap = db.tag(name='AP')
>>> fol = db.add_structdata(site=site, structype=struct, azimuth=324, inclination=78, tags=[tag_plot, tag_ap])
>>> db.close()
or you can attach linear and planar features (e.g. fault data)
>>> db = SDBSession('database.sdb')
>>> unit = db.unit(name='DMU')
>>> site = db.site(name='LX001')
>>> S = db.structype(structure='S')
>>> L = db.structype(structure='L')
>>> fol = db.add_structdata(site=site, structype=S, azimuth=220, inclination=28)
>>> lin = db.add_structdata(site=site, structype=L, azimuth=212, inclination=26)
>>> pair = db.attach(fol, lin)
>>> db.close()
You can open existing database and select existing site and type of structure
>>> db = SDBSession('database.sdb')
>>> site = db.site(name='LX003')
>>> S2 = db.structype(structure='S2')
>>> L2 = db.structype(structure='L2')
and insert Foliation
, Lineation
or Pair
directly
>>> f = fol(196, 39)
>>> l = lin(210, 37)
>>> db.add_fol(f, site=site, structype=S2)
>>> db.add_lin(l, site=site, structype=L2)
>>> p = Pair(258, 42, 220, 30)
>>> db.add_pair(p, S2, L2, site=site)
>>> db.close()
To retrieve data as FeatureSet
you can use getset
method:
>>> db = SDBSession('database.sdb')
>>> S2 = db.structype(structure='S2')
>>> g = db.getset(structype=S2)
or directly
>>> g = db.getset('S2')
Classes:
|
SqlAlchemy interface to PySDB database |
|
|
|
|
|
|
|
|
|
|
|
|
|
sqlite3 based read-only interface to PySDB database |
- class apsg.database.SDBSession(sdb_file, **kwargs)
Bases:
object
SqlAlchemy interface to PySDB database
- Parameters
sdbfile (str) – filename of PySDB database
- Keyword Arguments
create (bool) – if True existing sdbfile will be deleted and new database will be created
autocommit (bool) – if True, each operation is autocommitted
Example
>>> db = SDBSession('database.sdb', create=True)
- close()
Close session
- commit()
commit session
- rollback()
rollback session
- meta(name, **kwargs)
Insert, update or retrieve (when kwargs empty) Meta
- Parameters
name (str) – meta name
- Keyword Arguments
value (str) – meta value
- Returns
Meta
- site(name, **kwargs)
Insert, update or retrieve (when kwargs empty) Site
- Parameters
name (str) – site name
- Keyword Arguments
x_coord (float) – x coord or longitude
y_coord (float) – y coord or latitude
description (str) – site description
unit (Unit) – unit instance (mus be provided)
- Returns
Site
- unit(name, **kwargs)
Insert, update or retrieve (when kwargs empty) Unit
- Parameters
name (str) – unit name
- Keyword Arguments
description (str) – unit description
- Returns
Unit
- tag(name, **kwargs)
Insert, update or retrieve (when kwargs empty) Tag
- Parameters
name (str) – tag name
- Keyword Arguments
description (str) – tag description
- Returns
Tag
- structype(structure, **kwargs)
Insert, update or retrieve (when kwargs empty) Structype
- Parameters
structure (str) – label for structure
- Keyword Arguments
description (str) – structype description
planar (int) – 1 for planar 0 for linear
structcode (int) – structcode (optional)
groupcode (int) – groupcode (optional)
- Returns
Structype
- add_structdata(site, structype, azimuth, inclination, **kwargs)
Add structdata to site
- add_fol(site, structype, fol, **kwargs)
Add Foliation to site
- add_lin(site, structype, lin, **kwargs)
Add Lineation to site
- attach(fol, lin)
Add Lineation to site
- add_pair(pair, foltype, lintype, **kwargs)
Add attached foliation and lineation to database
- sites(**kwargs)
Retrieve Site or list of Sites based on criteria in kwargs
Keyword arguments are passed to sqlalchemy filter_by method
- units(**kwargs)
Retrieve Unit or list of Units based on criteria in kwargs
Keyword arguments are passed to sqlalchemy filter_by method
- structypes(**kwargs)
Retrieve Structype or list of Structypes based on criteria in kwargs
Keyword arguments are passed to sqlalchemy filter_by method
- tags(**kwargs)
Retrieve Tag or list of Tags based on criteria in kwargs
Keyword arguments are passed to sqlalchemy filter_by method
- class apsg.database.Meta(*args: Any, **kwargs: Any)
Bases:
declarative_base
- class apsg.database.Site(*args: Any, **kwargs: Any)
Bases:
declarative_base
- class apsg.database.Structdata(*args: Any, **kwargs: Any)
Bases:
declarative_base
- class apsg.database.Structype(*args: Any, **kwargs: Any)
Bases:
declarative_base
- class apsg.database.Tag(*args: Any, **kwargs: Any)
Bases:
declarative_base
- class apsg.database.Unit(*args: Any, **kwargs: Any)
Bases:
declarative_base
- class apsg.database.SDB(sdb_file)
Bases:
object
sqlite3 based read-only interface to PySDB database
- Parameters
sdbfile (str) – filename of PySDB database
Example
>>> db = SDB('database.sdb')
- structures(**kwargs)
Return list of structures in database.
For kwargs see getset method
- sites(**kwargs)
Return list of sites in database.
For kwargs see getset method.
- units(**kwargs)
Return list of units in database.
For kwargs see getset method.
- tags(**kwargs)
Return list of tags in database.
For kwargs see getset method.
- getset(structs, **kwargs)
Method to retrieve data from SDB database to
FeatureSet
.- Parameters
structs (str) – structure or list of structures to retrieve
- Keyword Arguments
sites (str) – name or list of names of sites to retrieve from
units (str) – name or list of names of units to retrieve from
tags (str) – tag or list of tags to retrieve
labels (bool) – if True return also list of sites. Default False
math module
This module provide basic linear algebra classes.
Classes:
|
A class to represent a 3D vector. |
|
A class to represent a 3D axial vector. |
|
A class to represent a 2D vector. |
|
A class to represent a 2D axial vector. |
|
A class to represent a 3x3 matrix. |
|
A class to represent a 2x2 matrix. |
- class apsg.math.Vector3(*args)
Bases:
Vector
A class to represent a 3D vector.
There are different way to create
Vector3
object:without arguments create default
Vector3
(1, 0, 0)with single argument v, where
v could be Vector3-like object
v could be string ‘x’, ‘y’ or ‘z’ - principal axes of coordinate system
v could be tuple of (x, y, z) - vector components
with 2 arguments plunge direction and plunge
with 3 numerical arguments defining vector components
- Parameters
azi (float) – plunge direction of linear feature in degrees
inc (float) – plunge of linear feature in degrees
Example
>>> vec() >>> vec(1,2,-1) >>> vec('y') >>> vec(120, 30) >>> v = vec(1, -2, 1)
- property z
Return z-component of the vector
- normalized()
Returns normalized (unit length) vector
- uv()
Returns normalized (unit length) vector
- lower()
Change vector direction to point towards positive Z direction
- is_upper()
Return True if vector points towards negative Z direction
- property geo
Return tuple of plunge direction and signed plunge
- classmethod unit_x()
Create unit length vector in x-direction
- classmethod unit_y()
Create unit length vector in y-direction
- classmethod unit_z()
Create unit length vector in z-direction
- classmethod random()
Create random 3D vector
- transform(F, **kwargs)
Return affine transformation of vector u by matrix F.
- Parameters
F – transformation matrix
- Keyword Arguments
norm – normalize transformed vectors. [True or False] Default False
- Returns
vector representation of affine transformation (dot product) of self by F
Example
# Reflexion of y axis. >>> F = [[1, 0, 0], [0, -1, 0], [0, 0, 1]] >>> u = Vector3([1, 1, 1]) >>> u.transform(F) Vector3(1, -1, 1)
- class apsg.math.Axial3(*args)
Bases:
Vector3
A class to represent a 3D axial vector.
Note: the angle between axial data cannot be more than 90°
- class apsg.math.Vector2(*args)
Bases:
Vector
A class to represent a 2D vector.
There are different way to create
Vector2
object:without arguments create default
Vector2
(0, 0, 1)with single argument v, where
v could be Vector2-like object
v could be string ‘x’ or ‘y’ - principal axes of coordinate system
v could be tuple of (x, y) - vector components
v could be float - unit vector with given angle to ‘x’ axis
with 2 numerical arguments defining vector components
- Parameters
ang (float) – angle between ‘x’ axis and vector in degrees
Example
>>> vec2() >>> vec2(1, -1) >>> vec2('y') >>> vec2(50) >>> v = vec2(1, -2)
- normalized()
Returns normalized (unit length) vector
- uv()
Returns normalized (unit length) vector
- property direction
Returns direction of the vector in degrees
- classmethod random()
Random 2D vector
- classmethod unit_x()
Create unit length vector in x-direction
- classmethod unit_y()
Create unit length vector in y-direction
- transform(*args, **kwargs)
Return affine transformation of vector u by matrix F.
- Parameters
F – transformation matrix
- Keyword Arguments
norm – normalize transformed vectors. [True or False] Default False
- Returns
vector representation of affine transformation (dot product) of self by F
Example
# Reflexion of y axis. >>> F = [[1, 0], [0, -1]] >>> u = vec2([1, 1]) >>> u.transform(F) Vector2(1, -1)
- class apsg.math.Axial2(*args)
Bases:
Vector2
A class to represent a 2D axial vector.
Note: the angle between axial data cannot be more than 90°
- class apsg.math.Matrix3(*args)
Bases:
Matrix
A class to represent a 3x3 matrix.
There are different way to create
Matrix3
object:without arguments create default identity
Matrix3
with single argument of Matrix3-like object
- Parameters
v – 2-dimensional array-like object
Example
>>> Matrix3() Matrix3 [[1 0 0] [0 1 0] [0 0 1]] >>> A = Matrix3([[2, 1, 0], [0, 0.5, 0], [0, -0.5, 1]])
- classmethod from_comp(xx=1, xy=0, xz=0, yx=0, yy=1, yz=0, zx=0, zy=0, zz=1)
Return
Matrix3
defined by individual components. Default is identity tensor.- Keyword Arguments
xx (float) – tensor component M_xx
xy (float) – tensor component M_xy
xz (float) – tensor component M_xz
yx (float) – tensor component M_yx
yy (float) – tensor component M_yy
yz (float) – tensor component M_yz
zx (float) – tensor component M_zx
zy (float) – tensor component M_zy
zz (float) – tensor component M_zz
Example
>>> F = Matrix3.from_comp(xy=1, zy=-0.5) >>> F [[ 1. 1. 0. ] [ 0. 1. 0. ] [ 0. -0.5 1. ]]
- property xz
Return xz-element of the matrix
- property yz
Return yz-element of the matrix
- property zx
Return zx-element of the matrix
- property zy
Return zy-element of the matrix
- property zz
Return zz-element of the matrix
- property E3
Third eigenvalue
- property V3
Third eigenvector
- eigenvectors()
Return tuple of principal eigenvectors as
Vector3
objects.
- scaled_eigenvectors()
Return tuple of principal eigenvectors as
Vector3
objects with magnitudes of eigenvalues
- class apsg.math.Matrix2(*args)
Bases:
Matrix
A class to represent a 2x2 matrix.
There are different way to create
Matrix2
object:without arguments create default identity
Matrix2
with single argument of Matrix2-like object
- Parameters
v – 2-dimensional array-like object
Example
>>> Matrix2() Matrix2 [[1 0] [0 1]] >>> A = Matrix2([[2, 1],[0, 0.5]])
- classmethod from_comp(xx=1, xy=0, yx=0, yy=1)
Return
Matrix2
defined by individual components. Default is identity tensor.- Keyword Arguments
xx (float) – tensor component M_xx
xy (float) – tensor component M_xy
yx (float) – tensor component M_yx
yy (float) – tensor component M_yy
Example
>>> F = Matrix2.from_comp(xy=2) >>> F [[1. 2.] [0. 1.]]
- eigenvectors()
Return tuple of principal eigenvectors as
Vector3
objects.
- scaled_eigenvectors()
Return tuple of principal eigenvectors as
Vector3
objects with magnitudes of eigenvalues
helpers module
- apsg.helpers.sind(x)
Calculate sine of angle in degrees
- apsg.helpers.cosd(x)
Calculate cosine of angle in degrees
- apsg.helpers.tand(x)
Calculate tangent of angle in degrees
- apsg.helpers.acosd(x)
Calculate arc cosine in degrees
- apsg.helpers.asind(x)
Calculate arc sine in degrees
- apsg.helpers.atand(x)
Calculate arc tangent in degrees
- apsg.helpers.atan2d(y, x)
Calculate arc tangent in degrees in the range from pi to -pi.
- Parameters
y (float) – y coordinate
x (float) – x coordinate
- apsg.helpers.geo2vec_planar(*args)
Function to transform geological measurement of plane to normal vector
Conversion is done according to notation configuration
- Parameters
azi (float) – dip direction or strike
inc (float) – dip
- apsg.helpers.geo2vec_linear(*args)
Function to transform geological measurement of line to vector
- Parameters
azi (float) – plunge direction
inc (float) – plunge
Contributing
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions
Report Bugs
Report bugs at https://github.com/ondrolexa/apsg/issues.
If you are reporting a bug, please include:
Your operating system name and version.
Any details about your local setup that might be helpful in troubleshooting.
Detailed steps to reproduce the bug.
Fix Bugs
Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.
Implement Features
Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.
Write Documentation
APSG could always use more documentation, whether as part of the official APSG docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback
The best way to send feedback is to file an issue at https://github.com/ondrolexa/apsg/issues.
If you are proposing a feature:
Explain in detail how it would work.
Keep the scope as narrow as possible, to make it easier to implement.
Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!
Ready to contribute? Here’s how to set up apsg for local development.
Fork the apsg repo on GitHub.
Clone your fork locally with SSH or HTTPS:
$ git clone git@github.com:ondrolexa/apsg.git $ git clone https://github.com/ondrolexa/apsg.git
Install your local copy and activate the virtual environment via pipenv.
$ cd apsg/ $ pipenv shell $ pipenv install –dev
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 apsg tests $ python setup.py test $ tox
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines
Before you submit a pull request, check that it meets these guidelines:
The pull request should include tests.
If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
The pull request should work for Python 2.7, 3.5, and 3.6, and for PyPy. Check https://travis-ci.org/ondrolexa/apsg/pull_requests and make sure that the tests pass for all supported Python versions.
Credits
Development Lead
Ondrej Lexa <lexa.ondrej@gmail.com>
Contributors
David Landa <david.landa@natur.cuni.cz>