-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Some simple broadcast_dim method? #2267
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
Comments
Is exand dims not what you are looking for? |
No, I'd need something like np.tile. |
As an explanation: I recognized that np.broadcast_to converts the DataArray into a numpy one. I tried: DataArray.expand_dims("new_dim").isel("new_dim", np.repeat(0, target_dim_size)) but this really looks ugly and I'm not sure about the performance implications of this. |
We could add an optional |
@shoyer so there is no direct xarray equivalent to np.broadcast_to? |
We have |
Maybe related: Consider the following example to calculate pairwise distances:
numpy automatically broadcasts the one-dimensions to get 4x4 matrices and substracts them. As far as I can see, this example is really hard to recreate with xarray, since there is nearly no possibility to add a new dimension to |
let's continue the repeated dimension discussion over in #1378 |
This should be fixed by the latest |
I've already found xr.broadcast(arrays).
However, I'd like to just add a new dimension with a specific size to one DataArray.
I could not find any simple option to do this.
If there is no such option:
The text was updated successfully, but these errors were encountered: