vergauwenthomas / PyFa

Python wrapper on Rfa using xarray
MIT License
0 stars 0 forks source link

Bug: collection xarray to_netcdf #48

Closed kobebryant432 closed 6 months ago

kobebryant432 commented 6 months ago

Saving a collection's (after combined with validate) xarray to netcdf does not work.

new_collection.ds.to_netcdf()

The following error is thrown:

File "/readonly/dodrio/apps/RHEL8/zen2-ib/software/SciPy-bundle/2022.05-foss-2022a/lib/python3.10/site-packages/scipy/io/_netcdf.py", line 555, in _write_att_values
    nc_type = REVERSE[values.dtype.char, values.dtype.itemsize]
KeyError: ('U', 64)

I think the attribute type are not compatible.

vergauwenthomas commented 6 months ago

This seems to be an issue with the engine you use (probably scipy) while it should be netcdf4. I am using netcdf4 and never had this issue.

i will add netcdf4 to the dependencies, and specify the engine in the save nc function like this:

  # convert to nc
    xrdata.to_netcdf(path=target_file,
                      engine='netcdf4',
                      mode='w',
                      **kwargs)

I found this engine issue here: https://github.com/pydata/xarray/issues/3374