allow merging datasets where a variable might be a coordinate variable only in a subset of datasets
Open
Nobody has claimed this yet.
enhancement
topic-combine
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
Is your feature request related to a problem?
Here are two datasets, in one a is a data_var, in the other a is a coordinate variable. The following fails
import xarray as xr
ds1 = xr.Dataset({"a": ('x', [1, 2, 3])})
ds2 = ds1.set_coords("a")
ds2.update(ds1)
with
649 ambiguous_coords = coord_names.intersection(noncoord_names)
650 if ambiguous_coords:
--> 651 raise MergeError(
652 "unable to determine if these variables should be "
653 f"coordinates or not in the merged result: {ambiguous_coords}"
654 )
656 attrs = merge_attrs(
657 [var.attrs for var in coerced if isinstance(var, (Dataset, DataArray))],
658 combine_attrs,
659 )
661 return _MergeResult(variables, coord_names, dims, out_indexes, attrs)
MergeError: unable to determine if these variables should be coordinates or not in the merged result: {'a'}
Describe the solution you'd like
I think we should replace this error with a warning and arbitrarily choose to either convert a to a coordinate variable or a data variable.
Describe alternatives you've considered
No response
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the two datasets in the issue and start from the merge path that raises the shown MergeError. Determine how the merged result should classify the conflicting variable, then add coverage for the dataset update case and verify that it no longer raises the ambiguity error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100