digger.utils.logspiral

Functions for fitting logarithmic spirals.

Module Contents

Functions

logspiral

Return parameters to uniquely define a logarithmic spiral with endpoints of \((x_1, y_1)\) to \((x_2, y_2)\).

API

digger.utils.logspiral.logspiral(x1: float, y1: float, x2: float, y2: float, alpha1: float, alpha2: float, npoints: int = 100, verbose: bool = False, error_alpha: float = 5.0, error_xy: float = 2.0) Tuple[numpy.ndarray, numpy.ndarray]

Return parameters to uniquely define a logarithmic spiral with endpoints of \((x_1, y_1)\) to \((x_2, y_2)\).

\(x_2\) must be greater than \(x_1\) and \(y_1\) must be greater than \(x_2\).

in polar coordinates \((r, \theta)\) a logarithmic spiral has the form:

\[r = a \exp(k \theta)\]

A headscarp and toeslope angle (measured counterclockwise from the positive x-axis) are provided as alpha1 and alpha2, respectively. alpha1 is the tangent of the spiral at \((x_1, y_1)\) and alpha2 is the tangent at \((x_1, x_2)\).

alpha1 must be greater than the average slope implied by the endpoint coordinates and alpha2 must be less than the average slope.

\(x_1\), \(y_1\), \(x_2\), \(y_2\), alpha1, and alpha2 overperscribe a logspiral and thus a least squares fit of a spiral that meets these criteria is conducted.

If a poor fit is found, errors are raised.

Errors are based on user-specified values for error_alpha and error_xy.

  • If the final fit between the logspiral tangent at either endpoint is more than error_alpha different from the tangents specified by alpha1 and alpha2, and error is raised.

  • If the final location of the endpoint has a distance from \((x_1, y_1)\) or \((x_2, y_2)\) that is greater than error_xy, an error is raised.

Inputs:
x1: float

Logarithmic spiral endpoint x-coordinate.

y1: float

Logarithmic spiral endpoint y-coordinate.

x2: float

Logarithmic spiral endpoint x-coordinate.

y2: float

Logarithmic spiral endpoint y-coordinate.

alpha1: float

Headscarp angle, measured counterclockwise from the postive x-axis)

alpha2: float

Toeslope angle, measured counterclockwise from the postive x-axis)

npoints: int

Size of returned array

verbose: bool

Whether to write summary information to screen.

error_alpha: float

Error threshold in headscarp and toeslope angles.

error_xy: float

Error threshold in x and y.

Outputs:
(x, y): tuple of numpy arrays of shape (npoints,) each

The x and y coordinates tracing the logspiral from \((x_1, y_1)\) to \((x_2, y_2)\).