home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 998789248

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/6091#issuecomment-998789248 https://api.github.com/repos/pydata/xarray/issues/6091 998789248 IC_kwDOAMm_X847iFCA 13301940 2021-12-21T13:41:33Z 2021-12-21T13:42:23Z MEMBER

Note that I can't reproduce it using this example:

I could be wrong but it appears that when you introduce a _FillValue in your dataarray, you end up with the same outcome:

```python In [53]: import numpy as np ...: import xarray as xr ...: ...: da = xr.DataArray(np.array([1,2,4294967295], dtype='uint')).rename('test_array')

In [56]: da.encoding['_FillValue'] = 4294967295 ```

```python In [62]: da.to_netcdf("test.nc", engine='netcdf4')

In [63]: !ncdump -h test.nc netcdf test { dimensions: dim_0 = 3 ; variables: uint64 test_array(dim_0) ; test_array:_FillValue = 4294967295ULL ; data:

test_array = 1, 2, _ ; } ```

```python In [64]: d = Dataset("test.nc")

In [65]: d Out[65]: <class 'netCDF4._netCDF4.Dataset'> root group (NETCDF4 data model, file format HDF5): dimensions(sizes): dim_0(3) variables(dimensions): uint64 test_array(dim_0) groups:

In [66]: xr.open_dataset('test.nc') Out[66]: <xarray.Dataset> Dimensions: (dim_0: 3) Dimensions without coordinates: dim_0 Data variables: test_array (dim_0) float64 ... ```

python In [67]: xr.open_dataset('test.nc').test_array Out[67]: <xarray.DataArray 'test_array' (dim_0: 3)> array([ 1., 2., nan]) Dimensions without coordinates: dim_0 Notice that xarray is using np.NaN as a sentinel value for the missing / fill_values. Because np.NaN is a float, this forces the entire array of integers to become floating pointing numbers...

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  1085619598
Powered by Datasette · Queries took 0.9ms · About: xarray-datasette