Ejemplo n.º 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
Ejemplo n.º 2
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