home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 289972054

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
289972054 MDU6SXNzdWUyODk5NzIwNTQ= 1842 DataArray read from netcdf with unexpected type 167802 closed 0     1 2018-01-19T13:15:11Z 2018-01-23T20:15:29Z 2018-01-23T20:15:29Z CONTRIBUTOR      

Code Sample, a copy-pastable example if possible

```python import numpy as np import h5netcdf

filename = "mask_and_scale_float32.nc"

with h5netcdf.File(filename, 'w') as f: f.dimensions = {'x': 5} v = f.create_variable('hello', ('x',), dtype=np.uint16) v[:] = np.ones(5, dtype=np.uint16) v[0] = np.uint16(65535) v.attrs['_FillValue'] = np.uint16(65535) v.attrs['scale_factor'] = np.float32(2) v.attrs['add_offset'] = np.float32(0.5)

import xarray as xr

v = xr.open_dataset(filename, mask_and_scale=True)['hello'] print(v.dtype) ```

Problem description

The scale_factor and add_offset being float32, I would expect the result from loading to be a float32 array. However, we get a float64 array instead. A float32 array for a very large dataset is better for faster computations.

Expected Output

float32

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 2.7.5.final.0 python-bits: 64 OS: Linux OS-release: 3.10.0-693.11.6.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: None.None xarray: 0.10.0 pandas: 0.21.0 numpy: 1.13.3 scipy: 0.18.1 netCDF4: 1.1.8 h5netcdf: 0.4.2 Nio: None bottleneck: None cyordereddict: None dask: 0.16.0+37.g1fef002 matplotlib: 2.1.0 cartopy: None seaborn: None setuptools: 38.2.4 pip: 9.0.1 conda: None pytest: 3.1.3 IPython: 5.5.0 sphinx: 1.3.6
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1842/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

  • 0 rows from issues_id in issues_labels
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 0.575ms · About: xarray-datasette