# xarray.ufuncs.isreal

### xarray.ufuncs.isreal *= <xarray.ufuncs._unary_ufunc object>*

xarray specific variant of [`numpy.isreal()`](https://numpy.org/doc/stable/reference/generated/numpy.isreal.html#numpy.isreal). Handles xarray objects by dispatching to the appropriate function for the underlying array type.

Documentation from numpy:

Returns a bool array, where True if input element is real.

If element has complex type with zero imaginary part, the return value
for that element is True.

* **Parameters:**
  **x** ([array_like](https://numpy.org/doc/stable/glossary.html#term-array_like)) – Input array.
* **Returns:**
  **out** ([`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray), [`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – Boolean array of same shape as x.

### Notes

isreal may behave unexpectedly for string or object arrays (see examples)

#### SEE ALSO
[`iscomplex`](xarray.ufuncs.iscomplex.html.md#xarray.ufuncs.iscomplex)

`isrealobj`
: Return True if x is not a complex type.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('32d5bfba-46ab-4807-bbe3-f2cf186094ec','4319566e-2ba8-4b19-9273-9d1dde9f916c','4960bffe-efe4-4440-abf0-3e018ff75959','../lite/tree/../notebooks/index.html?path=7526e6ea_bc76_4100_9956_9d3884e81caf.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> import numpy as np
>>> a = np.array([1+1j, 1+0j, 4.5, 3, 2, 2j], dtype=np.complex128)
>>> np.isreal(a)
array([False,  True,  True,  True,  True, False])
```

The function does not work on string arrays.

```pycon
>>> a = np.array([2j, "a"], dtype=np.str_)
>>> np.isreal(a)  # returns the result of `"" == 0` currently.
array([False, False])
```

Returns True for all elements that either have no `.imag` attribute
or for which that attribute is zero:

```pycon
>>> a = np.array([1, "2", 3+4j], dtype=np.object_)
>>> np.isreal(a)
array([ True,  True,  False])
```

<div id="4960bffe-efe4-4440-abf0-3e018ff75959" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('32d5bfba-46ab-4807-bbe3-f2cf186094ec','4960bffe-efe4-4440-abf0-3e018ff75959')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('32d5bfba-46ab-4807-bbe3-f2cf186094ec','4960bffe-efe4-4440-abf0-3e018ff75959')">Open In Tab</button></div><div id="4319566e-2ba8-4b19-9273-9d1dde9f916c" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
