# 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('f242841d-d811-40ad-ac4d-f7033a9e4296','b4fe92f0-4a48-467b-9274-f7882eb54d70','d9092a21-2bc1-4f25-a24e-73a7c9f1f231','../lite/tree/../notebooks/index.html?path=5800eacf_9f56_48ad_8f63_9ff03c3db794.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="d9092a21-2bc1-4f25-a24e-73a7c9f1f231" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('f242841d-d811-40ad-ac4d-f7033a9e4296','d9092a21-2bc1-4f25-a24e-73a7c9f1f231')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('f242841d-d811-40ad-ac4d-f7033a9e4296','d9092a21-2bc1-4f25-a24e-73a7c9f1f231')">Open In Tab</button></div><div id="b4fe92f0-4a48-467b-9274-f7882eb54d70" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
