Skip to content

Commit 44a332e

Browse files
authored
Merge pull request #30 from uafgeotools/fix_3_array
Fix rthEllipse handling in OLS code
2 parents 2597827 + a98a3e5 commit 44a332e

1 file changed

Lines changed: 21 additions & 16 deletions

File tree

lts_array/classes/lts_classes.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -945,22 +945,27 @@ def solve(self, data):
945945
# along coordinate system axes
946946
So = R @ [sx, sy]
947947
# Find angle & slowness extrema
948-
# try:
949-
eExtrm, eVec = rthEllipse(a, b, So[0], So[1])
950-
# Rotate eigenvectors back to original orientation
951-
eVec = eVec @ R
952-
# Fix up angle calculations
953-
sig_theta = np.abs(np.diff(
954-
(np.arctan2(eVec[2:, 1], eVec[2:, 0]) * 180 / np.pi - 360)
955-
% 360))
956-
if sig_theta > 180:
957-
sig_theta = np.abs(sig_theta - 360)
958-
959-
# Halving here s.t. +/- value expresses uncertainty bounds.
960-
# Remove the 1/2's to get full values to express
961-
# coverage ellipse area.
962-
self.conf_int_baz[jj] = 0.5 * sig_theta
963-
self.conf_int_vel[jj] = 0.5 * np.abs(np.diff(1 / eExtrm[:2]))
948+
try:
949+
# rthEllipse routine can be unstable; catch instabilities
950+
eExtrm, eVec = rthEllipse(a, b, So[0], So[1])
951+
# Rotate eigenvectors back to original orientation
952+
eVec = eVec @ R
953+
# Fix up angle calculations
954+
sig_theta = np.abs(np.diff(
955+
(np.arctan2(eVec[2:, 1], eVec[2:, 0]) * 180 / np.pi - 360)
956+
% 360))
957+
if sig_theta > 180:
958+
sig_theta = np.abs(sig_theta - 360)
959+
960+
# Halving here s.t. +/- value expresses uncertainty bounds.
961+
# Remove the 1/2's to get full values to express
962+
# coverage ellipse area.
963+
self.conf_int_baz[jj] = 0.5 * sig_theta
964+
self.conf_int_vel[jj] = 0.5 * np.abs(np.diff(1 / eExtrm[:2]))
965+
966+
except ValueError:
967+
self.conf_int_baz[jj] = np.nan
968+
self.conf_int_vel[jj] = np.nan
964969

965970

966971
class LTSEstimator(LsBeam):

0 commit comments

Comments
 (0)