id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 420584430,MDU6SXNzdWU0MjA1ODQ0MzA=,2808,Improving documentation on `apply_ufunc`,13205162,closed,0,,,9,2019-03-13T16:03:37Z,2022-04-27T20:09:06Z,2022-04-27T20:09:06Z,CONTRIBUTOR,,,,"This is just a suggestion to improve the documentation on `apply_ufunc`. The way I see it, this is one of the most powerful functions that xarray has to offer but (IMHO) the documentation is really small and with only a few examples. From personal experience, every time I have to use it I get confused and it takes me a long time to figure out what important keywords like `input_core_dims` and `output_core_dims` actually do. After talking to some colleagues of mine I found that they share the same opinion so it appears that I'm not the only one. PS: I honestly still don't quite understand what most (if not all) of the keywords do, so I'm not the man for the job. __EDIT__ An example of something that could be improved upon is this function taken from the documentation: ``` def mean(obj, dim): # note: apply always moves core dimensions to the end return apply_ufunc(np.mean, obj, input_core_dims=[[dim]], kwargs={'axis': -1}) ``` It's really easy to understand, but if I want to use it with more than one axis it doesn't work: ``` a=xr.DataArray(np.random.randn(3,3,3), dims=(""x"", ""y"", ""z"")) def mean(obj, dims): # note: apply always moves core dimensions to the end return xr.apply_ufunc(np.mean, obj, input_core_dims=[dims], kwargs={'axis': -1}) mean(a, ""x"") # works mean(a, (""x"", ""y"")) # returns ValueError: applied function returned data with unexpected number of dimensions: 2 vs 1, for dimensions ('z',) ``` And I have no idea how to make the second, more general example work.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2808/reactions"", ""total_count"": 5, ""+1"": 5, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 963089887,MDU6SXNzdWU5NjMwODk4ODc=,5681,Complex LaTeX expressions in `long_name`s aren't rendered correctly when plotting,13205162,closed,0,,,5,2021-08-06T22:54:11Z,2021-11-28T17:07:18Z,2021-11-28T17:07:18Z,CONTRIBUTOR,,,," **What happened**: When I try to give a variable a `long_name` that's a complex latex expression and then plot that variable the expression doesn't get rendered by latex **What you expected to happen**: I expected the name to get rendered by latex **Minimal Complete Verifiable Example**: In the example below I'm plotting a variable with a complex `long_name` via xarray and then plotting it again (in a separate figure) using only matplotlib and manually setting `xlabel()`. The matplotlib-only version works fine (right), but the xarray version doesn't render (left). ```python import numpy as np from matplotlib import pyplot as plt import xarray as xr da = xr.DataArray(range(5), dims=""x"", coords = dict(x=range(5))) name = r""$Ra_s = \mathrm{mean}(\epsilon_k) / \mu M^2_\infty$"" da.x.attrs = dict(long_name = name) da.plot() plt.figure() plt.plot(range(5)) plt.xlabel(name) ``` ![Screenshot from 2021-08-06 15-50-08](https://user-images.githubusercontent.com/13205162/128578216-5f5ce409-e77c-43e8-b0c1-0b85dc3e81a9.png) **Anything else we need to know?**: **Environment**:
Output of xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.9.2 (default, Mar 3 2021, 20:02:32) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 5.10.53-1-MANJARO machine: x86_64 processor: byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.6 libnetcdf: 4.6.1 xarray: 0.17.0 pandas: 1.2.3 numpy: 1.19.2 scipy: 1.5.3 netCDF4: 1.5.6 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.2.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.2 dask: 2021.04.0 distributed: 2021.04.0 matplotlib: 3.3.4 cartopy: 0.18.0 seaborn: None numbagg: None pint: 0.17 setuptools: 52.0.0.post20210125 pip: 21.0.1 conda: None pytest: None IPython: 7.22.0 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5681/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 963239311,MDExOlB1bGxSZXF1ZXN0NzA1ODk4MDcx,5682,Improves rendering of complex LaTeX expressions as `long_name`s when plotting,13205162,closed,0,,,11,2021-08-07T14:18:16Z,2021-11-28T17:06:49Z,2021-08-17T02:29:54Z,CONTRIBUTOR,,0,pydata/xarray/pulls/5682,"This PR changes the function `label_from_attrs()` to wrap text differently if we think it's a LaTeX sequence. This prevents long LaTeX names from not being rendered properly. I tried to identify if it's a latex code if the string starts with `$` and if it has an even number of `$` in it. But I'm open to suggestions. I also increased the number of allowed columns for latex code since it generally renders to fewer characters. - [x] Closes #5681 - [x] Tests added - [x] Passes `pre-commit run --all-files` - [x] User visible changes (including notable bug fixes) are documented in `whats-new.rst` - [x] New functions/methods are listed in `api.rst` CC: @dcherian @Illviljan ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5682/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 822404281,MDU6SXNzdWU4MjI0MDQyODE=,4997,Include a markertype in `Dataset.plot.scatter`,13205162,open,0,,,4,2021-03-04T18:49:08Z,2021-05-26T22:49:14Z,,CONTRIBUTOR,,,,"Pardon me if I've missed something, but from the docs and the issues raised it doesn't seem like anyone has proposed to add a marker type in `Dataset.plot.scatter`. From [the docs](http://xarray.pydata.org/en/stable/generated/xarray.plot.scatter.html) it seems that right now you can organize points using hue and marker size. It would be nice to add marker type to the mix, and I imagine that it wouldn't too hard. The only issue I see is that there are a finite number of marker types by default, but that's no different from the finite number of colors in the default color wheel. Thoughts?","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4997/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 435532136,MDU6SXNzdWU0MzU1MzIxMzY=,2911,Support from reading unformatted Fortran files,13205162,open,0,,,6,2019-04-21T17:50:52Z,2021-01-01T11:25:53Z,,CONTRIBUTOR,,,,"I was wondering if there is interest in developing support for reading unformatted binary files into DataArrays/Datasets. I have been using a couple of models for a while that output unformatted Fortran binary files that I have to read into DataArrays and Datasets. I have developed my own custom functions to do this and they work quite well for my purposes, but I was wondering is the community thinks this is something that would be useful for more people. I know the syntax could be a bit cumbersome, but I was thinking it could be implemented like ``` da = xr.DataArray.from_binary(filename, access=""direct"", dtype=np.float64, coords=coords, dims=dims,) ``` From there we could figure out the counts to read, etc. If there's interest in this feature we could discuss it and I'd be happy to implement. Cheers","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2911/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 423922821,MDU6SXNzdWU0MjM5MjI4MjE=,2838,Change `swap_dims` to rename_dims?,13205162,open,0,,,1,2019-03-21T20:17:59Z,2019-09-07T20:08:02Z,,CONTRIBUTOR,,,,"Basically I'm trying to swap the names and data (basically the underlying numpy array would be the same, but the coords would change) of two dimensions in my `DataArray` and I was looking for options that could do that. So I thought `swap_dims` would be a good candidate for that given its description but it doesn't work. In fact, based on the docs, I have no idea how to use it and what it does. Based off of issues like [this](https://github.com/pydata/xarray/issues/1081) it seems I'm not alone. Maybe it would be good to add example of usage of this function?","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2838/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 309965118,MDU6SXNzdWUzMDk5NjUxMTg=,2030,Animate DataArrays,13205162,open,0,,,12,2018-03-30T03:23:22Z,2019-05-31T14:55:56Z,,CONTRIBUTOR,,,,"Hi, this is my first a feature request here. I've been using xarray for a while but it always comes somewhat short when I'm trying to do animations. It always ends up being a big hassle. Is there a good way to provide some functionality to make animations easier? I really like the way xarray sets up the plots by default, but I always end up re-writing it when setting up an animation, which I always feel like is kind of a shame. Cheers","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2030/reactions"", ""total_count"": 3, ""+1"": 3, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 310670696,MDU6SXNzdWUzMTA2NzA2OTY=,2035,Manually subtracting two slices of DataArary always produces zero output,13205162,closed,0,,,5,2018-04-03T02:22:00Z,2019-01-22T22:44:43Z,2019-01-22T22:44:43Z,CONTRIBUTOR,,,,"I have witnessing a weird behavior with xarray. Here's a MWE ```python import xarray as xr da=xr.DataArray(np.random.rand(5,5,5), dims=['x', 'y', 'z'], coords=dict(x=range(5), y=range(5), z=range(5))) da[...,1:]-da[...,:-1] ``` I expected this work just as `da.diff(dim='z')`, but it always returns a zero-values DataArray. #### Expected Output ``` array([[[-0.22148 , 0.246586, 0.043931, -0.37468 ], [-0.522721, -0.016258, -0.386125, 0.932965], [-0.227799, -0.140233, 0.400886, -0.130469], [-0.04763 , 0.656787, -0.597745, 0.212088], [ 0.089159, 0.376483, -0.712572, 0.397021]], [[ 0.161166, -0.387264, 0.052542, 0.477284], [ 0.30892 , 0.426818, -0.370983, 0.059737], [ 0.429502, -0.395471, 0.238937, 0.360634], [ 0.702574, -0.150469, 0.300272, -0.483837], [ 0.419341, 0.317944, -0.089965, -0.102932]], [[ 0.371919, -0.140948, 0.583743, -0.827194], [-0.037487, -0.345201, -0.457696, 0.281395], [ 0.43892 , 0.156371, -0.351781, -0.016645], [-0.542661, 0.51394 , -0.615431, -0.039449], [-0.439784, -0.153804, 0.314933, -0.539498]], [[-0.398652, 0.830793, -0.408786, -0.355191], [-0.757028, -0.017731, 0.086872, -0.182064], [ 0.174183, -0.075571, 0.604353, -0.347382], [-0.388407, 0.342358, 0.059482, 0.347141], [ 0.759616, -0.446468, -0.060504, -0.217946]], [[-0.283018, -0.078172, 0.276102, -0.236144], [-0.427625, -0.044339, 0.484844, -0.06352 ], [-0.073386, 0.336733, 0.429961, -0.839064], [ 0.256269, -0.586563, -0.076288, -0.220549], [ 0.320014, -0.633854, -0.026103, 0.333301]]]) Coordinates: * z (z) int64 1 2 3 4 * y (y) int64 0 1 2 3 4 * x (x) int64 0 1 2 3 4 ``` #### The output I'm getting is: ``` array([[[0., 0., 0.], [0., 0., 0.], [0., 0., 0.], [0., 0., 0.], [0., 0., 0.]], [[0., 0., 0.], [0., 0., 0.], [0., 0., 0.], [0., 0., 0.], [0., 0., 0.]], [[0., 0., 0.], [0., 0., 0.], [0., 0., 0.], [0., 0., 0.], [0., 0., 0.]], [[0., 0., 0.], [0., 0., 0.], [0., 0., 0.], [0., 0., 0.], [0., 0., 0.]], [[0., 0., 0.], [0., 0., 0.], [0., 0., 0.], [0., 0., 0.], [0., 0., 0.]]]) Coordinates: * z (z) int64 1 2 3 * y (y) int64 0 1 2 3 4 * x (x) int64 0 1 2 3 4 ``` Is there something I'm missing here or is this really the expected behavior? #### Output of ``xr.show_versions()``
xarray: 0.10.2 pandas: 0.22.0 numpy: 1.14.2 scipy: 1.0.0 netCDF4: 1.2.6 h5netcdf: 0.3.1 h5py: 2.6.0 Nio: None zarr: None bottleneck: None cyordereddict: None dask: 0.17.2 distributed: None matplotlib: 2.1.0 cartopy: None seaborn: None setuptools: 38.2.4 pip: 9.0.3 conda: None pytest: None IPython: 6.2.1 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2035/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 341272087,MDU6SXNzdWUzNDEyNzIwODc=,2286,Assembling a domain from smaller 2D patches using DataArray,13205162,closed,0,,,1,2018-07-14T21:48:41Z,2018-07-14T22:44:54Z,2018-07-14T22:44:54Z,CONTRIBUTOR,,,,"This is based off of [this question I posted in SO](https://stackoverflow.com/questions/51335531/concatenate-xarray-dataarrays-simultaneously-along-2-dimensions?noredirect=1#comment89646157_51335531). Basically I have a huge 2D domain that is separated into a lot of smaller 2D domains (as `DataArrays`). I have been trying to find a way to combine them all into one huge `DataArray` based on their coordinates. Kind of like assembling a mosaic. Here's a MWE of one of my tries that didn't work: ```python a=xr.DataArray(np.random.rand(4,4)+0, dims=(""x"", ""y""), coords=dict(x=range(4), y=range(4))) b=xr.DataArray(np.random.rand(4,4)+1, dims=(""x"", ""y""), coords=dict(x=range(4,8), y=range(4))) c=xr.DataArray(np.random.rand(4,4)+2, dims=(""x"", ""y""), coords=dict(x=range(4,8), y=range(4,8))) d=xr.concat([a,b,c], dim=""x"") d.plot.imshow(x=""x"") ``` This is somewhat close to what I wanted, but since it only concatenates in one direction, the output is wrong. You can read the question I linked above for a more detail explanation with a figure. At this point I'm thinking that what I want is not possible with what's currently implemented in `xarray`. So if indeed this is the case, I think this could be understood as a feature request, since I think this functionality would be very useful. ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2286/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue