Bug: structured data transpose changes face mapping in from_xarray
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Read _map_dims_to_ugrid in uxarray/core/utils.py and face construction in uxarray/io/_structured.py, then inspect the existing structured mapping regression test. Reproduce the issue using the supplied (y, x) and (x, y) datasets and add a regression test showing both conversions map values identically to the same grid faces. Done when the test passes and the mapping remains consistent with the documented face ordering.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version
Source main at 6d6c6dacd2472fda8c6a3f71af659e1eb1cbadc9; Python 3.12.14, NumPy 2.5.4, xarray 2026.9.0 on Linux.
How did you install UXarray?
Source
What happened?
Converting equivalent structured datasets with UxDataset.from_xarray(..., uxgrid=grid) associates different values with the same grid faces when the spatial dimension order is transposed. The conversion succeeds without a warning. This matters when normalizing structured member files into a shared unstructured representation for regional statistics or integration.
For the synthetic example below, (y, x) produces face values [0, 0, 0, 100, 100, 100], while the equivalent (x, y) input produces [0, 100, 0, 100, 0, 100]. Both retain exactly the same Grid object and its face connectivity. The integral changes from 67.08123535225863 to 79.37563993526874 for this example; this is not a general error bound.
What did you expect to happen?
Transposing named input dimensions should preserve the physical field and its association with grid faces, so both mapped values and integration results should agree.
Can you provide a MCVE to repoduce the bug?
import numpy as np
import xarray as xr
import uxarray as ux
original = xr.Dataset(
{"temperature": (("y", "x"), [[0., 0., 0.], [100., 100., 100.]])},
coords={"x": [0., 20., 40.], "y": [-10., 50.]},
)
transposed = original.transpose("x", "y")
xr.testing.assert_identical(original, transposed.transpose("y", "x"))
grid = ux.Grid.from_structured(lon=original.x, lat=original.y)
a = ux.UxDataset.from_xarray(original, uxgrid=grid)
b = ux.UxDataset.from_xarray(transposed, uxgrid=grid)
assert a.uxgrid is b.uxgrid is grid
print(a.temperature.values) # [0., 0., 0., 100., 100., 100.]
print(b.temperature.values) # [0., 100., 0., 100., 0., 100.]
print(float(a.temperature.integrate())) # 67.08123535225863
print(float(b.temperature.integrate())) # 79.37563993526874
np.testing.assert_array_equal(a.temperature.values, b.temperature.values)
The last assertion fails. I also reproduced the mapping after writing the two synthetic members as separate NetCDF files and reading them through xarray. Explicitly transposing the source back to (..., "y", "x") before conversion restores the correct values and integral.
Investigation and scope
_map_dims_to_ugrid chooses its stacking order from a data variable's final dimension, while _read_structured_grid constructs face connectivity in latitude-major, longitude-minor order. The existing structured mapping regression test also documents face k as (k // n_lon, k % n_lon).
This reproduction uses the existing from_xarray API on main, without the changes in #1827. It does not call weighted_mean, so it is distinct from #1800's reduction-axis issue. No implementation changes are included here. I would be happy to work on a focused fix and regression tests if this can be assigned to me, following the contribution guide.
AI assistance: OpenAI Codex assisted with investigation and synthetic reproduction; the recorded results were actually executed against the pinned source.
- Ngôn ngữ chính
- Python
- Star
- 230
- Fork
- 57
- Merge trung bình
- 4 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của UXARRAY/uxarray
-
Update installation docs to include new conda recipesCó thể đã có người làm @Sevans711 đã nhận 18 ngày trước. Đang mởdocumentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
UXARRAY/uxarray#1793 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
developer experience
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 3 ngày
-
zonal_mean() and weighted_mean() should return the same type of objectCó thể đã có người làm @Sevans711 đã nhận 27 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
UXARRAY/uxarray#1733 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Neighborhood filter radii in kilometersCó thể đã có người làm @cmdupuis3 đã nhận 5 ngày trước. Đang mởimprovement
UXARRAY/uxarray#1824 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của UXARRAY/uxarray
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
SACGF/variantgrid#2341 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
comp/cli P3 type/security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
NousResearch/hermes-agent#141420 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CKV_GCP_18 (GKEPublicControlPlane) passes when master_authorized_networks_config is absent, control plane is internet-reachableCó thể đã có người làm @Varshith-Kali đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
bridgecrewio/checkov#7753 ·
Maintainer thường phản hồi trong vòng 1 ngày