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

get_usgs_data throws error #414

Open
sverhoeven opened this issue May 7, 2024 · 0 comments
Open

get_usgs_data throws error #414

sverhoeven opened this issue May 7, 2024 · 0 comments

Comments

@sverhoeven
Copy link
Member

I tried to run the example code at https://ewatercycle.readthedocs.io/en/latest/autoapi/ewatercycle/observation/grdc/index.html#ewatercycle.observation.grdc.get_grdc_data

But got an error

>>> from ewatercycle.observation.usgs import get_usgs_data
>>> data = get_usgs_data('03109500', '2000-01-01', '2000-12-31', cache_dir='.')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/stefanv/git/eWaterCycle/ewatercycle/src/ewatercycle/observation/usgs.py", line 126, in get_usgs_data
    ds.to_netcdf(netcdf)
  File "/home/stefanv/mambaforge/envs/ewatercycle/lib/python3.10/site-packages/xarray/core/dataset.py", line 2298, in to_netcdf
    return to_netcdf(  # type: ignore  # mypy cannot resolve the overloads:(
  File "/home/stefanv/mambaforge/envs/ewatercycle/lib/python3.10/site-packages/xarray/backends/api.py", line 1339, in to_netcdf
    dump_to_store(
  File "/home/stefanv/mambaforge/envs/ewatercycle/lib/python3.10/site-packages/xarray/backends/api.py", line 1386, in dump_to_store
    store.store(variables, attrs, check_encoding, writer, unlimited_dims=unlimited_dims)
  File "/home/stefanv/mambaforge/envs/ewatercycle/lib/python3.10/site-packages/xarray/backends/common.py", line 393, in store
    variables, attributes = self.encode(variables, attributes)
  File "/home/stefanv/mambaforge/envs/ewatercycle/lib/python3.10/site-packages/xarray/backends/common.py", line 482, in encode
    variables, attributes = cf_encoder(variables, attributes)
  File "/home/stefanv/mambaforge/envs/ewatercycle/lib/python3.10/site-packages/xarray/conventions.py", line 795, in cf_encoder
    new_vars = {k: encode_cf_variable(v, name=k) for k, v in variables.items()}
  File "/home/stefanv/mambaforge/envs/ewatercycle/lib/python3.10/site-packages/xarray/conventions.py", line 795, in <dictcomp>
    new_vars = {k: encode_cf_variable(v, name=k) for k, v in variables.items()}
  File "/home/stefanv/mambaforge/envs/ewatercycle/lib/python3.10/site-packages/xarray/conventions.py", line 199, in encode_cf_variable
    var = ensure_dtype_not_object(var, name=name)
  File "/home/stefanv/mambaforge/envs/ewatercycle/lib/python3.10/site-packages/xarray/conventions.py", line 154, in ensure_dtype_not_object
    data = _copy_with_dtype(data, dtype=_infer_dtype(data, name))
  File "/home/stefanv/mambaforge/envs/ewatercycle/lib/python3.10/site-packages/xarray/conventions.py", line 80, in _infer_dtype
    raise ValueError(
ValueError: unable to infer dtype on variable 'time'; xarray cannot serialize arbitrary Python objects
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant