Skip to content

Commit

Permalink
Fix netdcf filter error bad id or parameters or duplicate filter
Browse files Browse the repository at this point in the history
Avoid passing filters to variable-length(vlen) datatypes.
Refer:
- Unidata/netcdf4-python#1205
- Unidata/netcdf-c#2554
- Unidata/netcdf-c#2231
  • Loading branch information
tWangchen committed Jan 25, 2024
1 parent 52e2d4c commit 2ec6058
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions geophys_utils/_netcdf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ def copy(self,
input_variable.dimensions[dimension_index]],
dest_dim_size[input_variable.dimensions[dimension_index]])

if isinstance(dtype, netCDF4._netCDF4.VLType):
# Disallowed filters for variable-length(vlen) datatypes
# https://github.com/Unidata/netcdf4-python/issues/1205
[var_options.pop(key, None) for key in ("compression", "complevel", "shuffle", "fletcher32", "endian")]

options_string = ' with options: %s' % ', '.join(
['%s=%s' % item for item in var_options.items()]) if var_options else ''
logger.debug("Copying variable %s from datatype %s to datatype %s%s" % (variable_name,
Expand Down

0 comments on commit 2ec6058

Please sign in to comment.