Open dopplershift opened 1 year ago
to_array
is adding a new dimension variable
with values a
, b
respectively.
Now when you align these, NaNs are inserted. I would insert a squeeze
after to_array()
@dopplershift does this answer fix your problem?
@dcherian Is this behavior (filling with fill_value
-> inserting Nans) because they share common dimensionality in terms of name, but have different coordinate values? My expectation was something that operated more like numpy broadcasting (repeating values, not filling with anything else).
I can understand how xarray's data model yields this behavior, but in that case it might be good to improve the docs for xarray.broadcast
, because it says nothing about the behavior that (seem to me) mimics xarray.align
.
Is this behavior (filling with fill_value -> inserting Nans) because they share common dimensionality in terms of name, but have different coordinate values?
Yes broadcasting is doing alignment with outer join by default: https://github.com/pydata/xarray/issues/6304. This is conceptually pretty confusing.
I agree we should document this.
What happened?
When running the
broadcast
in the sample code, I end up withnan
in the output when there are not any in the original source array. While I know the construction is really odd (this came from user-submitted code), I'm shocked that it resulted innan
s the resulting broadcasted data and honestly assumed MetPy's code was doing something dumb for quite awhile. I would have expected (regardless of the nature of the coordinates) that the result forbroad_a
be[[1, 2], [1, 2]]
.What did you expect to happen?
No response
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
No response
Environment