Feat: xarray extra dims coordinates - #662
Conversation
|
A potential bug I noticed while testing this feature: if a roi contains an integer (e.g. ? |
I think you're right. I didn't really give any attention to the logical consistency of dimension names, they just have to be called something. 🤷 |
philsmt
left a comment
There was a problem hiding this comment.
I don't think I stumbled on this problem yet, but this seems to be the better solution.
If arbitrary coordinates are a concern here, we should rather make using those more convenient than have the returned dimensions be more useless.
The question around dim_0 or dim_1 if a dimension is omitted is tricky. Given that extra_dims must match the final shape, this is more in line with starting with dim_0. In other words, if we skip dimensions sliced out of the result, extra_dims should also look at the full shape rather than the final one.
| roi4 = () | ||
| darr4 = am0.xarray(roi=roi4, extra_dims=['a', 'b', 'c']) | ||
| assert darr4.shape == (64, 2, 512, 128) | ||
| np.testing.assert_array_equal(darr4.coords['a'], np.arange(0, 2)) |
There was a problem hiding this comment.
I was surprised this works, but it does:
In [11]: 'dim_0' in da.coords
Out[11]: False
In [12]: da.coords['dim_0'].values
Out[12]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
TIL
|
LGTM |
|
thanks |
Adds coordinates for extra dimensions, particularly useful when
roiis defined.