# Override DataArray values beyond set values

**URL:** https://discourse.vtk.org/t/override-dataarray-values-beyond-set-values/7618
**Category:** Support
**Created:** [January 11, 2022, 8:53pm UTC](https://discourse.vtk.org/t/override-dataarray-values-beyond-set-values/7618 "2022-01-11T20:53:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![theodorebaltis](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/e480ec/32.png) [@theodorebaltis](https://discourse.vtk.org/u/theodorebaltis)
#### Post date: [January 11, 2022, 8:53pm UTC](https://discourse.vtk.org/t/override-dataarray-values-beyond-set-values/7618/1 "2022-01-11T20:53:11Z")

</div>

I’m looking to set a new range on my data, assuming I have a `new_min` and `new_max`, so that values \> `new_max` are set to `new_max` and values \< `new_min` are set to `new_min`

Easy enough to do with the `vtk_to_numpy`/`numpy_to_vtk` array conversions and performing the operations in `numpy`, but is there a filter or more straight-forward method to do so in `vtk` itself?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 12, 2022, 9:18pm UTC](https://discourse.vtk.org/t/override-dataarray-values-beyond-set-values/7618/2 "2022-01-12T21:18:29Z")

</div>

Hi, Theodore,

You can use the `vtkMath` class to clamp values in an array of `double`s. [https://vtk.org/doc/nightly/html/classvtkMath.html](https://vtk.org/doc/nightly/html/classvtkMath.html) . Take a look at its `ClampValues()` overrides and use one that suits your need.

regards,

Paulo

---

<div class="post-metadata">

### Author: ![theodorebaltis](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/e480ec/32.png) [@theodorebaltis](https://discourse.vtk.org/u/theodorebaltis)
#### Post date: [January 12, 2022, 10:33pm UTC](https://discourse.vtk.org/t/override-dataarray-values-beyond-set-values/7618/3 "2022-01-12T22:33:34Z")

</div>

Thank you @Paulo_Carvalho!

Interesting that the methods don’t accept a `vtkDataArray` so I still need to convert back and forth using `numpy_support` but that’s fine. Thanks again.
