Skip to content

Can't concat virtual datasets without dropping CF variables  #826

@rsignell

Description

@rsignell

I've got some virtual datasets that I need to concatenate along the time dimension.

Following the CF conventions, the dataset variables include time_bnds and the grid_mapping variable rotated_pole.

Creating a list of virtual datasets with Virtualizarr works fine.

Here's what one virtual dataset in the list looks like:

Image

If I drop the time_bnds and rotated_pole variables from each virtual dataset, I can concatenate with:

combined_ds = xr.concat(
    ds_list,
    dim="time",
    coords="minimal",
    compat="override",
    combine_attrs="override",
)

but if I don't drop them, I get:

File /srv/conda/envs/notebook/lib/python3.13/site-packages/xarray/core/duck_array_ops.py:261, in asarray(data, xp, dtype)
    258     return converted
    260 if xp is np or not hasattr(xp, "astype"):
--> 261     return converted.astype(dtype)
    262 else:
    263     return xp.astype(converted, dtype)

File /srv/conda/envs/notebook/lib/python3.13/site-packages/virtualizarr/manifests/array.py:209, in ManifestArray.astype(self, dtype, copy)
    207 """Cannot change the dtype, but needed because xarray will call this even when it's a no-op."""
    208 if dtype != self.dtype:
--> 209     raise NotImplementedError()
    210 else:
    211     return self

NotImplementedError: 

A reproducer notebook is here: https://gist.github.com/rsignell/88bd394bc76f30c6f5517da263490d9d

Am I doing anything wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions