spam.orientations package#

Submodules#

spam.orientations.analyse module#

spam.orientations.analyse.fitVonMisesFisher(orientations, confVMF=None, confMu=None, confKappa=None)[source]#

This function fits a vonMises-Fisher distribution to a set of N 3D unit vectors. The distribution is characterised by a mean orientation mu and a spread parameter kappa.

Parameters:
  • orientations (Nx3 array of floats) – Z, Y and X components of each vector.

  • confVMF (float) – Confidence interval for the test on the vMF distribution Used for checking wheter the data can be modeled with a vMF distribution Default = 95%

  • confMu (float) – Confidence interval for the test on the mean orientation mu Used for computing the error on the mean orientation Default = 95%

  • confKappa (float) – Confidence interval for the test on kappa Used for computing the error on kappa Default = 95%

Returns:

Keys:
orientationsNx3 array of floats

Z, Y and X components of each vector that is located in the same quadrant as the mean orientation

mu1x3 array of floats

Z, Y and X components of mean orientation.

thetafloat

Inclination angle of the mean orientation in degrees - angle with the Z axis

alphafloat

Azimuth angle of the mean orientation in degrees - angle in the X-Y plane

Rfloat

Mean resultant length First order measure of concentration (ranging between 0 and 1)

kappaint

Spread of the distribution, must be > 0. Higher values of kappa mean a higher concentration along the main orientation

vectorsProjNx3 array of floats

Z, Y and X components of each vector projected along the mean orientation

fisherTestbool

Boolean representing the result of the test on the vMF distribution 1 = The data can be modeled with a vMF distribution 0 = The data cannot be modeled with a vMF distribution

fisherTestValfloat

Value to be compared against the critical value, taken from a Chi-squared distrition

muTestfloat

Error associated to the mean orientation Defined as the semi-vertical angle of the cone that comprises the distribution

kappaTest1x2 list of floats

Maximum and minimum value of kappa, given the confidence interval

Return type:

Dictionary containing

Notes

The calculation of kappa implemented from Tanabe, A., et al., (2007). Parameter estimation for von Mises_Fisher distributions. doi: 10.1007/s00180-007-0030-7

spam.orientations.analyse.meanOrientation(orientations)[source]#

This function performs a Singular Value Decomposition (SVD) on a series of 3D unit vectors to find the main direction of the set

Parameters:

orientations (Nx3 numpy array of floats) – Z, Y and X components of direction vectors. Non-unit vectors are normalised.

Returns:

orientationVector – Z, Y and X components of direction vector.

Return type:

1x3 numpy arrayRI*numpy.cos(thetaI) of floats

Notes

Implementation taken from https://www.ltu.se/cms_fs/1.51590!/svd-fitting.pdf

spam.orientations.analyse.fabricTensor(orientations)[source]#

Calculation of a second order fabric tensor from 3D unit vectors representing orientations

Parameters:

orientations (Nx3 array of floats) – Z, Y and X components of direction vectors Non-unit vectors are normalised.

Returns:

  • N (3x3 array of floats) – normalised second order fabric tensor with N[0,0] corresponding to z-z, N[1,1] to y-y and N[2,2] x-x

  • F (3x3 array of floats) – fabric tensor of the third kind (deviatoric part) with F[0,0] corresponding to z-z, F[1,1] to y-y and F[2,2] x-x

  • a (float) – scalar anisotropy factor based on the deviatoric part F

Note

see [Kanatani, 1984] for more information on the fabric tensor and [Gu et al, 2017] for the scalar anisotropy factor

Function contibuted by Max Wiebicke (Dresden University)

spam.orientations.analyse.projectOrientation(vector, coordSystem, projectionSystem)[source]#

This functions projects a 3D vector from a given coordinate system into a 2D plane given by a defined projection.

Parameters:
  • vector (1x3 array of floats) – Vector to be projected For cartesian system: ZYX For spherical system: r, tetha (inclination), phi (azimuth) in Radians

  • coordSystem (string) – Coordinate system of the vector Either “cartesian” or “spherical”

  • projectionSystem (string) – Projection to be used Either “lambert”, “stereo” or “equidistant”

Returns:

  • projection_xy (1x2 array of floats) – X and Y coordinates of the projected vector

  • projection_theta_r (1x2 array of floats) – Theta and R coordinates of the projected vector in radians

spam.orientations.generate module#

spam.orientations.generate.generateIsotropic(N)[source]#

There is no analytical solution for putting equally-spaced points on a unit sphere. This Saff and Kuijlaars spiral algorithm gets close.

Parameters:

N (integer) – Number of points to generate

Returns:

orientations – Z,Y,X unit vectors of orientations for each point on sphere

Return type:

Nx3 numpy array

Note

For references, see: http://www.cgafaq.info/wiki/Evenly_distributed_points_on_sphere

Which in turn was based on: http://sitemason.vanderbilt.edu/page/hmbADS

From: Rakhmanov, Saff and Zhou: Minimal Discrete Energy on the Sphere, Mathematical Research Letters, Vol. 1 (1994), pp. 647-662: https://www.math.vanderbilt.edu/~esaff/texts/155.pdf

Also see discussion here: http://groups.google.com/group/sci.math/browse_thread/thread/983105fb1ced42c/e803d9e3e9ba3d23#e803d9e3e9ba3d23%22%22

spam.orientations.generate.generateIcosphere(subDiv)[source]#

This function creates an unit icosphere (convex polyhedron made from triangles) starting from an icosahedron (polyhedron with 20 faces) and then making subdivision on each triangle. The number of faces is 20*(4**subDiv).

Parameters:

subDiv (integer) – Number of times that the initial icosahedron is divided. Suggested value: 3

Returns:

  • icoVerts (numberOfVerticesx3 numpy array) – Coordinates of the vertices of the icosphere

  • icoFaces (numberOfFacesx3 numpy array) – Indeces of the vertices that compose each face

  • icoVectors (numberOfFacesx3) – Vectors normal to each face

spam.orientations.generate.generateVonMisesFisher(mu, kappa, N=1)[source]#

This function generates a set of N 3D unit vectors following a vonMises-Fisher distribution, centered at a mean orientation mu and with a spread K.

Parameters:
  • mu (1x3 array of floats) – Z, Y and X components of mean orientation. Non-unit vectors are normalised.

  • kappa (int) – Spread of the distribution, must be > 0. Higher values of kappa mean a higher concentration along the main orientation

  • N (int) – Number of vectors to generate

Returns:

orientations – Z, Y and X components of each vector.

Return type:

Nx3 array of floats

Notes

Sampling method taken from dlwhittenbury/von-Mises-Fisher-Sampling

Module contents#