Skip to content

[FEATURE]: to_netcdf and additional keyword arguments #6153

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

Open
hmaarrfk opened this issue Jan 11, 2022 · 2 comments
Open

[FEATURE]: to_netcdf and additional keyword arguments #6153

hmaarrfk opened this issue Jan 11, 2022 · 2 comments

Comments

@hmaarrfk
Copy link
Contributor

Is your feature request related to a problem?

I briefly tried to see if any issue was brought up but couldn't.

I'm hoping to be able to pass additional keyword arguments to the engine when using to_netcdf. https://xarray.pydata.org/en/stable/generated/xarray.open_dataset.html

However, it doesn't seem to easy to do so.

Similar to how open_dataset has an additional **kwargs parameter, would it be reasonable to add a similar parameter, maybe engine_kwargs to the to_netcdf to allow users to pass additional parameters to the engine?

Describe the solution you'd like

import xarray as xr
import numpy as np

dataset = xr.DataArray(
    data=np.zeros(3),
    name="hello"
).to_dataset()

dataset.to_netcdf("my_file.nc", engine="h5netcdf", engine_kwargs={"decode_vlen_strings=True"})

Describe alternatives you've considered

One could forward the additional keyword arguments with **kwargs. I just feel like this makes things less "explicit".

Additional context

h5netcdf emits a warning that is hard to disable without passing a keyword argument to the constructor.
h5netcdf/h5netcdf#132

Also, for performance reasons, it might be very good to tune things like the storage data alignment.

@kmuehlbauer
Copy link
Contributor

@hmaarrfk Xref with implementation details: #4893

@hmaarrfk
Copy link
Contributor Author

Thank you @kmuehlbauer for the explicit PR link.

I do plan on adding alignment features to h5py then to bring it toward h5netcdf. So I think something like this will be useful in the future.

Feature request link:
h5py/h5py#2034

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

No branches or pull requests

3 participants