issues: 351846466
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
351846466 | MDU6SXNzdWUzNTE4NDY0NjY= | 2374 | Suggestion: Add option for default_fillvals to open_dataset | 5948670 | open | 0 | 2 | 2018-08-18T19:47:53Z | 2021-07-17T19:59:43Z | CONTRIBUTOR | Hi, May I suggest having a default_fillvals option to xarray.open_dataset (and xarray.open_dataarray)? My problem: I have netcdf data containing flagged data, that is flagged with the netcdf default fill value of 9.96...e+36. But xarray (0.10.8) only masks arrays that have an explicit fill_value set: ```python import netCDF4, xarray, numpy nc = netCDF4.Dataset('test.nc', 'w', format='NETCDF4') nc.createDimension('x', 3) var1 = nc.createVariable('var1', 'f8', ('x',)) var2 = nc.createVariable('var2', 'f8', ('x',), fill_value=netCDF4.default_fillvals['f8']) var1[:] = numpy.array([0., 1., netCDF4.default_fillvals['f8']]) var2[:] = numpy.array([0., 1., netCDF4.default_fillvals['f8']]) print('netCDF4 var1', nc.variables['var1'][:]) print('netCDF4 var2', nc.variables['var2'][:]) nc.close() ds = xarray.open_dataset('test.nc') print('xarray var1', ds.var1[:]) print('xarray var2', ds.var2[:]) ``` The problem is, that ds.var1 and ds.var2 are interpreted differently, although netCDF4 shows both as masked:
I agree, that it is a good default, to mask data, only if the fill_value attribute is set. But I think it would be useful to be able to pass default_fill values to open_dataset to enable reading data, that uses the implicit default values. What do you think? |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2374/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | issue |