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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intersection bounds fix (replacement PR) #4059
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3185,18 +3185,22 @@ def _intersect_modulus( | |
pre_wrap_delta != post_wrap_delta | ||
) | ||
|
||
# Recalculate the extended minimum. | ||
indices = inside_indices[split_cell_indices] | ||
cells = bounds[indices] | ||
cells_delta = np.diff(coord.bounds[indices]) | ||
|
||
# Watch out for ascending/descending bounds | ||
if cells_delta[0, 0] > 0: | ||
cells[:, 0] = cells[:, 1] - cells_delta[:, 0] | ||
minimum = np.min(cells[:, 0]) | ||
else: | ||
cells[:, 1] = cells[:, 0] + cells_delta[:, 0] | ||
minimum = np.min(cells[:, 1]) | ||
if maximum % modulus not in cells: | ||
# Recalculate the extended minimum only if the output bounds | ||
# do not span the requested (minumum, maximum) range. If | ||
# they do span that range, this adjustment would give unexpected | ||
# results (see #3391). | ||
cells_delta = np.diff(coord.bounds[indices]) | ||
|
||
# Watch out for ascending/descending bounds. | ||
if cells_delta[0, 0] > 0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's only been two months but I had completely forgotten the logic here! I think this is fine though: we don't explicitly set
So the only way that Definitely needs a comment though! |
||
cells[:, 0] = cells[:, 1] - cells_delta[:, 0] | ||
minimum = np.min(cells[:, 0]) | ||
else: | ||
cells[:, 1] = cells[:, 0] + cells_delta[:, 0] | ||
minimum = np.min(cells[:, 1]) | ||
|
||
points = wrap_lons(coord.points, minimum, modulus) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a comment here, even referencing the exact problem that this code is aiming to solve.