Convert vertices to bounds for nD arrays
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start with cf_xarray/helpers.py and the vertices_to_bounds entry point shown in the traceback. Reproduce the supplied nD DataArray example and compare it with the working single-profile call. Done means the full array with x, y, time, and test dimensions is accepted and converted into the requested bnds and test bounds.
Written by the indexing model from the issue text.
Description
Thank you for developing this amazing package, I am only slowly appreciating its full amazingness.
I am currently trying to convert an array of layer depths that varies in time and space, which represent cell vertices in the vertical into a bound style array.
This is my original array lev_vertices:

For a minimal example you can create a similar array with:
lev_vertices = xr.DataArray(np.arange(9), dims='test').expand_dims(x=2,y=2, time=2)
lev_vertices
I would like to convert the dimension test into bounds.
This works as expected when operating on a single profile:
cf_xarray.vertices_to_bounds(
lev_bounds.isel(time=0,x=0, y=0).load(), out_dims=["bnds", "test"]
)

But I cant figure out how to make this work on the full array...
cf_xarray.vertices_to_bounds(
lev_vertices.load(), out_dims=["bnds", "test"]
)
gives
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-76-4487305bbcdc> in <module>
----> 1 cf_xarray.vertices_to_bounds(
2 lev_vertices.load(), out_dims=["bnds", "test"]
3 )
/scratch/gpfs/jbusecke/conda_tigercpu/envs/aguadv_omz_busecke_2021/lib/python3.8/site-packages/cf_xarray/helpers.py in vertices_to_bounds(vertices, out_dims)
116 )
117 else:
--> 118 raise ValueError(
119 f"vertices format not understood. Got {vertices.dims} with shape {vertices.shape}."
120 )
ValueError: vertices format not understood. Got ('x', 'y', 'time', 'test') with shape (2, 2, 2, 9).
I am wondering if I am missing an option to ignore dimensions here? I was thinking of using xr.map_blocks, but that would impose restrictions on my chunking (which might affect performance). So I first wanted to check in here, and see if there is an easy fix.
- Dominant language
- Python
- Stars
- 181
- Forks
- 49
- Avg merge
- 43m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
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.
More from xarray-contrib/cf-xarray
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
xarray-contrib/cf-xarray#623 ·
-
Consider adding opt-in support for circular axes when calling `bounds_to_vertices` (related to #594) Open
Difficulty 5/5 Over a week Newbie friendliness 38/100
xarray-contrib/cf-xarray#596 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
xarray-contrib/cf-xarray#570 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 15/100
xarray-contrib/cf-xarray#568 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
xarray-contrib/cf-xarray#566 · 2 comments ·
All issues in xarray-contrib/cf-xarray
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
zostera/django-bootstrap4#894 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
use-agent-os/agent-os#3276 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
zilliztech/memsearch#759 ·