html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/5620#issuecomment-883320031,https://api.github.com/repos/pydata/xarray/issues/5620,883320031,IC_kwDOAMm_X840pmTf,27021858,2021-07-20T11:32:45Z,2021-07-20T11:32:45Z,NONE,"@keewis thanks for your further explanation.
In the mean time I have built a work-around because I recognized that xarray tries to keep the 2D arrays. nump reverts a 1D index array.
Thanks","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,947796627
https://github.com/pydata/xarray/issues/5620#issuecomment-883232093,https://api.github.com/repos/pydata/xarray/issues/5620,883232093,IC_kwDOAMm_X840pQ1d,14808389,2021-07-20T09:09:31Z,2021-07-20T09:44:42Z,MEMBER,"Actually, I can reproduce this with the example `""rasm""` dataset:
```python
In [2]: import xarray as xr
...:
...: rasm = xr.tutorial.open_dataset(""rasm"").load()
...:
...: min_lat = 17
...: max_lat = 18
...: min_lon = 189
...: max_lon = 190
...:
...: mask = (
...: (rasm.xc <= max_lon) & (rasm.xc > min_lon)
...: & (rasm.yc <= max_lat) & (rasm.yc > min_lat)
...: )
...:
...: subset = rasm.xc.where(mask, drop=True)
...: display(subset.max(), subset.xc.max())
...: display(subset, subset.xc)
array(189.89982737)
array(190.07286203)
array([[189.55836619, 189.72833384, 189.89982737, nan],
[189.30253733, 189.47184886, 189.64270151, 189.81509531],
[189.04515208, 189.21383799, 189.38403452, nan]])
Coordinates:
xc (y, x) float64 189.6 189.7 189.9 190.1 ... 189.0 189.2 189.4 189.6
yc (y, x) float64 17.02 17.27 17.51 17.76 ... 17.34 17.59 17.84 18.08
Dimensions without coordinates: y, x
Attributes:
long_name: longitude of grid cell center
units: degrees_east
array([[189.55836619, 189.72833384, 189.89982737, 190.07286203],
[189.30253733, 189.47184886, 189.64270151, 189.81509531],
[189.04515208, 189.21383799, 189.38403452, 189.55578745]])
Coordinates:
xc (y, x) float64 189.6 189.7 189.9 190.1 ... 189.0 189.2 189.4 189.6
yc (y, x) float64 17.02 17.27 17.51 17.76 ... 17.34 17.59 17.84 18.08
Dimensions without coordinates: y, x
Attributes:
long_name: longitude of grid cell center
units: degrees_east
```
which makes it pretty obvious why this fails: `drop=True` drops as much as possible, but to really drop everything we would have to collapse the result to 1D. To work around that, `.where` sets the data to `nan` where necessary, but only for data variables (as coordinates still need to label the masked values).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,947796627
https://github.com/pydata/xarray/issues/5620#issuecomment-883226384,https://api.github.com/repos/pydata/xarray/issues/5620,883226384,IC_kwDOAMm_X840pPcQ,14808389,2021-07-20T09:01:34Z,2021-07-20T09:01:34Z,MEMBER,"@meteoDaniel, it ultimately comes down to how much time a maintainer is willing to spend on a single issue, with self-contained, small examples being much easier to debug (and there are a few other reasons in the blog post linked to by @max-sixty).
That said, I can reproduce your issue, which apparently is independent of the way the mask is constructed:
```python
mask = (
(latitudes <= maxLat)
& (latitudes > minLat)
& (longitudes <= maxLon)
& (longitudes > minLon)
)
ds.where(xr.DataArray(mask, dims=(""y"", ""x"")), drop=True).latitude.max() # 49.30
latitudes[mask].max() # 48.92
```
However, if I do
```python
subset = ds.latitude.where(xr.DataArray(mask, dims=(""y"", ""x"")), drop=True)
subset.max()
```
I get the same result as with pure `numpy`.
Interestingly, `xr.testing.assert_identical(subset, subset.latitude)` raises...","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,947796627
https://github.com/pydata/xarray/issues/5620#issuecomment-883085722,https://api.github.com/repos/pydata/xarray/issues/5620,883085722,IC_kwDOAMm_X840otGa,5635139,2021-07-20T05:50:39Z,2021-07-20T05:50:48Z,MEMBER,No stress — I know it can be unclear at first — but can you show the same result without requiring downloading data and with a smaller example? Here's the link in the issue template I was referring to: http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,947796627
https://github.com/pydata/xarray/issues/5620#issuecomment-883077601,https://api.github.com/repos/pydata/xarray/issues/5620,883077601,IC_kwDOAMm_X840orHh,27021858,2021-07-20T05:39:10Z,2021-07-20T05:40:01Z,NONE,"@max-sixty I do not know what you want? You can download the file and I have placed all the code you need to run into this issue.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,947796627
https://github.com/pydata/xarray/issues/5620#issuecomment-883071124,https://api.github.com/repos/pydata/xarray/issues/5620,883071124,IC_kwDOAMm_X840opiU,5635139,2021-07-20T05:29:50Z,2021-07-20T05:29:50Z,MEMBER,Hi @meteoDaniel — please could you add a minimal example as per the link in the issue template?,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,947796627