Skip to content

Commit 90130cc

Browse files
make x-y ordering more consistent with existing implementations
1 parent 31ef593 commit 90130cc

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/iris/analysis/_area_weighted.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def _regrid_area_weighted_rectilinear_src_and_grid__perform(
403403
weights,
404404
) = regrid_info
405405

406-
tgt_shape = (len(grid_x.points), len(grid_y.points))
406+
tgt_shape = (len(grid_y.points), len(grid_x.points))
407407

408408
# Calculate new data array for regridded cube.
409409
regrid = functools.partial(
@@ -558,13 +558,13 @@ def _combine_xy_weights(x_info, y_info, src_shape, tgt_shape):
558558
x_weight, x_rows, x_cols = x_info
559559
y_weight, y_rows, y_cols = y_info
560560

561-
xy_weight = x_weight[:, np.newaxis] * y_weight[np.newaxis, :]
561+
xy_weight = y_weight[:, np.newaxis] * x_weight[np.newaxis, :]
562562
xy_weight = xy_weight.flatten()
563563

564-
xy_rows = (x_rows[:, np.newaxis] * y_tgt) + y_rows[np.newaxis, :]
564+
xy_rows = (y_rows[:, np.newaxis] * x_tgt) + x_rows[np.newaxis, :]
565565
xy_rows = xy_rows.flatten()
566566

567-
xy_cols = (x_cols[:, np.newaxis] * y_src) + y_cols[np.newaxis, :]
567+
xy_cols = (y_cols[:, np.newaxis] * x_src) + x_cols[np.newaxis, :]
568568
xy_cols = xy_cols.flatten()
569569

570570
combined_weights = csr_array(
@@ -662,13 +662,12 @@ def _regrid_along_dims(data, x_dim, y_dim, weights, tgt_shape, mdtol):
662662
else:
663663
y_none = False
664664

665-
# TODO: decide if standard regridding should expect (x,y) or (y,x) ordering
666665
# Standard regridding expects the last two dimensions to belong
667-
# to the x and y coordinate and will output as such.
666+
# to the y and x coordinate and will output as such.
668667
# Axes are moved to account for an arbitrary dimension ordering.
669-
data = np.moveaxis(data, [x_dim, y_dim], [-2, -1])
668+
data = np.moveaxis(data, [y_dim, x_dim], [-2, -1])
670669
result = _standard_regrid(data, weights, tgt_shape, mdtol)
671-
result = np.moveaxis(result, [-2, -1], [x_dim, y_dim])
670+
result = np.moveaxis(result, [-2, -1], [y_dim, x_dim])
672671

673672
if y_none:
674673
result = np.squeeze(result, axis=-1)

0 commit comments

Comments
 (0)