Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compression level of netCDF4 variable

How do you determine the compression level of a netCDF4 variable (preferably in Python)?

like image 741
sfinkens Avatar asked Dec 18 '25 21:12

sfinkens


1 Answers

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
like image 132
jhamman Avatar answered Dec 20 '25 11:12

jhamman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!