Replies: 1 comment 4 replies
-
I don't know if there's a good way to do this currently. However this makes me wondering whether, in the context of the (ongoing) explicit indexes refactor, we might want to return all the relevant indexed coordinates when constructing a DataArray from a Dataset variable, possibly including coordinates that don't share common dimensions with the variable itself. In your example, the indexes refactor will eventually allow setting a custom index based on the 4 coordinates That said, it would mean that the set of all dimensions of the coordinates of a DataArray is not guaranteed to be always a subset of the dimensions of the DataArray itself, and I'm not sure about all the implications that such a big change in the DataArray data model would have. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
DataArray's are self contained objects, for netcdf variables they include information about coordinate variable.
For example, consider the following netcdf file:
The eta variable has "centre" dimensions and is on a 2D curvilinear quad grid. However, the reference to the coordinates of the grid corners, i.e. the variables
x_grd
andy_grid
, are lost when the DataArray for eta is constructed.We're currently extending xarray via accessors, to use the grid corners to properly plot variables like eta, but are forced to make our custom
plot
method on theDataset
class rather than theDataArray
.So, this works as the Dataset has all the information we need:
But we would prefer to make this work:
As the syntax is more natural, and consistent with other packages like GeoViews, and even xarray itself.
Is there a way to do this?
We've looked at using the
attrs
property to store theDataset
object on theDataArray
variables viads.cem.open_dataset(..)
method but this is problematic in a range of cases, not least of which breaksto_netcdf()
Beta Was this translation helpful? Give feedback.
All reactions