Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data published from xcube server where calculations on the fly add new data variables raises error for mldatasets #20

Open
konstntokas opened this issue Aug 2, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@konstntokas
Copy link
Collaborator

konstntokas commented Aug 2, 2024

Describe the bug
When using xcube-stac to open data published by xcube server calculations on the fly add new data variables raises an error, if mldataset is desired. xcube-stac renames variables to distinguish data variables of different assets sharing the same name. When calculations are performed on a dataset where data variables are added, the renaming dictionary picks those names. However when actually accessing the data source with mlds.get_dataset(idx_level), the original dataset is opened, which does not have these data variable, resulting in an error.

To Reproduce
Steps to reproduce the behavior:

  1. run xcube server demo example: xcube serve -vvv -c examples/serve/demo/config.yml
  2. use xcube-stac to open data:
from xcube.core.store import new_data_store

url = "http://127.0.0.1:8080/ogc"
store = new_data_store("stac", url=url)
mlds = store.open_data("collections/datacubes/items/local", data_type="mldataset")
ds = mlds.get_dataset(2)
print(ds)

Returned error:

Traceback (most recent call last):
  File "/home/konstantin/bc_kon/01_coding/00_testing/error_xcube_server.py", line 6, in <module>
    ds = mlds.get_dataset(2)
         ^^^^^^^^^^^^^^^^^^^
  File "/home/konstantin/micromamba/envs/xcube-stac/lib/python3.12/site-packages/xcube/core/mldataset/lazy.py", line 92, in get_dataset
    level_dataset = self._get_dataset_lazily(index, self._parameters)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/konstantin/micromamba/envs/xcube-stac/lib/python3.12/site-packages/xcube/core/mldataset/mapped.py", line 32, in _get_dataset_lazily
    return self._mapper_function(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/konstantin/bc_kon/01_coding/01_github/xcube-stac/xcube_stac/utils.py", line 508, in _xarray_rename_vars
    return ds.rename_vars(name_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/konstantin/micromamba/envs/xcube-stac/lib/python3.12/site-packages/xarray/core/dataset.py", line 4396, in rename_vars
    raise ValueError(
ValueError: cannot rename 'lat_bnds' because it is not a variable or coordinate in this dataset

Expected behavior
Levels of multi-level datasets shall be opened without error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant