0

I have a .nc file with a group structure, one of the groups containing a variable I need to delete.

Using xarray, if I want to delete the variable I can only extract its group as a new .nc file.

ds = xr.load_dataset(path_test,group='/data_01/ku')
ds = ds.drop_vars(["ssh"])
ds.to_netcdf(path_test, mode="a", group='/data_01/ku')

Using bash command ncks (from nco) doing this : ncks -x -g data_01/ku -v ssh in.nc out.nc I get a memory error.

Does anyone know how to delete one specific variable while keeping the complete group structure of the file ?

Thanks guys

benben
  • 1

1 Answers1

0

The ncks command you tried looks correct, and such commands work for me. Try adding the -C switch just in case:

ncks -O -x -C -g g1/g1g1 -v ppc_dbl ~/nco/data/in_grp.nc ~/foo.nc

Seems like you got unlucky, or possibly are employing an old NCO version?

Charlie Zender
  • 5,929
  • 14
  • 19