You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dataset.append_dim should be consistent with Dataset.concat, which does not raise an error. For empty Dataset objects, this results in the example Tom provided, with no time dimension, because there are no variables using that time dimension. For Dataset objects with variables, using Dataset.append_dim on those Datasets should introduce a new, single-element, dimension added to the contained variables, and the output variables should be concatenated along that new dimension.
Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
Complete example — the example is self-contained, including all data and the text of any traceback.
Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
New issue — a search of GitHub Issues suggests this is not a duplicate.
Recent environment — the issue occurs with the latest version of xarray and its dependencies.
Relevant log output
File~/Documents/git/pydata/xarray/xarray/core/dataset.py:2622, inDataset.to_zarr(self, store, chunk_store, mode, synchronizer, group, encoding, compute, consolidated, append_dim, region, safe_chunks, storage_options, zarr_version, zarr_format, write_empty_chunks, chunkmanager_store_kwargs)
2454"""Write dataset contents to a zarr group. 2455 2456 Zarr chunks are determined in the following way: (...) 2618 The I/O user guide, with more details and examples. 2619 """2620fromxarray.backends.apiimportto_zarr->2622returnto_zarr( # type: ignore[call-overload,misc]2623self,
2624store=store,
2625chunk_store=chunk_store,
2626storage_options=storage_options,
2627mode=mode,
2628synchronizer=synchronizer,
2629group=group,
2630encoding=encoding,
2631compute=compute,
2632consolidated=consolidated,
2633append_dim=append_dim,
2634region=region,
2635safe_chunks=safe_chunks,
2636zarr_version=zarr_version,
2637zarr_format=zarr_format,
2638write_empty_chunks=write_empty_chunks,
2639chunkmanager_store_kwargs=chunkmanager_store_kwargs,
2640 )
File~/Documents/git/pydata/xarray/xarray/backends/api.py:2184, into_zarr(dataset, store, chunk_store, mode, synchronizer, group, encoding, compute, consolidated, append_dim, region, safe_chunks, storage_options, zarr_version, zarr_format, write_empty_chunks, chunkmanager_store_kwargs)
2182writer=ArrayWriter()
2183# TODO: figure out how to properly handle unlimited_dims->2184dump_to_store(dataset, zstore, writer, encoding=encoding)
2185writes=writer.sync(
2186compute=compute, chunkmanager_store_kwargs=chunkmanager_store_kwargs2187 )
2189ifcompute:
File~/Documents/git/pydata/xarray/xarray/backends/api.py:1920, indump_to_store(dataset, store, writer, encoder, encoding, unlimited_dims)
1917ifencoder:
1918variables, attrs=encoder(variables, attrs)
->1920store.store(variables, attrs, check_encoding, writer, unlimited_dims=unlimited_dims)
File~/Documents/git/pydata/xarray/xarray/backends/zarr.py:907, inZarrStore.store(self, variables, attributes, check_encoding_set, writer, unlimited_dims)
905existing_dims=self.get_dimensions()
906ifself._append_dimnotinexisting_dims:
-->907raiseValueError(
908f"append_dim={self._append_dim!r} does not match any existing "909f"dataset dimensions {existing_dims}"910 )
912variables_encoded, attributes=self.encode(
913 {vn: variables[vn] forvninnew_variable_names}, attributes914 )
916ifexisting_variable_names:
917# We make sure that values to be appended are encoded *exactly*918# as the current values in the store.919# To do so, we decode variables directly to access the proper encoding,920# without going via xarray.Dataset to avoid needing to load921# index variables into memory.ValueError: append_dim='time'doesnotmatchanyexistingdatasetdimensions {'lat': 2, 'lon': 3}
What happened?
This issue relates to #9858, and captures the
Dataset.append_dim
behaviour noted by @TomNicholas in this comment.What did you expect to happen?
Dataset.append_dim
should be consistent withDataset.concat
, which does not raise an error. For emptyDataset
objects, this results in the example Tom provided, with notime
dimension, because there are no variables using that time dimension. ForDataset
objects with variables, usingDataset.append_dim
on thoseDataset
s should introduce a new, single-element, dimension added to the contained variables, and the output variables should be concatenated along that new dimension.Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
No response
Environment
<function xarray.util.print_versions.show_versions(file=<_io.TextIOWrapper name='' mode='w' encoding='utf-8'>)>
The text was updated successfully, but these errors were encountered: