digger.utils.logspiral
¶
Functions for fitting logarithmic spirals.
Module Contents¶
Functions¶
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
andalpha2
, respectively.alpha1
is the tangent of the spiral at \((x_1, y_1)\) andalpha2
is the tangent at \((x_1, x_2)\).alpha1
must be greater than the average slope implied by the endpoint coordinates andalpha2
must be less than the average slope.\(x_1\), \(y_1\), \(x_2\), \(y_2\),
alpha1
, andalpha2
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
anderror_xy
.If the final fit between the logspiral tangent at either endpoint is more than
error_alpha
different from the tangents specified byalpha1
andalpha2
, 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)\).