Add inherit='all' option to DataTree.to_dataset()#11230
Open
aladinor wants to merge 6 commits intopydata:mainfrom
Open
Add inherit='all' option to DataTree.to_dataset()#11230aladinor wants to merge 6 commits intopydata:mainfrom
inherit='all' option to DataTree.to_dataset()#11230aladinor wants to merge 6 commits intopydata:mainfrom
Conversation
inherit='all' option to DataTree.to_dataset()
Draft
4 tasks
kmuehlbauer
reviewed
Mar 20, 2026
Contributor
kmuehlbauer
left a comment
There was a problem hiding this comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
whats-new.rstSummary
Adds
inherit='all'option toDataTree.to_dataset()so users can inherit all parent coordinates, not just indexed ones.Currently,
DataTreeonly inherits indexed (dimension) coordinates from parent nodes. Non-index coordinates are silently dropped during inheritance. This PR extends theinheritparameter frombooltobool | Literal["all", "indexes"]:True/"indexes"— inherit only indexed coordinates (default, backward compatible)"all"— inherit all coordinates, including non-index coordinatesFalse— node-only coordinatesMotivation: inheriting non-index coordinates
As described in #10812, non-index coordinates defined on a parent node are not inherited by child nodes. This is a common need in projects like xradar, where non-index coordinates such as
latitude,longitude, andaltitudeare stored on the root node and need to be accessible on child sweep nodes:See also: openradar/xradar#337
Implementation
_coord_variables_allproperty onDataTree(like_coord_variablesbut inherits all parent coords, not just indexed ones)_resolve_inherit()helper to centralize inherit parameter validation and dispatchto_dataset()and_to_dataset_view()to use the new helpercc @kmuehlbauer