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

ValueError: not enough values to unpack (expected 3, got 0) #5

Open
yangt235 opened this issue Mar 2, 2023 · 1 comment
Open

ValueError: not enough values to unpack (expected 3, got 0) #5

yangt235 opened this issue Mar 2, 2023 · 1 comment

Comments

@yangt235
Copy link

yangt235 commented Mar 2, 2023

Hello, may I ask if this problem is because of my incorrect selection of operation?
selected points:image
error:
ValueError Traceback (most recent call last)
Cell In [5], line 207, in downloader(whatever)
200 # Load datacube according to prerequisites (time, space and variables)
201 start = time.time()
202 xrds = xr.open_dataset(url,
203 engine='zarr',
204 drop_variables=variables_drop
205 ).sel(mid_date=t_mask,
206 x=slice(velocity_widget.xmin_proj, velocity_widget.xmax_proj),
--> 207 y=slice(velocity_widget.ymax_proj, velocity_widget.ymin_proj)).load()
209 print(f"downloaded {cubes[n].split('/')[-1].split('.')[0]} spatial slice {time.time()-start:8.1f} seconds")
210 xrds.to_netcdf(f"{pathsave}{cubes[n].split('/')[-1].split('.')[0]}{sdate}{edate}.nc")

File ~\anaconda3\envs\Glaciervel\lib\site-packages\xarray\core\dataset.py:746, in Dataset.load(self, **kwargs)
744 for k, v in self.variables.items():
745 if k not in lazy_data:
--> 746 v.load()
748 return self

File ~\anaconda3\envs\Glaciervel\lib\site-packages\xarray\core\variable.py:542, in Variable.load(self, **kwargs)
540 self._data = as_compatible_data(self._data.compute(**kwargs))
541 elif not is_duck_array(self._data):
--> 542 self._data = np.asarray(self._data)
543 return self

File ~\anaconda3\envs\Glaciervel\lib\site-packages\xarray\core\indexing.py:653, in MemoryCachedArray.array(self, dtype)
652 def array(self, dtype=None):
--> 653 self._ensure_cached()
654 return np.asarray(self.array, dtype=dtype)

File ~\anaconda3\envs\Glaciervel\lib\site-packages\xarray\core\indexing.py:650, in MemoryCachedArray._ensure_cached(self)
648 def _ensure_cached(self):
649 if not isinstance(self.array, NumpyIndexingAdapter):
--> 650 self.array = NumpyIndexingAdapter(np.asarray(self.array))

File ~\anaconda3\envs\Glaciervel\lib\site-packages\xarray\core\indexing.py:623, in CopyOnWriteArray.array(self, dtype)
622 def array(self, dtype=None):
--> 623 return np.asarray(self.array, dtype=dtype)

File ~\anaconda3\envs\Glaciervel\lib\site-packages\xarray\core\indexing.py:524, in LazilyIndexedArray.array(self, dtype)
522 def array(self, dtype=None):
523 array = as_indexable(self.array)
--> 524 return np.asarray(array[self.key], dtype=None)

File ~\anaconda3\envs\Glaciervel\lib\site-packages\xarray\coding\variables.py:72, in _ElementwiseFunctionArray.array(self, dtype)
71 def array(self, dtype=None):
---> 72 return self.func(self.array)

File ~\anaconda3\envs\Glaciervel\lib\site-packages\xarray\coding\variables.py:139, in _apply_mask(data, encoded_fill_values, decoded_fill_value, dtype)
135 def _apply_mask(
136 data: np.ndarray, encoded_fill_values: list, decoded_fill_value: Any, dtype: Any
137 ) -> np.ndarray:
138 """Mask all matching values in a NumPy arrays."""
--> 139 data = np.asarray(data, dtype=dtype)
140 condition = False
141 for fv in encoded_fill_values:

File ~\anaconda3\envs\Glaciervel\lib\site-packages\xarray\core\indexing.py:524, in LazilyIndexedArray.array(self, dtype)
522 def array(self, dtype=None):
523 array = as_indexable(self.array)
--> 524 return np.asarray(array[self.key], dtype=None)

File ~\anaconda3\envs\Glaciervel\lib\site-packages\xarray\backends\zarr.py:75, in ZarrArrayWrapper.getitem(self, key)
73 else:
74 assert isinstance(key, indexing.OuterIndexer)
---> 75 return array.oindex[key.tuple]

File ~\anaconda3\envs\Glaciervel\lib\site-packages\zarr\indexing.py:669, in OIndex.getitem(self, selection)
667 selection = ensure_tuple(selection)
668 selection = replace_lists(selection)
--> 669 return self.array.get_orthogonal_selection(selection, fields=fields)

File ~\anaconda3\envs\Glaciervel\lib\site-packages\zarr\core.py:1087, in Array.get_orthogonal_selection(self, selection, out, fields)
1084 # setup indexer
1085 indexer = OrthogonalIndexer(selection, self)
-> 1087 return self._get_selection(indexer=indexer, out=out, fields=fields)

File ~\anaconda3\envs\Glaciervel\lib\site-packages\zarr\core.py:1271, in Array._get_selection(self, indexer, out, fields)
1267 self._chunk_getitem(chunk_coords, chunk_selection, out, out_selection,
1268 drop_axes=indexer.drop_axes, fields=fields)
1269 else:
1270 # allow storage to get multiple items at once
-> 1271 lchunk_coords, lchunk_selection, lout_selection = zip(*indexer)
1272 self._chunk_getitems(lchunk_coords, lchunk_selection, out, lout_selection,
1273 drop_axes=indexer.drop_axes, fields=fields)
1275 if out.shape:

ValueError: not enough values to unpack (expected 3, got 0)

@vdevauxchupin
Copy link
Owner

vdevauxchupin commented Mar 2, 2023

Hi @yangt235 ! Could you print the extents of your selection ? You can do that by running:
print(velocity_widget.ymax_proj, velocity_widget.ymin_proj, velocity_widget.xmax_proj, velocity_widget.xmin_proj)

It looks like it is somehow having trouble slicing the y-axis of the datacube.

Your selection looks good from here, you did put individual points covering all the red tiles so it should grab 3 different datacubes from the online AWS server.

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

2 participants