Skip to content
Snippets Groups Projects
Commit 7a1fd24d authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Correct inData order in non_maximal_downsample_bpf()

parent 62d44525
No related branches found
No related tags found
1 merge request!419Resolve RTSD-265
Pipeline #91855 passed
......@@ -190,7 +190,7 @@ class PolyPhaseFirFilterStructure:
def map_to_poly_delays(self, delayLine):
self.polyDelays = delayLine.reshape((self.Ntaps, self.Nphases)).T
def shift_in_data(self, inData):
def shift_in_data(self, inData, flipped=False):
"""Shift block of data into the polyDelays structure.
View polyDelays as delay line if L < Nphases. Shift in from the left
......@@ -202,22 +202,25 @@ class PolyPhaseFirFilterStructure:
. inData: Block of one or more input samples with index as time index
n in inData[n], so oldest sample at index 0 and newest sample at
index -1.
. flipped: False then inData order is inData[n] and still needs to be
flipped. If True then the inData is already flipped.
"""
L = len(inData)
xData = inData if flipped else np.flip(inData)
if L < self.Nphases:
delayLine = self.map_to_delay_line()
# Equivalent code:
# delayLine = np.concatenate((inData, delayLine[L:]))
delayLine = np.roll(delayLine, L)
delayLine[:L] = np.flip(inData)
delayLine[:L] = xData
self.map_to_poly_delays(delayLine)
else:
# Equivalent code for L == Nphases: Shift in inData block directly
# at column 0
self.polyDelays = np.roll(self.polyDelays, 1, axis=1)
self.polyDelays[:, 0] = np.flip(inData)
self.polyDelays[:, 0] = xData
def filter_block(self, inData):
def filter_block(self, inData, flipped=False):
"""Filter block of inData per polyphase.
Input:
......@@ -228,9 +231,11 @@ class PolyPhaseFirFilterStructure:
Return:
. pfsData: block of polyphase FIR filtered output data for Nphase, with
pfsData[p] and p = 0:Nphases-1 from top to bottom.
. flipped: False then inData order is inData[n] and still needs to be
flipped. If True then the inData is already flipped.
"""
# Shift in one block of input data (1 <= len(inData) <= Nphases)
self.shift_in_data(inData)
self.shift_in_data(inData, flipped)
# Apply FIR coefs per delay element
zData = self.polyDelays * self.polyCoefs
# Sum FIR taps per polyphase
......@@ -353,7 +358,7 @@ def polyphase_frontend(x, Nphases, coefs, sampling):
Ndown = Nphases
Nzeros = Ndown - 1
polyX, Nx, Nxp = polyphase_data_for_downsampling_whole_x(x, Ndown, Nzeros)
print(polyX[:, 0])
# print(polyX[:, 0])
# Filter Ndown parts of x per polyphase, because the FIR filter output
# y will sum. The commutator index order for downsampling is p =
# Ndown - 1,..., 1, 0, so from bottom to top in the PFS. However, the
......@@ -709,7 +714,7 @@ def non_maximal_downsample_bpf(x, Ndown, k, Ndft, coefs, verbosity=1):
for b in range(Nblocks):
# Filter block
inData = xBlocks[:, b]
pfsData = pfs.filter_block(inData)
pfsData = pfs.filter_block(inData, flipped=True)
# Phase rotate polyphases for bin k [HARRIS Eq 6.8]
pfsBinData = pfsData * phasors
# Sum the polyphases to get single downsampled and downconverted output value
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment