Multiply along a specific dimension #7066
Replies: 2 comments 1 reply
-
Hi @adelezaini, I'm a bit confused since you're trying to make a simple operation between two DataArrays and the example that you mention is about element-wise product of a DataArray with an unlabelled numpy array. If you want to perform an element-wise operation like
There's already DataArray.prod but it serves a different purpose, i.e., compute the product of array elements over a given dimension and return a reduced DataArray (like |
Beta Was this translation helpful? Give feedback.
-
@adelezaini I'm moving this issue to discussion Q&A as to my understanding Xarray already supports the operation that you describe here. Please let me know if I misunderstood your problem. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem?
I was trying to make a simple operation for two DataArrays: applying the
*
operation along a single common dimension, but I couldn't find any simple and straight-forward way to apply it. This is a problem that can be faced very often when having weights to apply to a Dataset/DataArray, as in this example.Describe the solution you'd like
I believe a very useful implementation would be adding
xr.mult(*arrays, dim, *args)
- orxr.prod
or similar -, exactly as it is for thexr.dot(*arrays, dim, *args)
, but instead of applying the@
product it would apply the*
product.Describe alternatives you've considered
No response
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions