XCube NetCDF4 export bug

Hi,

I’m currently testing the latest XCube release (0.6.1) and found a potential bug in the netcdf4 export function. When I try to store an xcube with xcube.core.dsio.write_cube and format_name='netcdf4', I get this error message:

TypeError: illegal data type for attribute b’history’, must be one of dict_keys([‘S1’, ‘i1’, ‘u1’, ‘i2’, ‘u2’, ‘i4’, ‘u4’, ‘i8’, ‘u8’, ‘f4’, ‘f8’]), got O

The cube was downloaded with the sentinel hub plug in. See demo code below. Any suggestions? Thanks in advance!

Cheers, Philipp

PS: would this be more suitable to be posted as an issue in gitlab?

PPS: code attached – sorry, can’t upload .py files here…

from xcube_sh.cube import open_cube as open_cube_sh
from xcube_sh.config import CubeConfig
from xcube.core.dsio import write_cube

bbox = -122.269, 44.671, -122.128, 44.741

spatial_res = 0.00036   # = 40 meters in degree>

cube_config = CubeConfig(dataset_name='S2L2A',
                         band_names=['B04', 'B05', 'B06', 'B11', 'SCL', 'CLD'],
                         tile_size=[512, 512],
                         bbox=bbox,
                         spatial_res=spatial_res,
                         time_range=['2020-08-01', '2020-09-01'],
                         time_tolerance='1H')

cube = open_cube_sh(cube_config)

write_cube(cube, 'cube.nc', format_name='netcdf4')

That’s a bug! Thanks for reporting.

An even better place is the xcube-sh Issue Tracker.

Workaround:

del cube.attrs['history']
write_cube(cube, 'cube.nc', format_name='netcdf4')

Regards
Norman