using tools/rotate_signal in Signalpath.py. One can change the ADC_Result/Accumulation phase with the *phase(degrees)* method.

This commit is contained in:
Markus Rosenstihl 2014-12-15 21:03:01 +00:00
parent f663759f58
commit 2c22841697

View File

@ -1,9 +1,37 @@
import numpy as N
class Signalpath:
def phase(self, degrees):
tmp = self.y[0] + 1j*self.y[1]
tmp *= N.exp(1j*degrees*N.pi/180)
self.y[0] = tmp.real
self.y[1] = tmp.imag
del tmp
"""
rotate signal by **degrees** for phase cycling, etc.
:param degrees: rotate signal by this value
:return:
"""
if self.get_number_of_channels() != 2:
raise Exception("rotation defined only for 2 channels")
# simple case 0, 90, 180, 270 degree
reduced_angle = divmod(degrees, 90)
if abs(reduced_angle[1]) < 1e-6:
reduced_angle = reduced_angle[0] % 4
if reduced_angle == 0:
return
elif reduced_angle == 1:
self.y[1] *= -1
self.y = [self.y[1], self.y[0]]
elif reduced_angle == 2:
self.y[0] *= -1
self.y[1] *= -1
elif reduced_angle == 3:
self.y[0] *= -1
self.y = [self.y[1], self.y[0]]
else:
sin_angle = N.sin(degrees / 180.0 * N.pi)
cos_angle = N.cos(degrees / 180.0 * N.pi)
self.y = [cos_angle * self.y[0] - sin_angle * self.y[1],
sin_angle * self.y[0] + cos_angle * self.y[1]]
return self