How do you determine the compression level of a netCDF4 variable (preferably in Python)?
Asked
Active
Viewed 2,309 times
1 Answers
8
Python option using netCDF4 directly:
import netCDF4 as nc4
ds = nc4.Dataset('foo.nc')
var = ds.variables['bar']
print('complevel: %s', var.filters().get('complevel', False))
Note that the filters
method returns a dictionary of all the HDF5 filter parameters
Python option using Xarray and netCDF4 under the hood:
import xarray as xr
ds = xr.open_dataset('foo.nc')
print('complevel: %s', ds['bar'].encoding.get('complevel', False))
Note that the encoding attribute is a dictionary with all the variable encoding attributes for each variable
The command line options is easy too:
ncdump -h -s foo.nc

jhamman
- 5,867
- 19
- 39