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

Add verbosity.

parent 22053a35
No related branches found
No related tags found
1 merge request!413Resolve RTSD-271 "C"
...@@ -134,7 +134,7 @@ class PolyPhaseFirFilterStructure: ...@@ -134,7 +134,7 @@ class PolyPhaseFirFilterStructure:
return outData return outData
def upsample(x, Nup, coefs, verify=False): # interpolate def upsample(x, Nup, coefs, verify=False, verbosity=1): # interpolate
"""Upsample x by factor I = Nup """Upsample x by factor I = Nup
Input: Input:
...@@ -143,6 +143,7 @@ def upsample(x, Nup, coefs, verify=False): # interpolate ...@@ -143,6 +143,7 @@ def upsample(x, Nup, coefs, verify=False): # interpolate
. coefs: FIR filter coefficients for antialiasing LPF . coefs: FIR filter coefficients for antialiasing LPF
. verify: when True then verify that output y is the same when calculated directly or when calculated using the . verify: when True then verify that output y is the same when calculated directly or when calculated using the
polyphase implementation. polyphase implementation.
- verbosity: when > 0 print() status, else no print()
Return: Return:
. y: Upsampled output signal y[m] . y: Upsampled output signal y[m]
...@@ -242,6 +243,7 @@ def upsample(x, Nup, coefs, verify=False): # interpolate ...@@ -242,6 +243,7 @@ def upsample(x, Nup, coefs, verify=False): # interpolate
else: else:
print('ERROR: wrong upsample result') print('ERROR: wrong upsample result')
if verbosity:
print('> upsample():') print('> upsample():')
print('. Nup = ' + str(Nup)) print('. Nup = ' + str(Nup))
print('. Nx = ' + str(Nx)) print('. Nx = ' + str(Nx))
...@@ -250,7 +252,7 @@ def upsample(x, Nup, coefs, verify=False): # interpolate ...@@ -250,7 +252,7 @@ def upsample(x, Nup, coefs, verify=False): # interpolate
return y return y
def downsample(x, Ndown, coefs, verify=False): # decimate def downsample(x, Ndown, coefs, verify=False, verbosity=1): # decimate
"""Downsample x by factor D = Ndown up """Downsample x by factor D = Ndown up
Input: Input:
...@@ -259,6 +261,7 @@ def downsample(x, Ndown, coefs, verify=False): # decimate ...@@ -259,6 +261,7 @@ def downsample(x, Ndown, coefs, verify=False): # decimate
. coefs: FIR filter coefficients for antialiasing LPF . coefs: FIR filter coefficients for antialiasing LPF
. verify: when True then verify that output y is the same when calculated directly or when calculated using the . verify: when True then verify that output y is the same when calculated directly or when calculated using the
polyphase implementation. polyphase implementation.
- verbosity: when > 0 print() status, else no print()
Return: Return:
. y: Downsampled output signal y[m] . y: Downsampled output signal y[m]
...@@ -368,6 +371,7 @@ def downsample(x, Ndown, coefs, verify=False): # decimate ...@@ -368,6 +371,7 @@ def downsample(x, Ndown, coefs, verify=False): # decimate
else: else:
print('ERROR: wrong downsample result') print('ERROR: wrong downsample result')
if verbosity:
print('> downsample():') print('> downsample():')
print('. len(x) = ' + str(len(x))) print('. len(x) = ' + str(len(x)))
print('. Ndown = ' + str(Ndown)) print('. Ndown = ' + str(Ndown))
...@@ -378,7 +382,7 @@ def downsample(x, Ndown, coefs, verify=False): # decimate ...@@ -378,7 +382,7 @@ def downsample(x, Ndown, coefs, verify=False): # decimate
return y return y
def resample(x, Nup, Ndown, coefs, verify=False): # interpolate and decimate by Nup / Ndown def resample(x, Nup, Ndown, coefs, verify=False, verbosity=1): # interpolate and decimate by Nup / Ndown
"""Resample x by factor I / D = Nup / Ndown """Resample x by factor I / D = Nup / Ndown
x[n] --> Nup --> v[m] --> LPF --> w[m] --> Ndown --> y[k] x[n] --> Nup --> v[m] --> LPF --> w[m] --> Ndown --> y[k]
...@@ -408,6 +412,7 @@ def resample(x, Nup, Ndown, coefs, verify=False): # interpolate and decimate by ...@@ -408,6 +412,7 @@ def resample(x, Nup, Ndown, coefs, verify=False): # interpolate and decimate by
. coefs: FIR filter coefficients for antialiasing LPF . coefs: FIR filter coefficients for antialiasing LPF
. verify: when True then verify that output y is the same when calculated directly or when calculated using the . verify: when True then verify that output y is the same when calculated directly or when calculated using the
polyphase implementation. polyphase implementation.
- verbosity: when > 0 print() status, else no print()
Return: Return:
. y: Resampled output signal y[m] . y: Resampled output signal y[m]
...@@ -458,6 +463,7 @@ def resample(x, Nup, Ndown, coefs, verify=False): # interpolate and decimate by ...@@ -458,6 +463,7 @@ def resample(x, Nup, Ndown, coefs, verify=False): # interpolate and decimate by
else: else:
print('ERROR: wrong resample result') print('ERROR: wrong resample result')
if verbosity:
print('> resample():') print('> resample():')
print('. len(x) = ' + str(len(x))) print('. len(x) = ' + str(len(x)))
print('. Nx = ' + str(Nx)) print('. Nx = ' + str(Nx))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment