Skip to content

Attributing fill_value when writing DataArray with to_netcdf fails #2728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mommebutenschoen opened this issue Jan 30, 2019 · 2 comments
Closed

Comments

@mommebutenschoen
Copy link

Code Sample, a copy-pastable example if possible

This is fairly simple, so I might easily be doing something wrong, I'm failing to attribute a fill_value to a DataArray when writing it to netcdf:

from numpy import ones
from xarry import DataArray
data=DataArray(ones(10),name="testvar")
data.to_netcdf("testvar.nc",encoding={"testvar": {"fill_value': -1.e12}})

throws:

ValueError: unexpected encoding parameters for 'netCDF4' backend:  ['fill_value']
@jhamman
Copy link
Member

jhamman commented Jan 30, 2019

The correct key is _FillValue. This is documented here: http://xarray.pydata.org/en/stable/io.html#scaling-and-type-conversions

The error here could be a bit better though and tell you which encoding parameters it would accept. Any interest in contributing a fix here?

@jhamman
Copy link
Member

jhamman commented Jan 31, 2019

@mommebutenschoen - see #2730

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants