0

What is the most efficient way in python to achieve the same as the following IDL (interactive data language) expression: new_array = array > min_value The result of this IDL expression is an array where each value in the array, which is smaller than min_value, is replaced with min_value.

What works, I guess, is: Let's assume array is a numpy.ndarray

mask = array < value
new_array = array
new_array[mask] = value

But is there a one liner or something more efficient than my code?

Dunbur
  • 23
  • 5

0 Answers0