Consider the example:
x = np.array([-6,-5,-4,-3,-2,-1,0,1,2,3,5,6])
x % (2 * np.pi)
This modulo operation will map the intervall x to [0,2pi].
If i replace 2pi by pi or -pi i get the following result:
array([0.28318531, 1.28318531, 2.28318531, 0.14159265, 1.14159265,
2.14159265, 0. , 1. , 2. , 3. ,
1.85840735, 2.85840735]) # for pi
array([-2.85840735, -1.85840735, -0.85840735, -3. , -2. ,
-1. , -0. , -2.14159265, -1.14159265, -0.14159265,
-1.28318531, -0.28318531]) # for - pi
Which is not correct.
Does someone know an easy way to map x to [-pi,pi]?