home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 307444427

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
307444427 MDU6SXNzdWUzMDc0NDQ0Mjc= 2005 What is the recommended way to do proper compression/ scaling of vars? 13906519 closed 0     3 2018-03-21T22:45:05Z 2020-03-22T10:38:42Z 2020-03-22T09:38:42Z NONE      

Code Sample, a copy-pastable example if possible

```python if level == 'HIGH': ctype = 'i4' else: ctype = 'i2' max_int = np.iinfo(ctype).max min_val = ds[data_var].min().values max_val = ds[data_var].max().values offset_ = min_val

                if max_val - min_val == 0:
                    scale_ = 1.0
                else:
                    scale_ = float(max_int / (max_val - min_val))

```

Problem description

Using i2 I mostly get proper output. However, when I try to use i4 or i8 I don't get anything resembling my input... I write to file with format='NETCDF4_CLASSIC'

My DataArray encoding is: python ENCODING = dict(dtype=ctype, add_offset=offset_, scale_factor=scale_, zlib=True, _FillValue=-9999) ds[data_var] = ds[data_var].astype(ctype) #, casting='unsafe') ds[data_var].extra.update_encoding(ENCODING)

extra is added to DataArray like so: ```python @xr.register_dataarray_accessor('extra') class TileAccessor(object): def init(self, xarray_obj): self._obj = xarray_obj

def update_encoding(self, *args, **kwargs):
    """Update the encoding in a xarray DataArray"""
    def _update_encoding(obj, *args, **kwargs):
        obj.encoding.update(*args, **kwargs)
        return obj
    self._obj.pipe(_update_encoding, *args, **kwargs)

```

Expected Output

Not sure if one is supposed to use types other than i2 for compressed storage? Or is my approach wrong?

Output of xr.show_versions()

xarray: 0.10.0 pandas: 0.22.0 numpy: 1.14.2 scipy: 1.0.0 netCDF4: 1.3.1 h5netcdf: None Nio: None bottleneck: None cyordereddict: None dask: None matplotlib: 2.1.2 cartopy: None seaborn: 0.8.1 setuptools: 38.5.2 pip: 9.0.1 conda: None pytest: 3.4.2 IPython: 6.2.1 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2005/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

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