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

cfdm.write "compress" parameter doesn't work for field with string-type coordinates (netCDF4==1.6.0) #199

Closed
davidhassell opened this issue Jul 18, 2022 · 0 comments · Fixed by #200
Labels
bug Something isn't working netCDF write Relating to writing netCDF datasets
Milestone

Comments

@davidhassell
Copy link
Contributor

davidhassell commented Jul 18, 2022

Using the netCDF file cfdm/test/test_file.nc (created by cfdm/test/setup_create_field.py), that has vlen string type coordinates, and netCDF4 version 1.6.0 we get:

>>> import cfdm
>>> f = cfdm.read('test_file.nc')[0]
>>> cfdm.write(f, 'delme.nc')               # OK
>>> cfdm.write(f, 'delme.nc', compress=4)   # Not OK
Traceback (most recent call last):
  File "/home/david/NCAS-CMS/cfdm/cfdm/read_write/netcdf/netcdfwrite.py", line 2670, in _write_netcdf_variable
    self._createVariable(**kwargs)
  File "/home/david/NCAS-CMS/cfdm/cfdm/read_write/netcdf/netcdfwrite.py", line 2402, in _createVariable
    g["nc"][ncvar] = g["netcdf"].createVariable(**kwargs)
  File "src/netCDF4/_netCDF4.pyx", line 2838, in netCDF4._netCDF4.Dataset.createVariable
  File "src/netCDF4/_netCDF4.pyx", line 4003, in netCDF4._netCDF4.Variable.__init__
  File "src/netCDF4/_netCDF4.pyx", line 1965, in netCDF4._netCDF4._ensure_nc_success
RuntimeError: NetCDF: Filter error: bad id or parameters or duplicate filter

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/david/NCAS-CMS/cfdm/cfdm/read_write/write.py", line 522, in write
    netcdf.write(
  File "/home/david/NCAS-CMS/cfdm/cfdm/decorators.py", line 171, in verbose_override_wrapper
    return method_with_verbose_kwarg(*args, **kwargs)
  File "/home/david/NCAS-CMS/cfdm/cfdm/read_write/netcdf/netcdfwrite.py", line 4730, in write
    self._file_io_iteration(
  File "/home/david/NCAS-CMS/cfdm/cfdm/read_write/netcdf/netcdfwrite.py", line 5002, in _file_io_iteration
    self._write_field_or_domain(f)
  File "/home/david/NCAS-CMS/cfdm/cfdm/read_write/netcdf/netcdfwrite.py", line 3586, in _write_field_or_domain
    coordinates = self._write_auxiliary_coordinate(
  File "/home/david/NCAS-CMS/cfdm/cfdm/read_write/netcdf/netcdfwrite.py", line 2143, in _write_auxiliary_coordinate
    self._write_netcdf_variable(
  File "/home/david/NCAS-CMS/cfdm/cfdm/read_write/netcdf/netcdfwrite.py", line 2694, in _write_netcdf_variable
    raise RuntimeError(message)
RuntimeError: Can't create variable in NETCDF4 file from <AuxiliaryCoordinate: greek_letters(10) > (NetCDF: Filter error: bad id or parameters or duplicate filter)
>>> 

Everything is fine for netCDF4<1.6.0.

This is related to Unidata/netcdf4-python#1175 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working netCDF write Relating to writing netCDF datasets
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant