CF accessor adds grid mapping as coordinate
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 28/100
Hướng nghiên cứu
Start by running the minimal example and tracing the ds.cf[standard_name] accessor alongside Dataset.assign(). Determine whether adding the grid-mapping variable as a coordinate is intended; done should include an agreed behavior for coordinate handling that avoids the shown MergeError, with a regression check for the example.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Possibly a duplicate of #357 or a discussion topic. Opinions welcomed.
Description
Since cf_xarray == 0.8.0 (#391), selecting variables by standard name with ds.cf[standard_name] results in a different set of coordinates than selecting them by their short name with ds[short_name]. This prevents re-injecting these variables in a compatible (and even the original) dataset using Dataset.assign() (and possibly other xarray merge operations). Instead trying to Dataset.assign() a cf-picked, georeferenced variable into a raises a MergeError.
Could you help me to understand if this is a design choice or a bug? In my case it comes as a breaking change and I am not exactly sure how to go about (as a cf-xarray fix or downstream in https://github.com/juseg/hyoga/issues/73). Happy to contribute as I can.
Miminal example
import xarray as xr
import cf_xarray
# make grid-mapped fake data (or use xr.open_dataset)
ds = xr.Dataset({
'tas': ((), None, {
'grid_mapping': 'crs',
'standard_name': 'air_temperature'}),
'crs': ((), None, {
'grid_mapping_name': 'latitude_longitude'})})
# ds and ds.cf variables have different coordinates
print('crs' in ds['tas'].coords) # False
print('crs' in ds.cf['air_temperature'].coords) # True
# assign a cf-picked variable (only works on cf_xarray < 0.8.0)
ds.assign(new=ds.cf['air_temperature']) # xarray.core.merge.MergeError
Error message
Traceback (most recent call last):
File "/home/julien/git/code/hyoga/bugs/cfxr08.py", line 17, in <module>
ds.assign(new=ds.cf['air_temperature']) # xarray.core.merge.MergeError
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/xarray/core/dataset.py", line 6080, in assign
data.update(results)
File "/usr/lib/python3.12/site-packages/xarray/core/dataset.py", line 4946, in update
merge_result = dataset_update_method(self, other)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/xarray/core/merge.py", line 1104, in dataset_update_method
return merge_core(
^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/xarray/core/merge.py", line 772, in merge_core
raise MergeError(
xarray.core.merge.MergeError: unable to determine if these variables should be coordinates or not in the merged result: {'crs'}
- Ngôn ngữ chính
- Python
- Star
- 181
- Fork
- 51
- Merge trung bình
- 6 giờ 39 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 xarray-contrib/cf-xarray
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
xarray-contrib/cf-xarray#623 ·
-
Consider adding opt-in support for circular axes when calling `bounds_to_vertices` (related to #594)Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
xarray-contrib/cf-xarray#596 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
xarray-contrib/cf-xarray#570 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 15/100
xarray-contrib/cf-xarray#568 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
xarray-contrib/cf-xarray#566 · 2 bình luận ·
Tất cả issue của xarray-contrib/cf-xarray
Issue tương tự
-
enhancement from-review
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
khuisman/mcp-gee-sweet#1010 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug confirmed issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
open-webui/open-webui#32333 · 2 bình luận ·
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 68/100
ll7/robot_sf_ll7#10368 ·
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 62/100
-
mcp: a write that loses its answer is reported as "cannot reach", although it may have landedĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
flop-labs/technocore-chat#982 ·
Maintainer thường phản hồi trong vòng 1 ngày