[FEATURE]: to_netcdf and additional keyword arguments
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
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.
https://github.com/h5netcdf/h5netcdf/issues/132
Also, for performance reasons, it might be very good to tune things like the storage data alignment.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the existing to_netcdf API with open_dataset, especially how each handles engine arguments. Check how the h5netcdf engine receives constructor options and determine the intended keyword-argument shape; done means to_netcdf can forward engine-specific options without breaking existing calls and the behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100