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,15 +243,16 @@ def upsample(x, Nup, coefs, verify=False): # interpolate ...@@ -242,15 +243,16 @@ def upsample(x, Nup, coefs, verify=False): # interpolate
else: else:
print('ERROR: wrong upsample result') print('ERROR: wrong upsample result')
print('> upsample():') if verbosity:
print('. Nup = ' + str(Nup)) print('> upsample():')
print('. Nx = ' + str(Nx)) print('. Nup = ' + str(Nup))
print('. len(y) = ' + str(len(y))) print('. Nx = ' + str(Nx))
print('') print('. len(y) = ' + str(len(y)))
print('')
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,17 +371,18 @@ def downsample(x, Ndown, coefs, verify=False): # decimate ...@@ -368,17 +371,18 @@ def downsample(x, Ndown, coefs, verify=False): # decimate
else: else:
print('ERROR: wrong downsample result') print('ERROR: wrong downsample result')
print('> downsample():') if verbosity:
print('. len(x) = ' + str(len(x))) print('> downsample():')
print('. Ndown = ' + str(Ndown)) print('. len(x) = ' + str(len(x)))
print('. Nx = ' + str(Nx)) print('. Ndown = ' + str(Ndown))
print('. Nxp = ' + str(Nxp)) print('. Nx = ' + str(Nx))
print('. len(y) = ' + str(len(y))) # = Nxp print('. Nxp = ' + str(Nxp))
print('') print('. len(y) = ' + str(len(y))) # = Nxp
print('')
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,12 +463,13 @@ def resample(x, Nup, Ndown, coefs, verify=False): # interpolate and decimate by ...@@ -458,12 +463,13 @@ def resample(x, Nup, Ndown, coefs, verify=False): # interpolate and decimate by
else: else:
print('ERROR: wrong resample result') print('ERROR: wrong resample result')
print('> resample():') if verbosity:
print('. len(x) = ' + str(len(x))) print('> resample():')
print('. Nx = ' + str(Nx)) print('. len(x) = ' + str(len(x)))
print('. len(v) = ' + str(len(v))) print('. Nx = ' + str(Nx))
print('. Ny = ' + str(Ny)) print('. len(v) = ' + str(len(v)))
print('. Nyp = ' + str(Nyp)) print('. Ny = ' + str(Ny))
print('. len(y) = ' + str(len(y))) print('. Nyp = ' + str(Nyp))
print('') print('. len(y) = ' + str(len(y)))
print('')
return y return y
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