fix phase in PEIS mode
This commit is contained in:
@@ -1586,12 +1586,7 @@ class EISZeroOneDataDecoder(RecDataDecoder):
|
||||
else:
|
||||
impedance = 0
|
||||
|
||||
if (real > 0):
|
||||
raw_phase = math.atan(img / real) * 180 / math.pi
|
||||
elif (real == 0):
|
||||
raw_phase = 90
|
||||
else:
|
||||
raw_phase = math.atan(img / real) * 180 / math.pi + (180 if math.atan(img / real)< 0 else-180)
|
||||
raw_phase = math.atan2(img , real) * 180 / math.pi
|
||||
|
||||
if (freq >= 1000000): # 10000 Hz
|
||||
fre_idx = 0
|
||||
@@ -1604,19 +1599,19 @@ class EISZeroOneDataDecoder(RecDataDecoder):
|
||||
|
||||
ideal_raw_phase = phase_coeff[gain][fre_idx] /1e10 * freq + phase_offset[gain][fre_idx] / 1e6
|
||||
phase = raw_phase - ideal_raw_phase
|
||||
if phase > 90 :
|
||||
phase = phase - 180
|
||||
elif phase <= -90:
|
||||
phase = phase + 180
|
||||
phase = phase % 180 if phase % 180<=90 else phase % 180-180
|
||||
|
||||
# last_phase_to90 = self._last_phase % 180 if self._last_phase % 180<=90 else self._last_phase % 180-180
|
||||
# diff = phase - last_phase_to90
|
||||
|
||||
# if (self._first_phase_flag):
|
||||
# self._last_phase = phase
|
||||
# # self._last_phase = phase
|
||||
# self._first_phase_flag = 0
|
||||
# elif (abs(phase - self._last_phase) >= 90):
|
||||
# phase -= 360
|
||||
# self._last_phase = phase
|
||||
# else :
|
||||
# self._last_phase = phase
|
||||
# elif (abs(diff) >= 90):
|
||||
# phase = self._last_phase + diff + (180 if diff<0 else-180)
|
||||
# else:
|
||||
# phase = self._last_phase + diff
|
||||
# self._last_phase = phase
|
||||
|
||||
imag_after_cal = impedance * math.sin(round(phase) * math.pi / 180)
|
||||
real_after_cal = impedance * math.cos(round(phase) * math.pi / 180)
|
||||
|
||||
Reference in New Issue
Block a user