Skip to content
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

cdf_to_xarray to_netcdf fails with ValueError #276

Open
berniegsfc opened this issue Sep 11, 2024 · 1 comment
Open

cdf_to_xarray to_netcdf fails with ValueError #276

berniegsfc opened this issue Sep 11, 2024 · 1 comment

Comments

@berniegsfc
Copy link

The following code:

from cdflib.xarray import cdf_to_xarray,xarray_to_cdf
import xarray as xr

# https://cdaweb.gsfc.nasa.gov/pub/data/ace/mag/level_2_cdaweb/mfi_h0/1997/ac_h0_mfi_19970902_v04.cdf
filename = 'ac_h0_mfi_19970902_v04.cdf'

data = cdf_to_xarray(filename)

#xarray_to_cdf(data, 'data.cdf')

data.to_netcdf('data.nc')

fails with

ValueError: failed to prevent overwriting existing key units in attrs on variable 'Epoch'. This is probably an encoding field used by xarray to describe how a variable is serialized. To proceed, remove this key from the variable's attributes manually.

Is this a problem with the xarray.Dataset produced by cdf_to_xarray or a problem with xarray.Dataset.to_netcdf()?

@berniegsfc
Copy link
Author

I've tried different versions of cdflib, xarray, and python and it fails the same in all. But for the record, the last test was with

  • cdflib 1.3.1
  • xarray 2024.7.0
  • python 3.10.5

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

1 participant