-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
XArray does not support Latin characters in netCDF file names #9282
Comments
Thanks for opening your first issue here at xarray! Be sure to follow the issue template! |
I get an error in (also note I needed to change the MCVE path, worth updating the example)
INSTALLED VERSIONScommit: 42ed6d3 xarray: 2024.3.1.dev31+gb9163a6f |
Yes, there is an error in the path. Sorry about that. What I see is that Windows can't manage without the encoding parameter or the file created on the file system is bépo.nc. With Linux, you don't need to specify it, the file created is correct. Creating a netCDF file with Latin-1 encoding doesn't cause an error, but it ends up as b?po.nc on the file system I don't have a Mac, so I can't do the test. But it's possible that encoding on Mac is managed differently from Windows and Linux... |
Is the example you posted correct? If not, could you update it? |
Example fixed (using temporary folder from context manager) |
Thanks. FYI I still get this error — I'm guessing that's down to it being a Mac vs Linux issue...
|
This test demonstrates the issue on a Windows platform configured as CP1252. |
Forwarding |
What happened?
When you try to open an existing netCDF file named "bépo.nc", for example, you get the following error:
What did you expect to happen?
Internally, netCDF transforms the file path into an array of bytes.
This transformation can be configured by setting the appropriate encoding in netCDF4.Dataset constructor
What I expect is to be able to pass this encoding to netCDF when the file is opened with xarray.
Perhaps the solution would be to send the encoding along with the backend_kwargs parameter :
Transmitting the encoding would also be necessary in the to_netcdf() function.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
No response
Environment
INSTALLED VERSIONS
commit: None
python: 3.10.13 | packaged by conda-forge | (main, Oct 26 2023, 18:01:37) [MSC v.1935 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 158 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('fr_FR', 'cp1252')
libhdf5: 1.14.0
libnetcdf: 4.9.1
xarray: 2024.6.0
pandas: 2.2.2
numpy: 1.26.4
scipy: 1.13.1
netCDF4: 1.6.3
pydap: None
h5netcdf: None
h5py: 3.9.0
zarr: None
cftime: 1.6.4
nc_time_axis: None
iris: None
bottleneck: 1.4.0
dask: 2024.7.1
distributed: 2024.7.1
matplotlib: 3.9.1
cartopy: None
seaborn: 0.13.2
numbagg: None
fsspec: 2024.6.1
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 71.0.4
pip: 24.0
conda: 24.5.0
pytest: 8.3.2
mypy: None
IPython: None
sphinx: 7.4.7
The text was updated successfully, but these errors were encountered: