From dd345b8ff5483adc3dda8c2bcb4555ef42434bb5 Mon Sep 17 00:00:00 2001 From: Simon Liu Date: Thu, 30 Nov 2023 09:48:34 -0800 Subject: [PATCH] update group handling for unicode data types --- podaac/subsetter/group_handling.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/podaac/subsetter/group_handling.py b/podaac/subsetter/group_handling.py index 737ffdbd..bfb47020 100644 --- a/podaac/subsetter/group_handling.py +++ b/podaac/subsetter/group_handling.py @@ -190,6 +190,8 @@ def _rename_variables(dataset: xr.Dataset, base_dataset: nc.Dataset, start_date, elif variable.dtype in ['|S1', '|S2']: var_group.createVariable(new_var_name, variable.dtype, var_dims, fill_value=fill_value) else: + if np.issubdtype(variable.dtype, np.unicode_): + comp_args["zlib"] = False var_group.createVariable(new_var_name, variable.dtype, var_dims, fill_value=fill_value, **comp_args) # Copy attributes @@ -197,7 +199,7 @@ def _rename_variables(dataset: xr.Dataset, base_dataset: nc.Dataset, start_date, # Copy data var_group.variables[new_var_name].set_auto_maskandscale(False) - if variable.dtype in ['|S1', '|S2']: + if variable.dtype in ['|S1', '|S2'] or np.issubdtype(variable.dtype, np.unicode_): var_group.variables[new_var_name][:] = variable.values else: var_group.variables[new_var_name][:] = var_data