Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to reduce the output size with to_netcdf? #865

Closed
simon3122 opened this issue Jun 2, 2016 · 6 comments
Closed

How to reduce the output size with to_netcdf? #865

simon3122 opened this issue Jun 2, 2016 · 6 comments

Comments

@simon3122
Copy link

simon3122 commented Jun 2, 2016

Hello,

The options of the ds.to_netcdf method allow several netcdf modes and a control of several options (missing values, format...).

Our current options are as follows:

ds.to_netcdf(filenam,
'w',
'NETCDF4',
'netcdf4',
encoding={ vkey2:{'dtype': float32,'_FillValue':0}})

Whereas the input size is 6 GiB / variable, the output size reaches 23 GiB / variable.

What is the best strategy in the options to reduce the netcdf output size, other than changing the format (in my exercice we have float32)?
In particular, is there some interest in modifying the deprecated "missing_values" attribute?

Thank you in advance,

@fmaussion
Copy link
Member

NetCDF and xarray support lossy compression (extremely efficient and fast with the cost of numerical precision loss) or gzip compression (without precision loss but with slower I/O - especially when reading chunks of data). You can have a look at the documentation about NetCDF I/O here.

@marcosrdac
Copy link

How do I get lossy compression? I could not find it on the documentation :(

@dcherian
Copy link
Contributor

Please read the documentation

@marcosrdac
Copy link

Thanks, I thought there were some methods to choose from or something like that. For future readers, scale_factor seems to be used to control compression loss.

@dcherian dcherian reopened this Aug 19, 2022
@github-actions github-actions bot added the needs triage Issue that has not been reviewed by xarray team member label Aug 19, 2022
@dcherian
Copy link
Contributor

dcherian commented Aug 19, 2022

You can also use zlib and complevel

@andersy005 andersy005 removed the needs triage Issue that has not been reviewed by xarray team member label Aug 19, 2022
@marcosrdac
Copy link

You can also use zlib and complevel

Just making it clear: those would configure lossless compression of netcdf4 lib, not lossy compression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants