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/3946#issuecomment-1115437279,https://api.github.com/repos/pydata/xarray/issues/3946,1115437279,IC_kwDOAMm_X85CfDjf,26384082,2022-05-02T22:37:47Z,2022-05-02T22:37:47Z,NONE,"In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity
If this issue remains relevant, please comment here or remove the `stale` label; otherwise it will be marked as closed automatically
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,595813283
https://github.com/pydata/xarray/issues/3946#issuecomment-611208695,https://api.github.com/repos/pydata/xarray/issues/3946,611208695,MDEyOklzc3VlQ29tbWVudDYxMTIwODY5NQ==,2448579,2020-04-08T21:39:13Z,2020-04-08T21:39:13Z,MEMBER,We need to fix groupby to ignore variables that don't have the grouped dimension.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,595813283
https://github.com/pydata/xarray/issues/3946#issuecomment-611208139,https://api.github.com/repos/pydata/xarray/issues/3946,611208139,MDEyOklzc3VlQ29tbWVudDYxMTIwODEzOQ==,32069530,2020-04-08T21:37:45Z,2020-04-08T21:37:45Z,NONE,"@TomNicholas ,
Thanks for yor help. That is exactly what I wanted to do but, as you said there is probably a more efficent way to do it.
@dcherian I needed this function because I sometimes use the groupby_bins() function followed by a concatenantion along a new dimension. This can drastically increase memory due to the multiplication of other variables in a Dataset.
Independantly of my usage, having a function that remove redundant data seems interessant to me. There is probably other combination of function that can accidently duplicate data. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,595813283
https://github.com/pydata/xarray/issues/3946#issuecomment-610524351,https://api.github.com/repos/pydata/xarray/issues/3946,610524351,MDEyOklzc3VlQ29tbWVudDYxMDUyNDM1MQ==,2448579,2020-04-07T17:38:21Z,2020-04-07T17:38:21Z,MEMBER,Cookbook seems like a nice place to put it,"{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,595813283
https://github.com/pydata/xarray/issues/3946#issuecomment-610522710,https://api.github.com/repos/pydata/xarray/issues/3946,610522710,MDEyOklzc3VlQ29tbWVudDYxMDUyMjcxMA==,35968931,2020-04-07T17:35:12Z,2020-04-07T17:35:12Z,MEMBER,If people think this would be useful addition to the API then we could add it - or it could just be a cookbook recipe.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,595813283
https://github.com/pydata/xarray/issues/3946#issuecomment-610519628,https://api.github.com/repos/pydata/xarray/issues/3946,610519628,MDEyOklzc3VlQ29tbWVudDYxMDUxOTYyOA==,35968931,2020-04-07T17:29:10Z,2020-04-07T17:32:59Z,MEMBER,"Hi @lanougue , thanks for the suggestion!
If I understand correctly, you want to check that all elements are close along one dimension, and if so, then select only one index from that dimension? That seems to me to be two consecutive operations, the first of which is a reduction, and the second is just `.isel`:
```python
da = xr.DataArray([[1.,2.],[1.,2.]], dims=('x','y'))
def reduce_if_constant_along_dim(da, dim):
first = da.isel(**{dim: 0})
constant_along_dim = (da == first).all(dim)
true = xr.full_like(da, fill_value=True).isel(**{dim: 0}, drop=True)
if constant_along_dim.equals(true):
return da.isel(**{dim: 0}, drop=True)
else:
return da
print(reduce_if_constant_along_dim(da, dim='x'))
```
```bash
array([1., 2.])
```
or are you imagining something that applies the above function to every dim, more like:
```python
def drop_constant_dims(da):
for dim in da.dims:
da = reduce_if_constant_along_dim(da, dim)
return da
print(drop_constant_dims(da))
```
```bash
array([1., 2.])
```
There might be a slightly neater way using `reduce` somehow though.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,595813283
https://github.com/pydata/xarray/issues/3946#issuecomment-610520813,https://api.github.com/repos/pydata/xarray/issues/3946,610520813,MDEyOklzc3VlQ29tbWVudDYxMDUyMDgxMw==,35968931,2020-04-07T17:31:28Z,2020-04-07T17:31:28Z,MEMBER,@jthielen you should be able to adapt my example to check for being within a tolerance rather than strict equality.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,595813283
https://github.com/pydata/xarray/issues/3946#issuecomment-610516526,https://api.github.com/repos/pydata/xarray/issues/3946,610516526,MDEyOklzc3VlQ29tbWVudDYxMDUxNjUyNg==,3460034,2020-04-07T17:22:49Z,2020-04-07T17:22:49Z,CONTRIBUTOR,"If allowing for some degree of tolerance, something like this would also be quite useful in geographic coordinate transformations when going from 2D lon/lat auxiliary coordinates to 1D x/y dimension coordinates. Here's an example of what we're currently doing in MetPy for this: https://github.com/Unidata/MetPy/blob/3aa0118ffbda48be2a426dee956183b7cef81f0c/src/metpy/xarray.py#L907-L947","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,595813283