attitude.orientation package

Submodules

attitude.orientation.base module

class attitude.orientation.base.BaseOrientation[source]

Bases: object

Abstract class to define common methods used by other orientation classes (e.g. reconstructed orientations, pca orientations)

center
centered_array
dip_direction(uncertainties=False)[source]
disabled = False
error_ellipse(spherical=True, vector=False, level=1)[source]
errors()[source]
gradient(uncertainties=False)[source]
hash
principal_axes
rotated_covariance
standard_errors()[source]
to_mapping(**values)[source]

Create a JSON-serializable representation of the plane that is usable with the javascript frontend

attitude.orientation.base.ellipse(center, covariance_matrix, level=1, n=1000)[source]

Returns error ellipse in slope-azimuth space

attitude.orientation.base.hash_array(a)[source]
attitude.orientation.base.rotation(angle)[source]

Rotation about the Z axis (in the XY plane)

attitude.orientation.grouped module

class attitude.orientation.grouped.GroupedOrientation(*orientations, **kwargs)[source]

Bases: attitude.orientation.pca.PCAOrientation

to_mapping(**values)[source]

Create a JSON-serializable representation of the plane that is usable with the javascript frontend

exception attitude.orientation.grouped.GroupedPlaneError[source]

Bases: Exception

attitude.orientation.grouped.create_groups(orientations, *groups, **kwargs)[source]

Create groups of an orientation measurement dataset

attitude.orientation.grouped.disable_orientations(orientations, *to_disable)[source]

attitude.orientation.pca module

class attitude.orientation.pca.PCAOrientation(arr, weights=None, axes=None)[source]

Bases: attitude.orientation.base.BaseOrientation

Gets the axis-aligned principle components of the dataset.

U

Property to support lazy evaluation of residuals

angular_error(axis_length)[source]

The angular error for an in-plane axis of given length (either a PCA major axis or an intermediate direction).

angular_errors(degrees=True)[source]

Minimum and maximum angular errors corresponding to 1st and 2nd axes of PCA distribution.

as_conic(level=1)[source]
as_hyperbola(rotated=False)[source]

Hyperbolic error area

azimuth
center
centered_array
coefficients
covariance_matrix

The data covariance matrix is related to the cross-product matrix M^T M but scaled by the number of samples.

eigenvalues

Eigenvalues of the data covariance matrix

error_coords(**kwargs)[source]
error_ellipse(spherical=True, vector=False, level=1)[source]
explained_variance

Proportion of variance that is explained by the first two principal components (which together represent the planar fit). Analogous to R^2 of linear least squares.

classmethod from_axes()[source]

Recovers a principal component dataset from a set of axes (singular values*principal axes) of the dataset.

hyperbolic_axes
plane_errors(**kwargs)[source]
rake()[source]
residuals()[source]

Returns residuals of fit against all three data axes (singular values 1, 2, and 3). This takes the form of data along singular axis 3 (axes 1 and 2 define the plane)

rotated()[source]

Returns a dataset ‘despun’ so that it is aligned with the princpal axes of the dataset.

slope
strike_dip(degrees=True)[source]

Computes strike and dip from a normal vector. Results are usually the same as LLSQ in strike (to a few decimal places) and close in dip. Sometimes, dips are greater by as much as 45 degrees, reflecting inclusion of errors in x-y plane.

strike_dip_rake()[source]
to_mapping(**values)[source]

Create a JSON-serializable representation of the plane that is usable with the javascript frontend

attitude.orientation.pca.augment(matrix)[source]
attitude.orientation.pca.augment_vector(vec)[source]
attitude.orientation.pca.axis_transform(pca_axes)[source]

Creates an affine transformation matrix to rotate data in PCA axes into Cartesian plane

attitude.orientation.pca.compose_affine(*transforms)[source]

Returns a composite of several affine transformations.

attitude.orientation.pca.covariance_matrix(self)[source]

Constructs the covariance matrix of input data from the singular value decomposition. Note that this is different than a covariance matrix of residuals, which is what we want for calculating fit errors.

