Is it possible to delete a variable from a Scientific.IO.NetCDF.NetCDFFile
? If a file is opened like so:
nc = Scientific.IO.NetCDF.NetCDFFile("File.nc", "a")
neither a
del nc.variables["var"]
nor a
nc.variables["var"] = None
will delete the variable var
.
Thx in advance for any insight.
The simple answer is that you can not delete a variable. This is a "feature" of the NetCDF C-API and is not a shortcoming of Scientific.IO.NetCDF or any of the other python netcdf modules.
From the official NetCDF user guide: Attributes are more dynamic than variables or dimensions; they can be deleted and have their type, length, and values changed after they are created, whereas the netCDF interface provides no way to delete a variable or to change its type or shape.
The problem can be solved indirectly, by copying everything except the offending variable to a new NetCDF file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With