Beispiel #1
0
def test_TCXOSine_compute1():
  '''
  Unit test for TCXOSine object: 1.+sin(2*pi*t/0.004)

  The integral output is: 1.*t + (1. - cos(2*pi*t/0.004))*0.004/(2*pi);
  After removing the time component:
  Minimum value: 0
  Maximum value: 0.002/pi
  '''
  tcxo = TCXOSine(1e6, 1e6, 0.004)
  time = tcxo.computeTcxoTime(
      0, NormalRateConfig.SAMPLE_RATE_HZ * 0.004 + 1, NormalRateConfig)

  # Remove linear time component
  timeX_s = (NormalRateConfig.SAMPLE_RATE_HZ * 0.004 + 1) / \
      NormalRateConfig.SAMPLE_RATE_HZ
  time -= numpy.linspace(0, timeX_s,
                         NormalRateConfig.SAMPLE_RATE_HZ * 0.004 + 1,
                         endpoint=False)
  assert time[0] == 0.
  assert time[-1] == 0.
  _max = numpy.max(time)
  _min = numpy.min(time)
  assert numpy.abs(_min) < EPSILON
  assert numpy.abs(_max - 0.004 / pi) < EPSILON
  assert time[NormalRateConfig.SAMPLE_RATE_HZ * 0.002] == _max
Beispiel #2
0
        def __call__(self, parser, namespace, values, option_string=None):
            setattr(namespace, self.dest, values)

            if namespace.tcxo_type == "poly":
                coeffs = []
                hasHighOrder = False

                srcA = [
                    namespace.tcxo_a3, namespace.tcxo_a2, namespace.tcxo_a1,
                    namespace.tcxo_a0
                ]
                for a in srcA:
                    if a is not None:
                        coeffs.append(a)
                        hasHighOrder = True
                    elif hasHighOrder:
                        coeffs.append(0.)
                tcxo = TCXOPoly(coeffs)
            elif namespace.tcxo_type == "sine":
                initial = 0.
                ampl = 0.5
                period_s = 1.
                if namespace.tcxo_a0 is not None:
                    ampl = namespace.tcxo_a0
                if namespace.tcxo_a1 is not None:
                    ampl = namespace.tcxo_a1
                if namespace.tcxo_period is not None:
                    period_s = namespace.tcxo_period

                tcxo = TCXOSine(initial, ampl, period_s)
            else:
                raise ValueError("Unsupported TCXO type")
            namespace.tcxo = tcxo
Beispiel #3
0
def test_TCXOSine_compute0():
  '''
  Unit test for TCXOSine object: 0.+sin(2*pi*t/0.004)

  The integral output is: (1. - cos(2*pi*t/0.004))*0.004/(2*pi);
  Minimum value: 0
  Maximum value: 0.002/pi
  '''
  tcxo = TCXOSine(0., 1e6, 0.004)
  time = tcxo.computeTcxoTime(
      0, NormalRateConfig.SAMPLE_RATE_HZ * 0.004 + 1, NormalRateConfig)
  assert time[0] == 0.
  assert time[-1] == 0.
  _max = numpy.max(time)
  _min = numpy.min(time)
  assert numpy.abs(_min) < EPSILON
  assert numpy.abs(_max - 0.004 / pi) < EPSILON
  assert time[NormalRateConfig.SAMPLE_RATE_HZ * 0.002] == _max