Documentation request: add examples for carrying out "ncecat" in xarray
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
In climate science, a very common task involves concatenating NetCDF files with identical variables, dimensions, and coordinates along a brand new "ensemble member" or "record" dimension. With the NetCDF Operators, this is accomplished using ncecat.
MCVE Code Sample
Currently, it seems the correct way to do this in xarray is with xarray.combine_nested as follows:
import xarray as xr
files = ['member1.nc', 'member2.nc', ...]
ds = xr.open_mfdataset(
files,
combine='nested',
concat_dim='record',
)
Problem Description
While this works, there does not seem to be any mention of this use case in the combine_nested or open_mfdataset docs... and using combine='nested' to concatenate along a brand new dimension feels quite unintuitive to me.
It would be nice to have examples in combine_nested and/or open_mfdataset with this special usage or mention the possibility of creating brand new dimensions with concat_dim. For example:
In [1]: import xarray as xr
...: datasets = [
...: xr.Dataset({'temp': (('x', 'y'), np.random.rand(10, 20))})
...: for i in range(3)
...: ]
...: xr.combine_nested(datasets, concat_dim='record')
Out[1]:
<xarray.Dataset>
Dimensions: (record: 3, x: 10, y: 20)
Dimensions without coordinates: record, x, y
Data variables:
temp (record, x, y) float64 0.32 0.4897 0.2659 ... 0.3485 0.0251 0.399
Output of xr.show_versions()
n/a
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 with the documentation for xarray.combine_nested and xarray.open_mfdataset, then run the supplied MCVE for concatenating datasets along a new record dimension. Done means the relevant documentation includes a clear example or explanation of this usage, with the example rendering correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100