Skip to content

error from netCDF in cf.write #960

Description

@JonathanGregory

I am processing some CMIP6 data on Jasmin (making time-means). I get the following error. I realise that you probably need more background to diagnose it, but perhaps it's obvious from this much information? As a result of the error, the file is not properly written, just the start of it.

Thanks. Jonathan

Traceback (most recent call last):
  File "/home/users/jonathan/bin/grouptime", line 97, in <module>
    cf.write(n,ofile)
  File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.12/mf3-25.3.0-3/envs/jaspy3.12-mf3-25.3.0-3-v20250704/lib/python3.12/site-packages/cfdm/read_write/write.py", line 826, in __new__
    netcdf.write(
  File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.12/mf3-25.3.0-3/envs/jaspy3.12-mf3-25.3.0-3-v20250704/lib/python3.12/site-packages/cfdm/decorators.py", line 171, in verbose_override_wrapper
    return method_with_verbose_kwarg(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.12/mf3-25.3.0-3/envs/jaspy3.12-mf3-25.3.0-3-v20250704/lib/python3.12/site-packages/cfdm/read_write/netcdf/netcdfwrite.py", line 5232, in write
    self._file_io_iteration(
  File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.12/mf3-25.3.0-3/envs/jaspy3.12-mf3-25.3.0-3-v20250704/lib/python3.12/site-packages/cfdm/read_write/netcdf/netcdfwrite.py", line 5478, in _file_io_iteration
    self._write_global_attributes(fields)
  File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.12/mf3-25.3.0-3/envs/jaspy3.12-mf3-25.3.0-3-v20250704/lib/python3.12/site-packages/cfdm/read_write/netcdf/netcdfwrite.py", line 4610, in _write_global_attributes
    g["netcdf"].setncattr(
  File "src/netCDF4/_netCDF4.pyx", line 3087, in netCDF4._netCDF4.Dataset.setncattr
  File "src/netCDF4/_netCDF4.pyx", line 1858, in netCDF4._netCDF4._set_att
  File "src/netCDF4/_netCDF4.pyx", line 6733, in netCDF4._netCDF4._strencode
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 61-63: surrogates not allowed

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions