def _calc(self, data, ret_obj, **kwargs):
self._inst_als = _AlsCvxopt(**kwargs)
try:
shp = data.shape[0:-2]
total_num = _np.array(shp).prod()
counter = 1
for idx in _np.ndindex(shp):
print('Detrended iteration {} / {}'.format(counter, total_num))
ph = _np.unwrap(_np.angle(data[idx]))
if self.rng is None:
err_phase = self._inst_als.calculate(ph)
else:
err_phase = self._inst_als.calculate(ph[..., self.rng])
h = _np.zeros(err_phase.shape)
h += _hilbert(err_phase)
correction_factor = 1/_np.exp(h) * _np.exp(-1j*err_phase)
if self.rng is None:
ret_obj[idx] *= correction_factor
else:
ret_obj[idx][..., self.rng] *= correction_factor
counter += 1
except:
return False
else:
# print(self._inst_als.__dict__)
return True
评论列表
文章目录