Skip to content

exception to indexed-coordinate only inheritance for coordinates encoding #11441

Description

@itcarroll

Is your feature request related to a problem?

From review of #9475, #10812, and linked PRs, I partially understand the difficulty involved in resolving questions around shared coordinates within datatrees. The decision to support inheritance for indexed-coordinates makes a lot of sense. I think there is a practical use-case for allowing additional inheritance: when decode_cf=True and a CF-Conventions compliant coordinates attribute implies inheritance.

Here is an example of a CF-Convention coordinates attribute:

xarray.DataTree.from_dict(
    {
        "x": [0, 1],
        "y": [0, 1, 2],
        "lon": (("x", "y"), [[0, 0, 0], [1, 1, 1]]),
        "lat": (("x", "y"), [[0, 1, 2], [0, 1, 2]]),
        "products/temp": (
            ("x", "y"), [[4, 6, 2], [5, 7, 3]], None, {"coordinates": "/lon /lat"}
        ),
    },
)

or in netCDF's CDL:

dimensions:
	x = 2 ;
	y = 3 ;
variables:
	int64 x(x) ;
	int64 y(y) ;
	int64 lon(x, y) ;
	int64 lat(x, y) ;

group: products {
  variables:
  	int64 temp(x, y) ;
  		temp:coordinates = "/lon /lat" ;
  } // group products

Describe the solution you'd like

When a data variable's encoding includes coordinates that identify an "auxiliary coordinate variable" (sensu NUG) or "non-indexed coordinate" (sensu XArray) that is within scope, then that variable should be set as a coordinate and inherited if necessary.

I add "if necessary", because the in-scope coordinate could be within the same group. In which case there is nothing to inherit.

Describe alternatives you've considered

Any variable encoded in a coordinates string could have a (possibly multi-dimensional) index created automatically; so that the indexed-coordinate only inheritance is preserved. I think that would be too expensive.

Additional context

I am supporting refinement of netCDF files distributed by a NASA DAAC, and understanding how XArray is thinking about absolute and relative path-like elements of coordinates encodings would really help us help our data users.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions