How to align xarray dimensions without calculation? #9564
Replies: 1 comment
-
First things first, while I did spend the time to look at the StackOverflow question, I do believe that by deliberately not copying over the actual question (which was not that hard, I just did it for you) you reduce the probability that someone will spend the time to help you – maintainer time is very scarce, and any hurdle you put in the way (however small it may seem) may be one too many. With that out of the way, I believe what you're missing is that In [6]: y, x = xr.broadcast(y_da, x_da)
...: expected1 = y_da["y"] * (x_da["x"] / x_da["x"]).fillna(1)
...: xr.testing.assert_equal(y["y"], expected1) or by masking the broadcasted values: In [7]: expected2 = y_da["y"] * x_da["x"] / x_da["x"]
...: xr.testing.assert_equal(y["y"].where(x["x"].notnull()), expected2) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I already have detailed problem description here so I hope I don't need to re-describe.
It seems like any calculation auto triggers such alignment, however, I'm not able to efficiently obtain the same result with any of the align methods.
Edit: for completeness, here's the description posted on StackOverflow:
Beta Was this translation helpful? Give feedback.
All reactions