Skip to content
Snippets Groups Projects
Commit f308d606 authored by Kipp Cannon's avatar Kipp Cannon
Browse files

PSDFirKernel: some clean-up

- remove gratuitous [:] slices from expressions
- use .real, .imag array properties instead of numpy.real() numpy.imag()
- move gain & phase calc for zero-latency whitener up a few lines
parent e3f18255
No related branches found
No related tags found
No related merge requests found
......@@ -534,8 +534,8 @@ class PSDFirKernel(object):
kernel_fseries.data.data = numpy.sqrt(data) + 0.j
lal.COMPLEX16FreqTimeFFT(kernel_tseries, kernel_fseries, self.revplan)
kernel = numpy.real(kernel_tseries.data.data)
kernel = numpy.roll(kernel, (len(data) - 1) / 2)[:] / sample_rate * 2
kernel = kernel_tseries.data.data.real
kernel = numpy.roll(kernel, (len(data) - 1) / 2) / sample_rate * 2
#
# apply a Tukey window whose flat bit is 50% of the kernel.
......@@ -668,6 +668,16 @@ class PSDFirKernel(object):
lal.COMPLEX16TimeFreqFFT(theta, cepstrum, self.fwdplan)
#
# compute the gain and phase of the zero-phase
# approximation relative to the original linear-phase
# filter
#
theta_data = theta.data.data[working_length // 2:]
#gain = numpy.exp(theta_data.real)
phase = -theta_data.imag
#
# compute minimum phase kernel
#
......@@ -684,16 +694,6 @@ class PSDFirKernel(object):
kernel = kernel[-1::-1]
#
# compute the gain and phase of the zero-phase
# approximation relative to the original linear-phase
# filter
#
theta = theta.data.data[working_length // 2:]
#gain = numpy.exp(theta.real)
phase = -theta.imag
#
# done
#
......@@ -812,7 +812,7 @@ def one_second_highpass_kernel(rate, cutoff = 12):
highpass_filter_fd[-int(cutoff):] = 0.
highpass_filter_fd[rate/2-1:rate/2+1] = 0.
highpass_filter_td = fftpack.ifft(highpass_filter_fd)
highpass_filter_td = numpy.roll(numpy.real(highpass_filter_td), rate/2)
highpass_filter_td = numpy.roll(highpass_filter_td.real, rate/2)
highpass_filter_kernel = numpy.zeros(len(highpass_filter_td)+1)
highpass_filter_kernel[:-1] = highpass_filter_td[:]
x = numpy.arange(len(highpass_filter_kernel))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment