Skip to content

Instantly share code, notes, and snippets.

@marcusmueller
Created December 30, 2015 16:55
Show Gist options
  • Select an option

  • Save marcusmueller/c1fe14b74cc5d0631b74 to your computer and use it in GitHub Desktop.

Select an option

Save marcusmueller/c1fe14b74cc5d0631b74 to your computer and use it in GitHub Desktop.
GSM
#!/bin/python2
# -*- encoding: utf-8 -*-
import numpy
from collections import namedtuple
std_t = namedtuple("standards_taps", ("times", "dbs"))
def standard_to_taps(std, time_scale = 10, verbose = False):
tap_id= numpy.array(std.times * time_scale, dtype=numpy.int)
absolutes = 10**(std.dbs/10)
taps = numpy.zeros(max(tap_id)+1, numpy.float32)
taps[tap_id] = absolutes
if verbose:
print tap_id.tolist()
print absolutes.tolist()
return taps
TU_1 = std_t(times = numpy.array([0.0, 0.1, 0.3, 0.5, 0.8, 1.1, 1.3, 1.7, 2.3, 3.1, 3.2, 5.0]),
dbs = numpy.array([-4.0, -3.0, 0.0, -2.6, -3.0, -5.0, -7.0, -5.0, -6.5, -8.6, -11.0, -10.0]))
#RA = std_t(times = numpy.array([ 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, ]),
# dbs = numpy.array([ 0.0, -4.0, -8.0, -12.0, -16.0, -20.0, ]))
#
#HT = std_t(times = numpy.array([ 0.0, 0.1, 0.3, 0.5, 0.7, 1.0, 1.3, 15.0, 15.2, 15.7, 17.2, 20.0]),
# dbs = numpy.array([ -10.0, -8.0, -6.0, -4.0, 0.0, 0.0, -4.0, -8.0, -9.0, -10.0, -12.0, -14.0])
if __name__ == "__main__":
from matplotlib import pyplot
from scipy.signal import freqz
try:
import seaborn
except:
pass
taps = standard_to_taps(TU_1, verbose = True)
print taps.tolist()
print sum(taps)
w, h = freqz(taps)
w /= 2* numpy.pi
w *= 5000
pyplot.xlabel("kHz")
pyplot.ylabel("dB")
pyplot.plot(w,10*numpy.log10(h))
pyplot.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment