I have a numpy array of complex numbers. I seek to clip the real and imaginary parts of each number in the array to some prescribed minimum and maximum (same clipping applied to both the real and imaginary parts). For example, consider:
import numpy as np
clip_min = -4
clip_max = 3
x = np.array([-1.4 + 5j, -4.7 - 3j])
The desired output of the clipping operation would be:
[-1.4 + 3j, -4-3j]
I can achieve this by calling np.clip on the real and imaginary parts of the complex array and then adding them (after multiplying the imaginary clipped data by 1j). Is there a way to do this with one command?
np.clip(x, clip_min, clip_max)
doesn't yield the desired result.