Using SVD output to compute covariance matrix X=UΣV⊤ XX⊤XX⊤=(UΣV⊤)(UΣV⊤)⊤=(UΣV⊤)(VΣU⊤) V is an orthogonal matrix (V⊤V=I), covariance matrix of input data: XX⊤=UΣ2U⊤

Because the axes represent identity in the PCA coordinate system, the PCA major axes themselves represent an affine transformation matrix from PCA to Cartesian space
attitude.orientation.pca.norm(x)
attitude.orientation.pca.normalize(v)[source]
attitude.orientation.pca.random_pca(scattered=True)[source]
attitude.orientation.pca.rotate_tensor(tensor, transform)[source]

Transforms a tensor by an affine transform

attitude.orientation.pca.test_SVD(pca)[source]

Function to test the validity of singular value decomposition by reconstructing original data.

attitude.orientation.reconstructed module

class attitude.orientation.reconstructed.ErrorShell(axes, covariance)[source]

Bases: object

Object representing a specific error level

cartopy_girdle(**kw)[source]
cartopy_normal(**kw)[source]
class attitude.orientation.reconstructed.ReconstructedPlane(strike, dip, rake, *angular_errors, **kwargs)[source]

Bases: attitude.orientation.reconstructed.ErrorShell, attitude.orientation.base.BaseOrientation

This class represents a plane with errors on two axes. This error is presumably the result of some statistical process, and is a single confidence interval or shell derived from this result.

angular_errors()[source]
hash
strike_dip_rake()[source]

attitude.orientation.test_pca module

attitude.orientation.test_pca.test_builtin_recovery()[source]

Test recovery functions that are built into basic API

attitude.orientation.test_pca.test_component_planes()[source]
attitude.orientation.test_pca.test_error_angles()[source]

Test simplistic formulation of error angle measurement

attitude.orientation.test_pca.test_grouped_plane()[source]
attitude.orientation.test_pca.test_hyperbola_axes()[source]

Test that the hyperbolic axes are the same as the squared covariance matrices

attitude.orientation.test_pca.test_normal_errors()[source]

Test the reconstruction of normal vector errors from PCA and conversion back to hyperbolic errors

attitude.orientation.test_pca.test_pca_recovery()[source]
attitude.orientation.test_pca.test_pca_regression_variable()[source]

The $hateta$ regression variable is considered the canonical representation of the regressor for OLS. This is also defined for TLS/unweighted PCA regression.

attitude.orientation.test_pca.test_recovery_from_axes()[source]

Tests the recovery of a Principal Component dataset from a set of precomputed axes.

attitude.orientation.test_pca.test_rotation()[source]

Make sure we can rotate between PCA and global coordinate systems

attitude.orientation.test_pca.test_singular_values()[source]

Singular values should represent the standard deviations along major axes of the dataset, scaled by the size of the dataset. E.g. they represent the sqrt(sum of deviations) along that axis of the dataset.

See https://docs.scipy.org/doc/numpy/reference/generated/numpy.std.html for more information

attitude.orientation.test_pca.test_solid_angle()[source]

Test that integration to a range of girdle half-widths returns the appropriate solid angles.

attitude.orientation.test_reconstructed module

attitude.orientation.test_reconstructed.test_rake_angle()[source]

Test that we can reconstruct rake angle

attitude.orientation.test_reconstructed.test_reconstructed_plane()[source]

Test the reconstruction of a fitted plane from orientation of the plane expressed in spherical coordinates

attitude.orientation.tests module

class attitude.orientation.tests.TestCase(array, strike_dip, id)[source]

Bases: object

attitude.orientation.tests.check_orientation(a)[source]
attitude.orientation.tests.test_coordinates()[source]

Tests to make sure we don’t lose coordinates in the Orientation object

attitude.orientation.tests.test_covariance()[source]

Make sure we don’t get empty covariance matrices in the Orientation object

attitude.orientation.tests.test_directions()[source]

Tests cardinal directions for simple cases, to make sure everything conforms to right-hand rule. Does not test the standard deviation of these methods.

attitude.orientation.tests.test_rotation_matrix()[source]

Check that we have properly rotated our matrix to bring the along-strike direction into a coordinate plane.

Module contents

The core orientation module contains classes implementing different planar fitting algorithms. These methods generally produce an object describing a planar fit.

The most useful of these methods is described by