xcube-dev / xcube

xcube is a Python package for generating and exploiting data cubes powered by xarray, dask, and zarr.
https://xcube.readthedocs.io/
MIT License
201 stars 20 forks source link

Support other datatypes eg.integers for coordinates #910

Open TejasMorbagal opened 1 year ago

TejasMorbagal commented 1 year ago

Describe the bug When attempting to process a dataset with xcube, I encountered an issue where xcube seems to naively expect the coordinates to be provided as floating-point numbers. However, my dataset has coordinates in the format of int32.

Expected behavior xcube should be able to process a dataset with integer coordinates.

Screenshots If applicable, add screenshots to help explain your problem. Screenshot from 2023-10-25 15-22-50

stack-trace datset 404 GET /viewer/config/config.json (127.0.0.1): xcube viewer has not been been configured 404 GET /viewer/config/config.json (127.0.0.1) 5.92ms Skipping dataset d69b6d08-fa9a-4899-8f01-5d2465b9c1c8: Cannot cast ufunc 'subtract' output from dtype('float64') to dtype('int32') with casting rule 'same_kind' Traceback (most recent call last): File "/home/conda/deepesdl/4f055d4cb9f5a7bb59c11d4f960211d16d612f0f49fe5f6f4a110ccac09352f7-20230630-130445-100057-279-xcube-1.1.2/lib/python3.11/site-packages/xcube/webapi/datasets/controllers.py", line 137, in get_datasets get_dataset(ctx, ds_id, File "/home/conda/deepesdl/4f055d4cb9f5a7bb59c11d4f960211d16d612f0f49fe5f6f4a110ccac09352f7-20230630-130445-100057-279-xcube-1.1.2/lib/python3.11/site-packages/xcube/webapi/datasets/controllers.py", line 200, in get_dataset dataset_bounds = get_dataset_bounds(ds) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/conda/deepesdl/4f055d4cb9f5a7bb59c11d4f960211d16d612f0f49fe5f6f4a110ccac09352f7-20230630-130445-100057-279-xcube-1.1.2/lib/python3.11/site-packages/xcube/core/geom.py", line 739, in get_dataset_bounds x_min -= 0.5 * delta File "/home/conda/deepesdl/4f055d4cb9f5a7bb59c11d4f960211d16d612f0f49fe5f6f4a110ccac09352f7-20230630-130445-100057-279-xcube-1.1.2/lib/python3.11/site-packages/xarray/core/_typed_ops.py", line 312, in isub return self._inplace_binary_op(other, operator.isub) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/conda/deepesdl/4f055d4cb9f5a7bb59c11d4f960211d16d612f0f49fe5f6f4a110ccac09352f7-20230630-130445-100057-279-xcube-1.1.2/lib/python3.11/site-packages/xarray/core/dataarray.py", line 4645, in _inplace_binary_op f(self.variable, other_variable) File "/home/conda/deepesdl/4f055d4cb9f5a7bb59c11d4f960211d16d612f0f49fe5f6f4a110ccac09352f7-20230630-130445-100057-279-xcube-1.1.2/lib/python3.11/site-packages/xarray/core/_typed_ops.py", line 518, in isub return self._inplace_binary_op(other, operator.isub) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/conda/deepesdl/4f055d4cb9f5a7bb59c11d4f960211d16d612f0f49fe5f6f4a110ccac09352f7-20230630-130445-100057-279-xcube-1.1.2/lib/python3.11/site-packages/xarray/core/variable.py", line 2717, in _inplace_binary_op self.values = f(self_data, other_data) ^^^^^^^^^^^^^^^^^^^^^^^^ numpy.core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'subtract' output from dtype('float64') to dtype('int32') with casting rule 'same_kind' No datasets provided for current user.