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
1024011835,I_kwDOAMm_X849CS47,5857,"Incorrect results when using xarray.ufuncs.angle(..., deg=True)",1119116,closed,0,,,4,2021-10-12T16:24:11Z,2024-04-28T20:58:55Z,2024-04-28T20:58:54Z,NONE,,,,"<!-- Please include a self-contained copy-pastable example that generates the issue if possible.

Please be concise with code posted. See guidelines below on how to provide a good bug report:

- Craft Minimal Bug Reports: http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports
- Minimal Complete Verifiable Examples: https://stackoverflow.com/help/mcve

Bug reports that follow these guidelines are easier to diagnose, and so are often handled much more quickly.
-->

**What happened**:

The `xarray.ufuncs.angle` is broken. From the help docstring one may use option `deg=True` to have the result in degrees instead of radians (which is consistent with `numpy.angle` function). Yet results show that this is not the case. Moreover specifying `deg=True` or `deg=False` leads to the same result with the values in radians.

**What you expected to happen**:

To have the result of `xarray.ufuncs.angle` converted to degrees when option `deg=True` is specified.

**Minimal Complete Verifiable Example**:

```python
# Put your MCVE code here
import numpy as np
import xarray as xr

ds = xr.Dataset(coords={'wd': ('wd', np.arange(0, 360, 30, dtype=float))})

Z = xr.ufuncs.exp(1j * xr.ufuncs.radians(ds.wd))
D = xr.ufuncs.angle(Z, deg=True)  # YIELDS INCORRECT RESULTS
if not np.allclose(ds.wd, (D % 360)):
    print(f""Issue with angle operation: {D.values%360} instead of {ds.wd.values}"" \
        + f""\n\tERROR   xr.ufuncs.angle(Z, deg=True) gives incorrect results !!!"")

D = xr.ufuncs.degrees(xr.ufuncs.angle(Z))  # Works OK
if not np.allclose(ds.wd, (D % 360)):
    print(f""Issue with angle operation: {D%360} instead of {ds.wd}"" \
    + f""\n\tERROR   xr.ufuncs.degrees(xr.ufuncs.angle(Z)) gives incorrect results!!!"")

D = xr.apply_ufunc(np.angle, Z, kwargs={'deg': True})  # Works OK
if not np.allclose(ds.wd, (D % 360)):
    print(f""Issue with angle operation: {D%360} instead of {ds.wd}"" \
    + f""\n\tERROR   xr.apply_ufunc(np.angle, Z, kwargs={{'deg': True}}) gives incorrect results!!!"")
```

**Anything else we need to know?**:

Though `xarray.ufuncs` has a deprecated warning stating that the numpy equivalent may be used, this is not true for `numpy.angle`. Example:

```python
import numpy as np
import xarray as xr

ds = xr.Dataset(coords={'wd': ('wd', np.arange(0, 360, 30, dtype=float))})

Z = np.exp(1j * np.radians(ds.wd))
print(Z)
print(f""Is Z an XArray? {isinstance(Z, xr.DataArray)}"")

D = np.angle(ds.wd, deg=True)
print(D)
print(f""Is D an XArray? {isinstance(D, xr.DataArray)}"")
```
If this code is run, the result of `numpy.angle(xarray.DataArray)` is not a DataArray object, contrary to other numpy operations (for all versions of xarray I've used). Hence the `xarray.ufuncs.angle` is a great option, if it was not for the current problem.

**Environment**:

No issues with xarray versions 0.16.2 and 0.17.0. This error happens from 0.18.0 onwards, up to 0.19.0 (recentmost).

<details><summary>Output of <tt>xr.show_versions()</tt></summary>

<!-- Paste the output here xr.show_versions() here -->
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.10 (default, Feb 26 2021, 18:47:35) 
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.19.0-18-amd64
machine: x86_64
processor: 
byteorder: little
LC_ALL: en_US.utf8
LANG: C.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: None
libnetcdf: None

xarray: 0.19.0
pandas: 1.2.3
numpy: 1.20.2
scipy: 1.5.3
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
pint: None
setuptools: 58.2.0
pip: 21.3
conda: 4.10.3
pytest: None
IPython: None
sphinx: None

</details>
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5857/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue