home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 782440858

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
782440858 MDU6SXNzdWU3ODI0NDA4NTg= 4784 Opening a tiff with scale_factor/add_offset attrs then saving as zarr and opening causes a UFuncTypeError 53100696 closed 0     4 2021-01-08T22:45:21Z 2024-02-06T10:40:15Z 2024-02-06T10:40:14Z NONE      

What happened: When opening a geotiff that has scale_factor and add_offset metadata and then saving it as a zarr the scale_factor and add_offset attributes are loaded and then saved as strings. When the resulting zarr is opened xarray attempts to apply the scale_factor and add_offset attributes, but raises an exception because they are of type <U32. ``` /srv/conda/envs/notebook/lib/python3.8/site-packages/xarray/coding/variables.py in _scale_offset_decoding(data, scale_factor, add_offset, dtype) 218 data = np.array(data, dtype=dtype, copy=True) 219 if scale_factor is not None: --> 220 data *= scale_factor 221 if add_offset is not None: 222 data += add_offset

UFuncTypeError: Cannot cast ufunc 'multiply' output from dtype('<U32') to dtype('float32') with casting rule 'same_kind' `` **What you expected to happen**: 1.scale_factorandadd_offsetare converted to floats and applied when the tiff is opened 2. When attempting to applyscale_factorandadd_offset` attributes, check their types and/or cast them to floats.

Minimal Complete Verifiable Example:

python import xarray as xr img = xr.open_rasterio('https://hlssa.blob.core.windows.net/hls/S30/HLS.S30.T10TET.2019001.v1.4_04.tif') img.to_dataset(name='img', promote_attrs=True).to_zarr('./test.zarr', mode='w') xr.open_zarr('./test.zarr').persist()

Anything else we need to know?:

Environment:

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.8.6 | packaged by conda-forge | (default, Dec 26 2020, 05:05:16) [GCC 9.3.0] python-bits: 64 OS: Linux OS-release: 5.4.0-1034-azure machine: x86_64 processor: x86_64 byteorder: little LC_ALL: C.UTF-8 LANG: C.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.6 libnetcdf: 4.7.4 xarray: 0.16.2 pandas: 1.2.0 numpy: 1.19.5 scipy: 1.6.0 netCDF4: 1.5.5.1 pydap: None h5netcdf: 0.8.1 h5py: 2.10.0 Nio: None zarr: 2.6.1 cftime: 1.3.0 nc_time_axis: None PseudoNetCDF: None rasterio: 1.1.8 cfgrib: None iris: None bottleneck: None dask: 2020.12.0 distributed: 2020.12.0 matplotlib: 3.3.3 cartopy: 0.18.0 seaborn: None numbagg: None pint: None setuptools: 49.6.0.post20201009 pip: 20.3.3 conda: None pytest: 6.2.1 IPython: 7.19.0 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4784/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 3 rows from issues_id in issues_labels
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 0.735ms · About: xarray-datasette