Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cross track point perturbation #122

Merged
merged 3 commits into from
Dec 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ensembleperturbation/perturbation/atcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,14 +802,14 @@ def perturb(
next_offset = get_offset(current_point, next_point, cross_track_error)

# get the perpendicular offset based on the average of the forward and backward piecewise track lines adjusted so that the distance matches the actual cross_error
normal_offset = numpy.mean([previous_offset, next_offset])
normal_offset = numpy.mean([previous_offset, next_offset], axis=0)
alpha = abs(cross_track_error) / numpy.sqrt(numpy.sum(normal_offset ** 2))

if numpy.isinf(alpha):
alpha = 0

# compute the next point and retrieve back the lat-lon geographic coordinate
new_point = current_point - alpha * normal_offset
new_point = current_point - abs(alpha) * normal_offset
new_coordinates.append(
transformer.transform(
new_point[0].magnitude,
Expand Down Expand Up @@ -1796,9 +1796,9 @@ def get_offset(
# z**2 / (1 + pslope**2) = x**2
# z / (1 + pslope**2)**0.5 = x

points = numpy.concatenate([point_1, point_2], axis=0)
points = numpy.vstack([point_1, point_2])

difference = numpy.diff(points, axis=0)
difference = numpy.diff(points, axis=0).ravel()

# tangential slope approximation
slope = difference[1] / difference[0]
Expand Down
Loading